error message when combine geom_ribbon and geom_point

99 views
Skip to first unread message

pharmpk

unread,
Dec 5, 2012, 11:35:42 PM12/5/12
to ggp...@googlegroups.com
Dear users,

I am using ggplot2 version 0.8.9 and I am encountering an error message "Error in eval(expr, envir, enclos) : object 'Lower' not found" with the following code to draw a graph with ribbons and points,

ggplot(qSum,aes(x=TSLD,ymin=Lower,ymax=Upper))+geom_ribbon(alpha=0.5,fill="blue")+
geom_point(data=nmData2,aes(TSLD,CONC))+
facet_wrap(~STDY,scales = "free")

The weird thing is that if remove the geom_point line, it works and the code is able to draw ribbons:

ggplot(qSum,aes(x=TSLD,ymin=Lower,ymax=Upper))+geom_ribbon(alpha=0.5,fill="blue")+
#geom_point(data=nmData2,aes(TSLD,CONC))+
facet_wrap(~STDY,scales = "free")

It was also confirmed that without geom_ribbon, the code for geom_points also works. Can anyone help to figure out what is the problem here. Thanks in advance!

qSum data looks like this


row.names
TSLDSTDYLowerMedianUpper
110.510521.196415403.38389009.0630550
261.010524.128365509.088305020.9402550
3212.0105210.4093615020.742900038.2269500
4313.0105213.8124700025.804350049.5525400
5414.0105214.3812490030.549150052.0644200
6515.0105217.2643950032.708850053.5060900
7566.0105215.3608550030.297050058.9952550
8618.0105212.8992140027.698650048.2900400
91110.0105213.0233100024.000000043.8901450
101612.010528.7569875018.671950035.6992900
112624.010521.284381954.049545013.1873085
123636.01052-0.012620370.70284753.4038680
134648.01052-0.048458770.22214670.8821970
1420.510531.536375603.34971007.5664380
1571.010534.067487508.793255020.1453500
16222.010539.2548000019.443000036.8088850


nmData2 looks like this


row.names
IDSTDYSSMTSLDDOSECONC
11203052001105200.501006.490
21203152001105201.0010023.300
31203252001105202.0010047.500
41203352001105203.0010062.600
51203452001105204.0010072.500
61203552001105205.0010050.600
71203652001105206.0010042.300
81203752001105208.0010056.700
912038520011052010.0010036.500
1012039520011052012.0010022.900
1112040520011052024.001002.730
1212041520011052036.001000.443
131204552001105200.501004.760
141204652001105201.0010023.800
151204752001105202.0010041.600
161204852001105203.0010055.200
171204952001105204.0010065.200
181205052001105205.0010070.100
191205152001105206.0010061.900
201205252001105208.0010045.300


 

pharmpk

unread,
Dec 5, 2012, 11:40:04 PM12/5/12
to ggp...@googlegroups.com
Sorry that the column name should be moved to the right for one column

Dennis Murphy

unread,
Dec 6, 2012, 12:49:46 AM12/6/12
to pharmpk, ggp...@googlegroups.com
Hi:

On Wed, Dec 5, 2012 at 8:35 PM, pharmpk <yanxia...@gmail.com> wrote:
Dear users,

I am using ggplot2 version 0.8.9 and I am encountering an error message "Error in eval(expr, envir, enclos) : object 'Lower' not found" with the following code to draw a graph with ribbons and points,

ggplot(qSum,aes(x=TSLD,ymin=Lower,ymax=Upper))+geom_ribbon(alpha=0.5,fill="blue")+
geom_point(data=nmData2,aes(TSLD,CONC))+
facet_wrap(~STDY,scales = "free")

Notice that you defined ymin and ymax as aesthetics in the *base* ggplot; it will expect to find these aesthetics in all subsequent layers. Redo the code as follows:

ggplot(qSum, aes(x = TSLD, y = CONC)) +
   geom_ribbon(aes(ymin = Lower, ymax = Upper), fill = "blue", alpha = 0.5) +
   geom_point() +
   facet_wrap(~ STDY, scales = "free") 

In this form. the common aesthetics are x and y, while ymin and ymax are specific to geom_ribbon().

The weird thing is that if remove the geom_point line, it works and the code is able to draw ribbons:

ggplot(qSum,aes(x=TSLD,ymin=Lower,ymax=Upper))+geom_ribbon(alpha=0.5,fill="blue")+
#geom_point(data=nmData2,aes(TSLD,CONC))+
facet_wrap(~STDY,scales = "free")

It was also confirmed that without geom_ribbon, the code for geom_points also works. Can anyone help to figure out what is the problem here. Thanks in advance!

qSum data looks like this

Presenting data of the form below in an e-mail is not productive; it's better to 
(a) dput() an R data object and either paste the result from the console to the e-mail or export it to a text file and attach it to the e-mail; e.g., dput(qSum)
(b) create plain text files such as csv files and attach them to the e-mail, or 
(c) if large, save the data object as an R binary with a .Rdata extension and attach to the mail; e.g. save(qSum, file = "qSum.Rdata")

Dennis


 

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

pharmpk

unread,
Dec 6, 2012, 10:02:03 AM12/6/12
to ggp...@googlegroups.com
Dear Dennis,

Thank you very much!

Xiaoyu
Reply all
Reply to author
Forward
0 new messages