labeling x-axis

8 views
Skip to first unread message

JMK

unread,
Sep 28, 2010, 4:10:42 PM9/28/10
to ggplot2
Hello,

I want to label the x-axis or the actual line -- shown in my
reproducible example as the "99th percentile".

any ideas?


thanks,

Josh

test=data.frame(a=c(rlnorm(120,0.00119,.01),6))#create data
p=ggplot(test,aes(x=a)) +geom_histogram()#create histogram
quantile(test$a,.99)#get 99th percentile#find 99th percentile
p +geom_vline(xintercept=1.031367,colour="grey60")#put grey line on
99th percentile




James Howison

unread,
Sep 28, 2010, 5:10:45 PM9/28/10
to ggplot2
You could add it to the x labels or you could use geom_text

+ geom_text(aes(x=1.031367,y=75),label="99th Percentile line",hjust=-0.05)

--J

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

JMK

unread,
Sep 28, 2010, 6:00:20 PM9/28/10
to ggplot2
thanks James,

I adjusted the text color and position.

Josh


+geom_vline(xintercept=1.031367,colour="grey60")+
geom_text(aes(x=1.031367,y=-2),label="99th",hjust=-0.05,colour="grey60")


On Sep 28, 2:10 pm, James Howison <ja...@freelancepropaganda.com>
wrote:
Reply all
Reply to author
Forward
0 new messages