Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/64.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 旋转x轴标签并更改ggplot2中的主题_R_Ggplot2 - Fatal编程技术网

R 旋转x轴标签并更改ggplot2中的主题

R 旋转x轴标签并更改ggplot2中的主题,r,ggplot2,R,Ggplot2,有没有办法旋转ggplot中的x轴标签,同时更改主题 如果执行此操作,我可以旋转x轴标签: ToothGrowth$dose <- as.factor(ToothGrowth$dose) ggplot(ToothGrowth, aes(x=dose, y=len)) + geom_boxplot() + theme(axis.text.x = element_text(angle = 90, hjust = 1)) ToothGrowth$dose这是因为顺序:theme\u

有没有办法旋转ggplot中的x轴标签,同时更改主题

如果执行此操作,我可以旋转x轴标签:

ToothGrowth$dose <- as.factor(ToothGrowth$dose)
ggplot(ToothGrowth, aes(x=dose, y=len)) + 
  geom_boxplot() +
  theme(axis.text.x = element_text(angle = 90, hjust = 1))

ToothGrowth$dose这是因为顺序:
theme\u minimal
theme
之后覆盖了后者。使用

ggplot(ToothGrowth, aes(x = dose, y = len)) + 
  geom_boxplot() + theme_minimal() +
  theme(axis.text.x = element_text(angle = 90, hjust = 1))
给予


主题
theme\u minimal
改变了很多事情,包括您使用
theme
所做的更改。所以你应该用另一种方式来做:

ToothGrowth$dose <- as.factor(ToothGrowth$dose)
ggplot(ToothGrowth, aes(x=dose, y=len)) + 
  geom_boxplot()
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
ToothGrowth$剂量
ToothGrowth$dose <- as.factor(ToothGrowth$dose)
ggplot(ToothGrowth, aes(x=dose, y=len)) + 
  geom_boxplot()
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 90, hjust = 1)) +