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 needs to install and import the plotrix package to the working console of the R, further the user needs to call the gap.plot() function further pass the data created for the plot and the gap coordinates as per requirements of the user as the parameters to get the break y-axis of plot accordingly in the R programming language.
Syntax to install and import the plotrix package in the R console:
install.packages("plotrix") library("plotrix")
gap.plot() function: This function displays a plot with one or two missing ranges on one of the axes.
Syntax: gap.plot(x,y,gap)
Arguments::
- x,y: data values
- gap: the range(s) of values to be left out
Example:
In this example, we have created the Break Y-Axis of Plot at the 10, 20 coordinates of the scatter plot created of the data 50 to 1 in both the axis using the gap.plot() function in the R programming language.
R
# Import required libraries library ( "plotrix" ) # Create data x<-50:1 y<-50:1 # Apply gap.plot function gap.plot (x, y,gap = c (10, 20)) |
Output:
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.