Set Axis Breaks of ggplot2 Plot in R Last Updated : 23 Aug, 2021 Comments Improve Suggest changes Like Article Like Report In this article, we are going to see how to set axis break of ggplot2 plot in R Programming Language. To add axis breaks in ggplot2 plots in R, we use scale_x_break() and scale_y_break() functions. These functions take a vector as a parameter that has breakpoints. If we need multiple breakpoints we can add those too. Syntax: scale_x_continuous(breaks = <break-vec>) scale_y_continuous(breaks = <break-vec>) Example 1: Specify X-Axis Ticks in ggplot2 Plot Here is a ggplot2 scatter plot with x-axis break using scale_x_continuous() function. This function has a breaks parameter that takes a vector as input which has all the points of axis break as vector points. So, here we can set the axis breaks point to a plot manually. Code: R # Create sample data set.seed(5642) sample_data <- data.frame(x = rnorm(1000), y = rnorm(1000)) # Load ggplot2 and ggbreak library("ggplot2") library("ggbreak") # create plot with axis break ggplot(sample_data, aes(x = x, y = y)) + geom_point() + scale_x_continuous(breaks = c(-1,0, 1)) Output: Example 2: Specify Y-Axis Ticks in ggplot2 Plot Here is a ggplot2 scatter plot with y-axis break using the scale_y_continuous() function. This function has a breaks parameter that takes a vector as input which has all the points of y-axis break as vector points. So, here we can set the axis breaks point to a plot manually. R # Create sample data set.seed(5642) sample_data <- data.frame(x = rnorm(1000), y = rnorm(1000)) # Load ggplot2 and ggbreak library("ggplot2") library("ggbreak") # create plot with axis break ggplot(sample_data, aes(x = x, y = y)) + geom_point() + scale_y_continuous(breaks = c(-2, -1, 0, 1)) Output: Example 3: Specifying Sequence of Axis Ticks in ggplot2 Plot To specify the sequence of axis ticks we use the seq function as a parameter to breaks the property of scale_x_continuous / scale_y_continuous instead of vector. Here instead of giving input as a vector, we give input as a sequence that has three points, the first is starting break, the second is ending break and the third one is break period between starting and ending break. Syntax: plot+ scale_x_continuous(breaks = <seq-vec>) / scale_y_continuous(breaks = <seq-vec>) Code: R # Create sample data set.seed(5642) sample_data <- data.frame(x = rnorm(1000), y = rnorm(1000)) # Load ggplot2 and ggbreak library("ggplot2") library("ggbreak") # create plot with axis break ggplot(sample_data, aes(x = x, y = y)) + geom_point() + scale_x_continuous(breaks = seq(-3, 4, 0.2)) Output: Comment More infoAdvertise with us Next Article Set Axis Breaks of ggplot2 Plot in R M mishrapriyank17 Follow Improve Article Tags : R Language R-ggplot Similar Reads Set Area Margins of ggplot2 Plot in R In this article, we will discuss how to set area margins of the ggplot2 plot in the R programming language. To do this call the theme() function and use the plot.margin argument of this function with the required data to this argument as per the requirement of the user. theme() function is a powerf 1 min read Break Axis of Plot in R In this article, we will discuss the break axis of the plot with its working examples in the R programming language. Methodn1: Break Y-Axis of Plot Using gap.plot() Function of plotrix Package In this method break y-axis of the plot using the gap.plot() Function of plotrix Package, the user first n 4 min read Set Origin of ggplot2 Plot Axes to Zero in R In this article, we will be looking at the approach to set the origin of the ggplot2 plot axes to zero with the help of some functions of R programming language. In this approach to set the origin of the ggplot2 plot axes to zero, the user first needs to install and import the ggplot2 package in the 2 min read Set Axis Limits of ggplot2 Facet Plot in R - ggplot2 In this article, we will discuss how to set the axis limits of the ggplot2 facet plot in the R programming language. Method 1: Set axis limits of ggplot2 facet plot with Free Scales Here the role of the ggplot2 package is to plot the facet plot and provide some functionalities to the user, further t 5 min read Add Panel Border to ggplot2 Plot in R In this article, we will use theme() function to add panel border to the plot in R Programming Language. Here we will create a scatter plot, but you can apply it to any plot and add a Panel Border to that one. Approach:Specify the data object, and it has to be a dataframe. Here it has two variable n 3 min read How to set axis limits in ggplot2 in R? In this article, we are going to see how to set the axis limit in ggplot2 in R Programming Language. Method 1: Using coord_cartesian() This method is most helpful as it displays the plot within the limits of the axis without clipping the actual data. It just zooms in and shows the area under limits. 2 min read Add Text to ggplot2 Plot in R In this article, we are going to see how to add Text to the ggplot2 plot in R Programming Language. To do this annotate() is used. It is useful for adding small annotations (such as text labels) or if you have your data in vectors, and for some reason don't want to put them in a data frame. Syntax: 2 min read Divide Legend of ggplot2 Plot in R In this article, we will discuss how to divide the legend of ggplot2 plot in the R programming language. To divide the legend of the ggplot2 plot, the user needs to install and import the gridExtra and cowplot packages in the R console. gridExrta package: Provides a number of user-level functions to 2 min read How to annotate a plot in ggplot2 in R ? In this article, we will discuss how to annotate functions in R Programming Language in ggplot2 and also read the use cases of annotate. What is annotate?An annotate function in R can help the readability of a plot. It allows adding text to a plot or highlighting a specific portion of the curve. Th 4 min read How to plot a subset of a dataframe using ggplot2 in R ? In this article, we will discuss plotting a subset of a data frame using ggplot2 in the R programming language. Dataframe in use:  AgeScoreEnrollNo117700521880103177915419752051885256199630717903581971409188345 To get a complete picture, let us first draw a complete data frame. Example: R # Load ggp 9 min read Like