2011-08-15 1 views
3

これはこの質問(link)と非常によく似ていますが、私のニーズにどのように操作するかはわかりません。手動で1つのパネルに複数のラベル付きで注釈を付ける

私は2つのパネルを持つファセットプロットを持っており、最初のパネルには3つの象限を、最初のパネルには3つの象限を付けたいと思います。ここで

はモックのデータセットである:

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) 

これは私が達成したいものです。

enter image description here

答えて

4

あなたは必要なラベルを持つ別々のデータフレームを作成し、012を使用してプロットすることができます:

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)) 

enter image description here

+0

ああD'、それは私のコードのエラーだった、私は今愚かな感じ。すべて同じに感謝のおかげで! – jslefche

関連する問題