R语言怎么调整图的位置
本篇内容主要讲解“R语言怎么调整图的位置”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“R语言怎么调整图的位置”吧!
创新互联是专业的凌河网站建设公司,凌河接单;提供网站设计、成都网站设计,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行凌河网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!

我选择使用R语言的ggplot2来实现,这个是箱线图和热图的拼接,右侧的热图可以借助
geom_point()
函数实现,将点的形状改为正方块,数值按照正负来映射颜色,按照一定的数值来映射大小。
df<-data.frame(x=LETTERS[1:4],y=1:4)
df

library(ggplot2)
ggplot(data=df,aes(x=x,y=y))+
geom_col(aes(fill=x))

使用theme()
函数中的legend.box.margin
参数来调节
ggplot(data=df,aes(x=x,y=y))+
geom_col(aes(fill=x))+
theme(legend.box.margin = margin(0,0,0,5,unit = 'cm'))


通过 legend.justification
参数来实现
ggplot(data=df,aes(x=x,y=y))+
geom_col(aes(fill=x))+
theme(legend.box.margin = margin(0,0,0,5,unit = 'cm'),
legend.justification = c(0,1))

分别需要用到legend.spacing.y
和legend.spacing.x
参数
ggplot(data=df,aes(x=x,y=y))+
geom_col(aes(fill=x))+
theme(legend.box.margin = margin(0,0,0,5,unit = 'cm'),
legend.justification = c(0,1),
legend.spacing.y = unit(5,'cm'),
legend.spacing.x = unit(5,'cm'))

到此,相信大家对“R语言怎么调整图的位置”有了更深的了解,不妨来实际操作一番吧!这里是创新互联网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
文章题目:R语言怎么调整图的位置
转载源于:http://pwwzsj.com/article/gehede.html