- 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 change the Y-axis values in a bar plot using ggplot2 in R?
Bar plot is frequently used to analyze the number of times a level of factor variable occurs in a data set and the Y-axis values are crucial to the bar plot. Sometimes these values are not in the form we want, therefore, we want to replace them with the new ones. This can be done with the help of breaks argument of scale_y_continuous function in ggplot2.
Example
Consider the below data frame −
> set.seed(1) > x<-rpois(50,5) > df<-data.frame(x)
Loading ggplot2 package −
> library(ggplot2)
Creating the plot without specifying the Y-axis values −
> ggplot(df,aes(x))+ + geom_bar()
Output
Plotting with new Y-axis values −
> ggplot(df,aes(x))+ + geom_bar()+ + scale_y_continuous(breaks=c(0,2,4,6,8,10))
Output
- Related Articles
- How to create a bar plot using ggplot2 with percentage on Y-axis in R?
- How to change legend values in a bar plot created by using ggplot2 in R?
- How to change the automatic sorting of X-axis of a bar plot using ggplot2 in R?
- How to change the Y-axis title to horizontal using ggplot2 in R?
- How to create bar plot with log values using ggplot2 in R?
- How to change the color of bars of a bar plot using ggplot2 in R?
- How to convert the X-axis label in a bar plot to italic using ggplot2 in R?
- How to change the text size of Y-axis title using ggplot2 in R?
- How to change the adjustment of the plot title using ggplot2 to align it above the Y-axis labels in R?
- How to create transparent bar plot using ggplot2 in R?
- How to change the Y-axis title in base R plot?
- How to change the Y axis limit for boxplot created by using ggplot2 in R?
- How to create a histogram with Y-axis values as count using ggplot2 in R?
- How to create a bar plot with ggplot2 using stat_summary in R?
- How to change the gridlines of Y-axis on a chart created by using ggplot2 in R?

Advertisements