小编KJB*_*KJB的帖子

how to correct x axis text placement when the angle is between 45 and 90?

I'm struggling to understand the interactions for ggplot's axis.text.x: angle, hjust and vjust. Everything I've read works when angle is between 0 and 45, but not for angles > 45 and < 90.

Below is a minimal reproducible example:

library(ggplot2)   
p <- ggplot(mtcars, aes(1000 * mpg, hp)) +
      geom_point()
Run Code Online (Sandbox Code Playgroud)

The first plot with angle = 90 looks as expected,

p + theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5))
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

However, when decreasing the angle by …

r ggplot2

5
推荐指数
1
解决办法
61
查看次数

标签 统计

ggplot2 ×1

r ×1