The following code lifted from
http://had.co.nz/ggplot2/geom_boxplot.html shows a plot about which I
have a question.
p <- ggplot(mtcars, aes(factor(cyl), mpg))
p + geom_boxplot(aes(fill = factor(vs)))
In the mtcars data there are no cars which have 8 cylinders and a value
of 1 for vs. All the 8 cylinder cars have a value for 0. Because of
this, the boxplot for 8 cylinders, vs=0 is twice as wide as the the rest
of the boxplots.
Is there any way to make the boxplot widths uniform despite the fact
that there are missing values? Ideally, I'd like the mpg data for 8
cylinder, vs=0 cars to be plotted to the left of the gridline for 8
cylinders, and the space to the right of the gridline left blank.
Thanks
Ted Mendum
here is a very very ad-hoc and dirty and clumsy example ...
mtcars2 <- transform(mtcars, visible="black")
d <- rbind(mtcars2, transform(mtcars2[1,], cyl=8, vs=1, mpg=15, visible=NA))
p <- ggplot(d, aes(factor(cyl), mpg)) +
geom_boxplot(aes(fill = factor(vs), colour=visible)) +
scale_colour_identity(legend=FALSE)
is there a better way?
--
Kohske Takahashi <takahash...@gmail.com>
Research Center for Advanced Science and Technology,
The University of Tokyo, Japan.
http://www.fennel.rcast.u-tokyo.ac.jp/profilee_ktakahashi.html
> --
> 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
>