美文网首页
【R>>ggplot2】标题居中

【R>>ggplot2】标题居中

作者: 高大石头 | 来源:发表于2021-07-15 00:12 被阅读0次

用ggplot2绘图时,

  • theme(plot.title=element_text(hjust=0.5))设置标题居中
  • theme(plot.margin=unit(c(下,左,上,右),"lines")设置与边界的距离
rm(list = ls())
library(ggsci)

ggplot(iris,aes(Species,Sepal.Length,fill=Species))+
  geom_boxplot()+
  scale_fill_lancet()+
  theme_minimal()+
  theme(panel.border = element_blank(),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        axis.line = element_line(color="gray"),
        plot.title = element_text(hjust=0.5),#title居中
        plot.margin = unit(c(3,3,4,4),"lines")#绘画区域与边界的距离
        )+ 
  labs(title = "iris Dataset")

参考链接:

ggplot2使用手册

相关文章

网友评论

      本文标题:【R>>ggplot2】标题居中

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