Dear All,
I am struggling with the ggplot2_0.9 in order to reuse my previous code. I asked Had for an help and he suggests me to post again my request to the list (trying to provide a reproducible example). Here it is.
Sorry for posting again the question, I try to better explain my problem.
The following code worked perfectly for me on a linux system with ggplot2_0.8.5 on an older R version:
--------------------------------------------------------------------------------------
library(ggplot2)
library(MASS)
stat_sum_single <- function(fun, geom="point", colour="red", size=3, ...) {
stat_summary(fun.y=fun, colour=colour, geom=geom, size=size, ...)
}
stat_sum_crossbar <- function(fun1, fun2, fun3, geom="crossbar", colour="blue", ...) {
stat_summary(fun.y=fun1, fun.ymin=fun2, fun.ymax=fun3, colour=colour, geom=geom, ...)
}
carsRidotto <- subset(Cars93, Passengers %in% 4:6)
ggp <- qplot(data= carsRidotto, Passengers, Price, geom="point")
ggp2 <- ggp + stat_sum_single(mean, shape=8, size=8)
ggp2 <- ggp2 + stat_sum_single(function(x) quantile(x, 0.1), colour="orange", shape=17, size=7) +
stat_sum_single(function(x) quantile(x, 0.9), colour="orange", shape=17, size=7)
ggp2 <- ggp2 + stat_sum_crossbar(function(x) quantile(x, 0.5),
function(x) quantile(x, 0.25),
function(x) quantile(x, 0.75),
geom="crossbar", colour="blue", width=0.5)
ggp2
ggp3 <- ggp2 +
stat_quantile(colour="blue", size=1, linetype=2) +
stat_quantile(colour="orange", size=1, linetype="twodash",quantiles=c(0.1, 0.9)) +
stat_smooth(method=lm, se=FALSE, colour="red")
ggp3
--------------------------------------------------------------------------------
Here you can find the three resulting graphs:
http://stat.unicas.it/downloadStatUnicas/appoggio/fig-ggp.pdf
http://stat.unicas.it/downloadStatUnicas/appoggio/fig-ggp2.pdf
http://stat.unicas.it/downloadStatUnicas/appoggio/fig-ggp3.pdf
and here is my sessionInfo():
http://stat.unicas.it/downloadStatUnicas/appoggio/sessionInfo.txt
Using the last version of ggplot2 on a Mac OsX installation, I have problem with the second plot. Here is my new sessionInfo()
http://stat.unicas.it/downloadStatUnicas/appoggio/sessionInfoNew.txt
In particular here is the resulting "bad" plot:
http://stat.unicas.it/downloadStatUnicas/appoggio/bad-fig-ggp2.pdf
The third plot correctly adds the regression lines to the second plot (I think the problem lies in the stat_sum_crossbar function). Here is the "bad" third plot:
http://stat.unicas.it/downloadStatUnicas/appoggio/bad-fig-ggp3.pdf
Thanks to the help of Brian Diggs, I succeed in reproduce the ggp2 plot using the group aesthetic in the qplot, i.e. as follows:
ggp <- qplot(data= carsRidotto, Passengers, Price, geom="point", group=Passengers)
but using such change I am not more able to reproduce the third plot.
I really appreciate any suggestion.
Ciao,
domenico
| From: | Domenico Vistocco <domenico...@gmail.com> |
| To: | ggp...@googlegroups.com |
| Date: | 05/03/2012 10:33 AM |
| Subject: | a problem with crossbar (moving to ggplot0.9) |
| Sent by: | ggp...@googlegroups.com |
--
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
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+unsubscribe@googlegroups.com
More options: http://groups.google.com/group/ggplot2
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+unsubscribe@googlegroups.com
More options: http://groups.google.com/group/ggplot2
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+unsubscribe@googlegroups.com
More options: http://groups.google.com/group/ggplot2