2017-03-04 53 views
4

基本上是在主题行说。下面的代码生成一个情节与水平的Y标签:当我改变轴的位置ggplot停止轴标签的旋转

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)) 

horizontal axis lable

但是当我移动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)) 

axis on right, vertical label :(

这感觉就像这样一个愚蠢的问题,我敢肯定,我只是失去了一些东西明显。 Plz帮助我。

+1

这似乎是一个问题。我会将问题提交到https://github.com/tidyverse/ggplot2。 – troh

回答

2

只需添加.rightaxis.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

+0

我知道必须有一个简单的解决方案。谢谢! –