annotate in facet_wrap

1,203 views
Skip to first unread message

Manuel Spínola

unread,
Mar 20, 2011, 11:48:59 AM3/20/11
to ggplot2
Dear list members,

How to annotate text in only one of the graph of a facet_wrap?

x = rnorm(1:10)
y = rnorm(1:10)
sitio = c("a", "b")
df = data.frame(x,y, sitio)
df
p = ggplot(df, aes(x, y))
p + geom_point() + theme_bw() + facet_wrap(~sitio, scales="free") +
annotate("text", x=-0.5, y=0.2, label="This point")

but I want only in graph "a".

Best,

Manuel

--
Manuel Spínola, Ph.D.
Instituto Internacional en Conservación y Manejo de Vida Silvestre
Universidad Nacional
Apartado 1350-3000
Heredia
COSTA RICA
mspi...@una.ac.cr
mspin...@gmail.com
Teléfono: (506) 2277-3598
Fax: (506) 2237-7036
Personal website: Lobito de río
Institutional website: ICOMVIS

Dennis Murphy

unread,
Mar 20, 2011, 12:40:08 PM3/20/11
to Manuel Spínola, ggplot2
Hi:

Following
http://groups.google.com/group/ggplot2/browse_thread/thread/7583b95989b68815/dca9d582ea495d2a?lnk=gst&q=text+one+facet#dca9d582ea495d2a

create a data frame with the coordinates, panel and text label, and then use geom_text():

dfann <- data.frame(x = -0.5, y = 0.2, sitio = 'a', labl = 'This point')

p + geom_point() + theme_bw() + facet_wrap(~sitio, scales="free") +
      geom_text(data = dfann, aes(label = labl))

HTH,
Dennis

--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: http://gist.github.com/270442
 
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2

Reply all
Reply to author
Forward
0 new messages