What's not working? Trying to "dodge" point ranges

192 views
Skip to first unread message

adam.l...@pnc.com

unread,
Jan 8, 2013, 9:18:04 AM1/8/13
to ggp...@googlegroups.com
Hi group,

Two things are happening when I run this. First, the dodging doesn't seem to occur. The points and point ranges overlap, although the legend indicates the grouping. Secondly, for some reason, it's not recognizing "ymax." Any ideas? Thanks.

pd.range<-structure(list(rr = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L,
11L, 12L, 13L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L,
12L, 13L), exp = c(1e-07, 1e-06, 1e-05, 1e-04, 4e-04, 9e-04,
0.0041, 0.0075, 0.0134, 0.0202, 0.0433, 0.0732, 0.142, 1e-07,
1e-06, 1e-05, 1e-04, 4e-04, 9e-04, 0.0041, 0.0075, 0.0134, 0.0202,
0.0433, 0.0732, 0.142), min = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0.00069735,
0.002544529, 0.006749156, 0.020874752, 0, 0, 0, 0, 0, 0, 0.000340136,
0.000651678, 0.001752336, 0.0027894, 0.008481764, 0.01799775,
0.046222664), max = c(0, 0, 0, 0, 0.001692047, 0.004405286, 0.015646259,
0.029325513, 0.047926402, 0.070432357, 0.140797286, 0.211473566,
0.344930417, 0, 0, 0, 0, 0.001692047, 0.003568282, 0.013265306,
0.022157054, 0.03796729, 0.055090656, 0.103477523, 0.164229471,
0.279324056), rho = c(0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2,
0.2, 0.2, 0.2, 0.2, 0.2, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1,
0.1, 0.1, 0.1, 0.1, 0.1)), .Names = c("rr", "exp", "min", "max",
"rho"), class = "data.frame", row.names = c(NA, -26L))

ggplot(pd.range,aes(as.factor(rr),exp))+
geom_point(aes(colour=as.factor(rho)),position="dodge")+
geom_pointrange(aes(as.factor(rr),colour=as.factor(rho),ymin=min,ymax=max),position="dodge")




Adam Loveland

The contents of this email are the property of PNC. If it was not addressed to you, you have no legal right to read it. If you think you received it in error, please notify the sender. Do not forward or copy without permission of the sender. This message may contain an advertisement of a product or service and thus may constitute a commercial electronic mail message under US Law. The postal address for PNC is 249 Fifth Avenue, Pittsburgh, PA 15222. If you do not wish to receive any additional advertising or promotional messages from PNC at this e-mail address, click here to unsubscribe. https://pnc.p.delivery.net/m/u/pnc/uni/p.asp
By unsubscribing to this message, you will be unsubscribed from all advertising or promotional messages from PNC. Removing your e-mail address from this mailing list will not affect your subscription to alerts, e-newsletters or account servicing e-mails.


Ista Zahn

unread,
Jan 8, 2013, 9:50:14 AM1/8/13
to adam.l...@pnc.com, ggp...@googlegroups.com
Hi Adam,

On Tue, Jan 8, 2013 at 9:18 AM, <adam.l...@pnc.com> wrote:
> Hi group,
>
> Two things are happening when I run this. First, the dodging doesn't seem to
> occur. The points and point ranges overlap, although the legend indicates
> the grouping.

Points and lines are treated as one-dimensional, i.e., they don't have
a width. So you need to set a width in the position_dodge() call, like
this:

ggplot(pd.range,aes(as.factor(rr),exp))+
geom_pointrange(aes(colour=as.factor(rho),ymin=min,ymax=max),
position=position_dodge(width=0.5))

Best,
Ista
> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example:
> https://github.com/hadley/devtools/wiki/Reproducibility
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2

Brandon Hurr

unread,
Jan 8, 2013, 10:00:26 AM1/8/13
to Ista Zahn, adam.l...@pnc.com, ggplot2
For some reason the ymax warning is actually coming from geom_point...

ggplot(data=pd.range)+ 
#geom_point(aes(x= as.factor(rr),y= exp, colour=as.factor(rho)),position="dodge")+ 
geom_pointrange(aes(x=as.factor(rr), y=exp, colour=as.factor(rho), ymin=min, ymax=max), position=position_dodge(width=0.5))
#GET PLOT, NO WARNING

ggplot(data=pd.range)+ 
geom_point(aes(x= as.factor(rr),y= exp, colour=as.factor(rho)),position="dodge") #+ 
#geom_pointrange(aes(x=as.factor(rr), y=exp, colour=as.factor(rho), ymin=min, ymax=max), position=position_dodge(width=0.5))
#GET PLOT, WARNING
ymax not defined: adjusting position using y instead

ggplot(data=pd.range)+ 
geom_point(aes(x= as.factor(rr),y= exp, colour=as.factor(rho)),position="dodge")+ 
geom_pointrange(aes(x=as.factor(rr), y=exp, colour=as.factor(rho), ymin=min, ymax=max), position=position_dodge(width=0.5))
#GET PLOT, WARNING
ymax not defined: adjusting position using y instead

On Tue, Jan 8, 2013 at 2:50 PM, Ista Zahn <ista...@gmail.com> wrote:
position_dodge(width=0.5)

Reply all
Reply to author
Forward
0 new messages