- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to set the Y-axis tick marks using ggplot2 in R?
The default value of Y-axis tick marks using ggplot2 are taken by R using the provided data but we can set it by using scale_y_continuous function of ggplot2 package. For example, if we want to have values starting from 1 to 10 with a gap of 1 then we can use scale_y_continuous(breaks=seq(1,10,by=1)).
Example
Consider the below data frame: x<-rpois(20,5) y<-rpois(20,2) df<-data.frame(x,y) df
Output
x y 1 8 1 2 4 3 3 1 1 4 4 1 5 3 2 6 3 6 7 6 4 8 3 3 9 7 1 10 4 1 11 5 1 12 6 3 13 3 1 14 6 3 15 8 2 16 0 2 17 8 1 18 5 0 19 4 1 20 4 3
Loading ggplot2 package and creating a point chart between x and y −
Example
library(ggplot2) ggplot(df,aes(x,y))+geom_point()
Output
Creating the point chart with Y-axis tick marks with a difference of 1 −
Example
ggplot(df,aes(x,y))+geom_point()+scale_y_continuous(breaks=seq(1,10,by=1))
Output
- Related Articles
- How to display 0 at Y-axis using ggplot2 in R?
- How to change the Y-axis title to horizontal using ggplot2 in R?
- How to change the tick size using ggplot2 in R?
- How to display Y-axis with Euro sign using ggplot2 in R?
- How to display tick marks on upper as well as right side of the plot using ggplot2 in R?
- How to change the text size of Y-axis title using ggplot2 in R?
- How to increase the axes tick width using ggplot2 in R?
- How to create different Y-axis for group levels using ggplot2 in R?
- How to change the Y-axis values in a bar plot using ggplot2 in R?
- How to change the Y axis limit for boxplot created by using ggplot2 in R?
- How to reduce the space between Y-axis value and ticks using ggplot2 in R?
- How to create a plot with tick marks between X-axis labels in base R?
- How to display count on Y-axis for line chart using ggplot2 in R?
- How to set the X-axis labels in histogram using ggplot2 at the center in R?
- How to remove the axis tick marks on a Seaborn heatmap?

Advertisements