手动标注一个面板瓦特/多个标签 [英] Manually annotate one panel w/ multiple labels
本文介绍了手动标注一个面板瓦特/多个标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是非常相似,这个问题(<一个href=\"http://stackoverflow.com/questions/2417623/manual-annotate-a-ggplot-with-different-labels-in-different-facets\">link),但我不太清楚如何来操纵它满足我的需求。
This is very similar to this question (link), but I'm not quite sure how to manipulate it for my needs.
我有两个面板刻面的情节,我便想在第一小组三个象限只有一个面板。
I have a faceted plot with two panels, and I would like to label three quadrants in the first panel and only the first panel.
下面是一个模拟数据集:
Here is a mock data set:
dfr=data.frame(
variable=rep(c("A","B"),each=2),
x=c(2,-3,4,-5),
y=c(-2,4,-2,6))
而这里是小区:
p=ggplot(dfr,aes(x,y))+
geom_point()+
facet_grid(variable~.)+
scale_x_continuous(limits=c(-6,6))+
scale_y_continuous(limits=c(-6,6))+
geom_hline(yintercept=0)+
geom_vline(xintercept=0)
这是我想完成什么:
推荐答案
您可以随时创建所需的标签,一个单独的数据帧,并使用绘制它们 geom_text
:
You can always create a separate data frame with the desired labels and plot them using geom_text
:
dfLab <- data.frame(variable = rep("A",3),
x = c(3,3,-3),
y = c(3,-3,-3),
lab = c('I','IV','III'))
ggplot(dfr,aes(x,y))+
geom_point()+
facet_grid(variable~.)+
scale_x_continuous(limits=c(-6,6))+
scale_y_continuous(limits=c(-6,6))+
geom_hline(yintercept=0)+
geom_vline(xintercept=0) +
geom_text(data = dfLab,aes(x=x,y=y,label=lab))
这篇关于手动标注一个面板瓦特/多个标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文