Display Only Integer Values on ggplot2 Axis in R Last Updated : 23 May, 2021 Comments Improve Suggest changes Like Article Like Report A dataframe to be plotted can support multiple data types in it. Sometimes a float value isn't appropriate since it hampers the clarity and readability of the plot. Thus, if these values were plotted as integers it would easier and clearer. In this article, we will be looking at the approach to display only values on ggplot2 axis in the r language. In this approach of displaying only integer values on ggplot2 axis, user needs to first import and load the ggplot2 library and than call the geom_point() function present in the ggplot2 package and then pass the required parameters to the function and further this function will be returning the plot of the given values. To load and install ggplot2 package user need to follow the below syntax. Syntax: install.packages("ggplot2") library("ggplot2") Here we will plot a scatter plot and for that geom_point() is used. This function is used to plot scatter plot which is most useful for displaying the relationship between two continuous variables. Syntax: geom_point(mapping = NULL,data = NULL,stat = "identity",position = "identity",...,na.rm = FALSE,show.legend = NA, inherit.aes = TRUE) Dataset in consideration : Let us first see how a regular plot without any modification of this dataframe would appear. Example: R library("ggplot2") gfg_data <- data.frame(x=c(1,2,3,4,5,6,7,8,9,10), y=c(7,9,1,4,5,6,2,5,8,1)) gfg_plot <- ggplot(gfg_data, aes(x, y)) + geom_point() gfg_plot Output: Now we will be modifying the axis values of the plot plotted by ggplot2 using geom_point() function, this improving user needs to first load and install the scales library in R programming language, then, call the scale_x_continuous() and scale_y_continuous() function which basically removes non-integer numbers from ggplot2 axes needs from scales library and pass the required parameter into this function and in return, this function will modify the plot created by ggplot2 to the well-scaled plot to the user in r language. scale_x_continuous() and scale_y_continuous() functions are used to make continuous position scales (x & y) or removes non-integer numbers. Syntax: scale_x_continuous(..., expand = waiver())scale_y_continuous(..., expand = waiver()) Parameter: ...:-common continuous scale parameters: name, breaks, labels, na.value, limits and trans.expand:-a numeric vector of length two giving multiplicative and additive expansion constants. Example: R library("ggplot2") library("scales") gfg_data <- data.frame(x=c(1,2,3,4,5,6,7,8,9,10), y=c(7,9,1,4,5,6,2,5,8,1)) gfg_plot <- ggplot(gfg_data, aes(x, y)) + geom_point() gfg_plot + scale_x_continuous(breaks = pretty_breaks())+ scale_y_continuous(breaks = pretty_breaks()) Output: Comment More infoAdvertise with us Next Article Non-linear Components G geetansh044 Follow Improve Article Tags : R Language R-ggplot Similar Reads Non-linear Components In electrical circuits, Non-linear Components are electronic devices that need an external power source to operate actively. Non-Linear Components are those that are changed with respect to the voltage and current. Elements that do not follow ohm's law are called Non-linear Components. Non-linear Co 11 min read Spring Boot Tutorial Spring Boot is a Java framework that makes it easier to create and run Java applications. It simplifies the configuration and setup process, allowing developers to focus more on writing code for their applications. This Spring Boot Tutorial is a comprehensive guide that covers both basic and advance 10 min read Class Diagram | Unified Modeling Language (UML) A UML class diagram is a visual tool that represents the structure of a system by showing its classes, attributes, methods, and the relationships between them. It helps everyone involved in a projectâlike developers and designersâunderstand how the system is organized and how its components interact 12 min read Python Variables In Python, variables are used to store data that can be referenced and manipulated during program execution. A variable is essentially a name that is assigned to a value. Unlike many other programming languages, Python variables do not require explicit declaration of type. The type of the variable i 6 min read Spring Boot Interview Questions and Answers Spring Boot is a Java-based framework used to develop stand-alone, production-ready applications with minimal configuration. Introduced by Pivotal in 2014, it simplifies the development of Spring applications by offering embedded servers, auto-configuration, and fast startup. Many top companies, inc 15+ min read Backpropagation in Neural Network Back Propagation is also known as "Backward Propagation of Errors" is a method used to train neural network . Its goal is to reduce the difference between the modelâs predicted output and the actual output by adjusting the weights and biases in the network.It works iteratively to adjust weights and 9 min read Polymorphism in Java Polymorphism in Java is one of the core concepts in object-oriented programming (OOP) that allows objects to behave differently based on their specific class type. The word polymorphism means having many forms, and it comes from the Greek words poly (many) and morph (forms), this means one entity ca 7 min read What is an Operating System? An Operating System is a System software that manages all the resources of the computing device. Acts as an interface between the software and different parts of the computer or the computer hardware. Manages the overall resources and operations of the computer. Controls and monitors the execution o 5 min read CTE in SQL In SQL, a Common Table Expression (CTE) is an essential tool for simplifying complex queries and making them more readable. By defining temporary result sets that can be referenced multiple times, a CTE in SQL allows developers to break down complicated logic into manageable parts. CTEs help with hi 6 min read Python Functions Python Functions is a block of statements that does a specific task. The idea is to put some commonly or repeatedly done task together and make a function so that instead of writing the same code again and again for different inputs, we can do the function calls to reuse code contained in it over an 9 min read Like