R语言中ggplot绘图设置绘图标签文字到框线的距离

 

001、基础绘图

library(ggplot2)#导入ggplot包

ggplot(data = mtcars,         
       aes(x = wt, y = mpg, 
           colour = factor(cyl))) +  
  geom_point() +
  theme_bw()                ## 基础绘图

 

002、调整x轴上刻度文字到框线的距离

a、设置为-4

library(ggplot2)#导入ggplot包

ggplot(data = mtcars,         
       aes(x = wt, y = mpg, 
           colour = factor(cyl))) +  
  geom_point() +
  theme_bw() +
theme(  axis.text.x = element_text(vjust = -4))      ## 设置为-4

 

b、设置为4

library(ggplot2)#导入ggplot包

ggplot(data = mtcars,         
       aes(x = wt, y = mpg, 
           colour = factor(cyl))) +  
  geom_point() +
  theme_bw() +
theme(  axis.text.x = element_text(vjust = 4))    ## 设置为4

 。

 

posted @ 2024-03-08 18:35  小鲨鱼2018  阅读(43)  评论(0编辑  收藏  举报