Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R axis.text不改变角度_R_Ggplot2_Axis - Fatal编程技术网

R axis.text不改变角度

R axis.text不改变角度,r,ggplot2,axis,R,Ggplot2,Axis,我知道为了改变x轴的角度,我们应该使用theme()和axis.text.x=element\u text(size=1,angle=90) 对于绘图,我使用了geom_col,因为我的x轴不是一个连续变量,只是类别。谁能告诉我我做错了什么或错过了什么?对于精通R和ggplot的用户来说,一定有一些东西是显而易见的!谢谢大家! data("diamonds") example_df <- diamonds[unique(diamonds$clarity), ] ggplot(exampl

我知道为了改变x轴的角度,我们应该使用
theme()和axis.text.x=element\u text(size=1,angle=90)

对于绘图,我使用了
geom_col
,因为我的x轴不是一个连续变量,只是类别。谁能告诉我我做错了什么或错过了什么?对于精通
R
ggplot
的用户来说,一定有一些东西是显而易见的!谢谢大家!

data("diamonds")
example_df <- diamonds[unique(diamonds$clarity), ]

ggplot(example_df, aes(reorder(clarity, -carat, sum), carat)) +
  geom_col() + 
  xlab("clarity")+
  ylab("carat") +
  theme(axis.text.x=element_text(size=1, angle=45)) +
  geom_hline(yintercept=0.2, linetype="dashed", color = "red") +
  ggtitle("test") +
  theme_bw()
数据(“钻石”)
示例_df在末尾调用
theme\u bw()
将重置先前添加的所有
theme
更改。只有最后一个值仍然存在。只需更改设置值的顺序即可

ggplot(example_df, aes(reorder(clarity, -carat, sum), carat)) +
  geom_col() + 
  xlab("clarity")+
  ylab("carat") +
  geom_hline(yintercept=0.2, linetype="dashed", color = "red") +
  ggtitle("test") +
  theme_bw() + 
  theme(axis.text.x=element_text(size=1, angle=45)) 
在末尾调用
theme\u bw()
将重置先前添加的所有
theme
更改。只有最后一个值仍然存在。只需更改设置值的顺序即可

ggplot(example_df, aes(reorder(clarity, -carat, sum), carat)) +
  geom_col() + 
  xlab("clarity")+
  ylab("carat") +
  geom_hline(yintercept=0.2, linetype="dashed", color = "red") +
  ggtitle("test") +
  theme_bw() + 
  theme(axis.text.x=element_text(size=1, angle=45)) 

谢谢你!!!我以前就有过这个问题,我改变了订单,让它开始工作。但我真的不知道是
theme\u bw()
的顺序导致了这个问题。非常感谢!谢谢你!!!我以前就有过这个问题,我改变了订单,让它开始工作。但我真的不知道是
theme\u bw()
的顺序导致了这个问题。非常感谢!