美文网首页
ggplot2: 坐标轴标签

ggplot2: 坐标轴标签

作者: LET149 | 来源:发表于2023-08-02 09:08 被阅读0次

1. 修改坐标轴标签文字

plot()+scale_x_discrete(labels=c(新标签向量))
plot()+scale_y_discrete(labels=c(新标签向量))

2. 对坐标轴标签样式进行修改

plot()+theme(axis.text.x = element_text(size=, color=, angle=, hjust=, vjust=))
plot()+theme(axis.text.y = element_text(size=, color=, angle=, hjust=, vjust=))

常用X轴标签参数:theme(axis.text.x = element_text(size=13, color="black", angle=90, hjust=1, vjust=0.5))
常用Y轴标签参数:theme(axis.text.y = element_text(size=13, color="black", angle=-90, hjust=0, vjust=0.5))

  • size=:字体大小
  • color=:字体颜色
  • angle=:字体相对于水平的角度
  • hjust=:字体水平平移的比例,介于[0,1]之间
  • vjust=:字体垂直平移的比例,介于[0,1]之间

3. 对坐标轴取log10

plot()+scale_x_log10()
plot()+scale_y_log10()

相关文章

网友评论

      本文标题:ggplot2: 坐标轴标签

      本文链接:https://www.haomeiwen.com/subject/ytsniktx.html