Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

How to Rotate Axis Labels in ggplot2?.

Axis labels on graphs must occasionally be rotated.

Let’s look at how to rotate the labels on the axes in a ggplot2 plot.

Let’s begin by creating a basic data frame and the plot.

## Rotate Axis Labels in ggplot2

library(ggplot2)
p <- ggplot(ToothGrowth, aes(x = factor(dose), y = len,fill=factor(dose))) +
geom_boxplot()
p

Normality Test in R » How to Perform » Easy Steps »

### Rotation based on vjust and hjust

p + theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1))

To ensure that the labels are close enough to the plot, you may need to alter the vjust and hjust values depending on the angle at which you rotate the labels.

Correlation Analysis in R? » Karl Pearson correlation coefficient »

### Change axis tick mark labels

p + theme(axis.text.x = element_text(face = "bold", color = "red",
size = 12, angle = 45),
axis.text.y = element_text(face = "bold", color = "blue",
size = 12, angle = 45))

### Remove x and y axis tick mark labels

Let’s Remove x and y-axis tick mark labels

How to measure the Statistics Quality Control Chart of the product?

p + theme(axis.text.x = element_blank(),  axis.text.y = element_blank())

### Remove axis ticks and tick mark labels

p + theme(axis.text.x = element_blank(),  axis.text.y = element_blank(),
axis.ticks = element_blank())

One Sample Analysis in R » Quick Guide »

The post How to Rotate Axis Labels in ggplot2? appeared first on finnstats.