简体   繁体   English

当我改变轴位置ggplot停止轴标签旋转

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM