plot nothing but only vline?

6 views
Skip to first unread message

Zhenjiang Lan

unread,
Feb 9, 2012, 5:43:46 PM2/9/12
to ggplot2
Dear all,

my question is,

I have a dataset contained only two col: one is "x" and the other is "group".
I want to plot only vertical line with "x", and facet by "group".

How can I do this?

thanks a lot!

ZL

Winston Chang

unread,
Feb 10, 2012, 12:33:25 AM2/10/12
to Zhenjiang Lan, ggplot2
Hi - it would help us help you if you include a reproducible example -- at the very least, a data set. See this page: http://gist.github.com/270442



ZL

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

Zhenjiang Lan

unread,
Feb 10, 2012, 3:04:10 PM2/10/12
to Winston Chang, ggplot2
Thank you!
I think here's an example:

mydf<-data.frame(pos=sample(100,size=12),grp=rep(1:3,each=4))

now I want to plot all 'pos' as vertical-line into different facet (by 'grp').

How can I do this using ggplot2?

Dennis Murphy

unread,
Feb 10, 2012, 3:41:57 PM2/10/12
to Zhenjiang Lan, Winston Chang, ggplot2
Hi:

Here's one way, setting ylim().

mydf<-data.frame(pos=sample(100,size=12),grp=rep(1:3,each=4))
ggplot(mydf) + geom_vline(aes(xintercept = pos)) + facet_wrap(~ grp) +
ylim(0, 1)

In 0.8.9 this yields a 2 x 2 arrangement of facets; in 0.9.0, it
yields a 1 x 3 arrangement.

HTH,
Dennis

Reply all
Reply to author
Forward
0 new messages