Issues with geom_vline with bar/histogram plots

13 views
Skip to first unread message

BTCruiser

unread,
Feb 25, 2009, 12:18:53 PM2/25/09
to ggplot2
Hello all,

I have a data frame containing values for a bar/histogram chart. Two
vertical lines are drawn on the plot indicating threshold levels. On
an older version of ggplot2 (2.7.2) this code worked fine, but now
(2.8.1) I receive the following error:

Error in data.frame(..., check.names = FALSE) :
arguments imply differing number of rows: 43, 1

The data frame consists of 43 values for inbound and outbound
directions. If I change the geom_vline intercept argument from
intercept=VALUE to intercept=rep(VALUE,43) the graph is drawn with no
errors. This does not seem correct to me, but if this the proper code
please let me know.

Here is the code that does the graphing that gives the error:

p1 <- ggplot(actualDF,
aes(x=xval,
y=yval,
fill=factor(color, levels=thresholdColors)));
p1$title <- chartTitle;
p1<-p1 + opts(title=chartTitle,plot.title=theme_text(size=10));
p1<-p1 + facet_grid( direction ~ . );
p1<-p1 + geom_histogram(colour="black",stat="identity") +
scale_fill_identity();
p1<-p1 + scale_x_continuous(name="Utilization (bps)") +
scale_y_continuous(name="Percent of Business Day",
formatter="percent");
p1<-p1 + geom_vline(xintercept=green,colour="Yellow",size=1);
p1<-p1 + geom_vline(xintercept=yellow,colour="Red",size=1);
print(p1);

Here is the data frame used (CSV):

xval,yval,direction,color
46511628,0.0050000000,Inbound,Green
69767442,0.0555555556,Inbound,Green
93023256,0.0455555556,Inbound,Green
116279070,0.0833333333,Inbound,Green
139534884,0.1738888889,Inbound,Green
162790698,0.1927777778,Inbound,Green
186046512,0.1511111111,Inbound,Green
209302326,0.0872222222,Inbound,Green
232558140,0.0844444444,Inbound,Green
255813953,0.0427777778,Inbound,Green
279069767,0.0222222222,Inbound,Green
302325581,0.0188888889,Inbound,Green
325581395,0.0122222222,Inbound,Green
348837209,0.0055555556,Inbound,Green
372093023,0.0083333333,Inbound,Green
395348837,0.0055555556,Inbound,Green
418604651,0.0011111111,Inbound,Green
441860465,0.0016666667,Inbound,Green
465116279,0.0011111111,Inbound,Green
488372093,0.0011111111,Inbound,Green
511627907,0.0005555556,Inbound,Green
46511628,0.0238888889,Outbound,Green
69767442,0.0655555556,Outbound,Green
93023256,0.0377777778,Outbound,Green
116279070,0.1961111111,Outbound,Green
139534884,0.2483333333,Outbound,Green
162790698,0.1694444444,Outbound,Green
186046512,0.1138888889,Outbound,Green
209302326,0.0633333333,Outbound,Green
232558140,0.0305555556,Outbound,Green
255813953,0.0261111111,Outbound,Green
279069767,0.0100000000,Outbound,Green
302325581,0.0111111111,Outbound,Green
325581395,0.0022222222,Outbound,Green
348837209,0.0005555556,Outbound,Green
372093023,0.0005555556,Outbound,Green
395348837,0.0005555556,Outbound,Green

Thanks in advance for any assistance.

Regards,

Brian

hadley wickham

unread,
Feb 25, 2009, 4:07:13 PM2/25/09
to BTCruiser, ggplot2
Hi Brian,

Could you please send me a reproducible example that I can just cut
and paste out of your email into R?

Hadley
--
http://had.co.nz/
Reply all
Reply to author
Forward
0 new messages