adding text outside the plot area

4,070 views
Skip to first unread message

Manuel Spínola

unread,
Sep 4, 2010, 8:09:13 AM9/4/10
to ggplot2
Dear list members,

How to add text outside the plot area, like mtext

Best,

Manuel

baptiste auguie

unread,
Sep 4, 2010, 8:20:22 AM9/4/10
to Manuel Spínola, ggplot2
Hi,

Using grid.text(),

library(ggplot2)
print(qplot(1,1), vp=viewport(height=0.8))
grid.text(0.5, unit(1,"npc") - unit(1,"line"), label="I'm (slightly)
out of here!")

HTH,

baptiste

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

Manuel Spínola

unread,
Sep 4, 2010, 9:00:36 AM9/4/10
to baptiste auguie, ggplot2
Thank you very much Baptiste,

I would like to recreate the attached plot. My problem is that I don't
know how to specify the "7.81" in ggplot2.
Best,

Manuel


On 04/09/2010 06:20 a.m., baptiste auguie wrote:
> library(ggplot2)
> print(qplot(1,1), vp=viewport(height=0.8))
> grid.text(0.5, unit(1,"npc") - unit(1,"line"), label="I'm (slightly)
> out of here!")


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

plot.png

baptiste auguie

unread,
Sep 4, 2010, 9:28:59 AM9/4/10
to Manuel Spínola, ggplot2
Why don't you just add a y axis break at this value?

qplot(1:10, 1:10) +
scale_y_continuous(breaks=c(seq(2,10,by=2), 3.14)) +
geom_hline(aes(yintercept=y), data=data.frame(y=3.14), colour="blue")

HTH,

baptiste


On Sat, Sep 4, 2010 at 3:00 PM, Manuel Spínola <mspin...@gmail.com> wrote:
>  Thank you very much Baptiste,
>
> I would like to recreate the attached plot.  My problem is that I don't know
> how to specify the "7.81" in ggplot2.
> Best,
>
> Manuel
>
>
> On 04/09/2010 06:20 a.m., baptiste auguie wrote:
>>
>> library(ggplot2)
>> print(qplot(1,1), vp=viewport(height=0.8))
>> grid.text(0.5, unit(1,"npc") - unit(1,"line"), label="I'm (slightly)
>> out of here!")
>
>
> --

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

Reply all
Reply to author
Forward
0 new messages