1

textGrobサブテキスト (a ) を aに追加したいgrid Viewport-- これは可能ですか?

サブテキストを単一のチャートに追加する方法を見つけました:

require(ggplot2) 
require(gridExtra)

# make the data
timeSeries <- data.frame(date = seq(as.Date("2001-01-01"), as.Date("2012-01-01"), by = "mon"), 
                     value = 1:133 + rnorm(133, 0, 10)
                     )


# make the ggplots
gpLine <- ggplot(timeSeries, aes(x = date, y = value)) +
                geom_line()

gpBar <- ggplot(timeSeries, aes(x = date, y = value)) +
                geom_bar(stat = 'identity')

# ggplot + subtext
grid.arrange(gpBar, sub = textGrob("why is this at the bottom?"))

...そして、2 つのチャートをgrid Viewport

# two plots, one view
vplayout <- function(x,y) viewport(layout.pos.row = x, layout.pos.col = y)

pushViewport(viewport(layout = grid.layout(3,1)))
print(gpLine, vp = vplayout(1:2, 1))
print(gpBar, vp = vplayout(3, 1))

...しかし、結果のビューポートの下部にテキストを追加する方法がわかりません。

Gridとても完全なので、きっと道があるはずですが、それは私には隠されています。

4

3 に答える 3