[英]When I change axis position ggplot stops axis label rotation
Basically what is says in the subject line. 基本上在主题行中说的是什么。 The following code produces a plot with a horizontal y label:
以下代码生成带有水平y标签的图:
require(ggplot2)
silly.plott <- data.frame(silly = c(1,2,3,4,5), plott = c(1,2,3,4,5))
ggplot(silly.plott, aes(x = silly, y = plott))+
geom_point()+
theme(axis.title.y = element_text(angle = 0, vjust = 0.5))
But when I move the y axis to the left side the labels turn vertical! 但当我将y轴移动到左侧时,标签会垂直转动!
ggplot(silly.plott, aes(x = silly, y = plott))+
geom_point()+
scale_y_continuous(position = "right")+
theme(axis.title.y = element_text(angle = 0, vjust = 0.5))
This feels like such a silly problem and I'm positive I'm just missing something obvious. 这感觉就像这样一个愚蠢的问题而且我很肯定我只是错过了一些明显的东西。 Plz help me.
Plz帮助我。
Just add .right
to the axis.title.y
: 只需将
.right
添加到axis.title.y
:
ggplot(silly.plott, aes(x = silly, y = plott))+
geom_point()+
scale_y_continuous(position = "right")+
theme(axis.title.y.right = element_text(angle = 0, vjust = 0.5))
( https://github.com/tidyverse/ggplot2/blob/master/NEWS.md ) ( https://github.com/tidyverse/ggplot2/blob/master/NEWS.md )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.