How to change the Y-axis title to horizontal using ggplot2 in R?

The default direction of Y-axis title using ggplot2 in R is vertical and we can change to horizontal. For this purpose, we can use theme function of ggplot2 package. We would need to use the argument of theme function as axis.title.y=element_text(angle=0)) and this will write the Y-axis title to horizontal but the position will be changed to top.

Example

ggplot(df,aes(x))+geom_histogram(bins=30)+theme(axis.title.y=element_text(angle=0))

Output

Updated on: 2026-03-11T23:22:53+05:30

4K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements