使用ggplot2在绘图底部绘制标题 [英] Plot title at bottom of plot using ggplot2

查看:1302
本文介绍了使用ggplot2在绘图底部绘制标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  qplot(rnorm(100))在ggplot2中,如何将剧情标题放在剧情的底部。 + ggtitle(我的标题)

将标题置于情节的中间和顶部,它位于图的中间和底部

解决方案

c $ c> grid.text :

  library(grid)
qplot (rnorm(100))+ theme(plot.margin = unit(c(0.5,1,2,0.5),lines))
grid.text(My Title,x = unit(0.5, npc),y =单位(0,npc),
vjust = -0.5,gp = gpar(cex = 1.2))


In ggplot2, how to put the plot title at the bottom of the plot.

qplot(rnorm(100)) + ggtitle("My Title")

puts the title at middle and top of plot, while I want it to be at middle and bottom of the plot.

解决方案

Here is a solution using grid.text:

library("grid")
qplot(rnorm(100)) + theme(plot.margin=unit(c(0.5, 1, 2, 0.5), "lines"))
grid.text("My Title", x = unit(0.5, "npc"), y = unit(0, "npc"),
          vjust = -0.5, gp = gpar(cex=1.2))

这篇关于使用ggplot2在绘图底部绘制标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆