如何在facet ggplot的空白区域定位注释文本
How to position annotate text in the blank area of facet ggplot
如何在奇数多面 ggplot 中的空白 space 中注释一些文本。
让我们有一个带有 2 行和 2 列数据的分面 ggplot。所以有空白 space 代替 2 行,第 2 列。
df<- data.frame(Ara = rep("XTX", each = 3),
Len = c(744, 750, 755),
Mon = c("Sep", "Oct","Nov"),
Value=c(11.224,10.15,4.23))
df
facetplot<-ggplot(df, aes(x=Value, y=Len, shape=Ara))+
geom_point(size=5.0)+
theme(legend.position = c(.7, .4), legend.direction="vertical")+
facet_wrap(~Mon,scales="free_x", nrow=2)
facetplot
现在我正在尝试在 space 中注释一些文本,但不能(如图中以红色书写)。我正在寻找类似于 legend.position 的注释文本。有没有人知道 this.Or 可能的解决方法是什么?
谢谢。
创建绘图后,只需使用
print(facetplot)
grid.text("your text", x = 0.75, y = 0.25)
有关定位的详细信息,请参见?grid.text
。默认坐标系是整个屏幕设备,左下为(0,0),右上为(1,1)。
修改 grid.text 的图形参数设置,例如字体颜色、系列、字体和大小...
grid.text("your text", x = 0.6, y = 0.15, gp = gpar(col="red", fontsize = 20, family = "Times", fontface = "italic"))
如何在奇数多面 ggplot 中的空白 space 中注释一些文本。 让我们有一个带有 2 行和 2 列数据的分面 ggplot。所以有空白 space 代替 2 行,第 2 列。
df<- data.frame(Ara = rep("XTX", each = 3),
Len = c(744, 750, 755),
Mon = c("Sep", "Oct","Nov"),
Value=c(11.224,10.15,4.23))
df
facetplot<-ggplot(df, aes(x=Value, y=Len, shape=Ara))+
geom_point(size=5.0)+
theme(legend.position = c(.7, .4), legend.direction="vertical")+
facet_wrap(~Mon,scales="free_x", nrow=2)
facetplot
创建绘图后,只需使用
print(facetplot)
grid.text("your text", x = 0.75, y = 0.25)
有关定位的详细信息,请参见?grid.text
。默认坐标系是整个屏幕设备,左下为(0,0),右上为(1,1)。
修改 grid.text 的图形参数设置,例如字体颜色、系列、字体和大小...
grid.text("your text", x = 0.6, y = 0.15, gp = gpar(col="red", fontsize = 20, family = "Times", fontface = "italic"))