On Mon, Sep 28, 2009 at 07:47:55AM -0700, dpark wrote:
>
> Here is an example scenario:
>
> t$x <- seq(100)
> t$y <- dnorm(t$x, mean=50, sd=10)
> ggplot(t) + geom_area(aes(x, y))
>
> That looks like a perfectly normal bell curve. Now add either ylim
> (0,0.02) or scale_y_continuous(limits=c(0,0.02)) into the mix and look
> at what you get. Two spikes with emptiness in the middle.
>
not for me, see the attached file.
regards,
Stefan
> sessionInfo()
R version 2.9.1 (2009-06-26)
i686-pc-linux-gnu
locale:
LC_CTYPE=de_DE.UTF-8;LC_NUMERIC=C;LC_TIME=de_DE.UTF-8;LC_COLLATE=de_DE.UTF-8;LC_MONETARY=C;LC_MESSAGES=de_DE.UTF-8;LC_PAPER=de_DE.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=de_DE.UTF-8;LC_IDENTIFICATION=C
attached base packages:
[1] grid stats graphics grDevices utils datasets methods
[8] base
other attached packages:
[1] ggplot2_0.8.3 reshape_0.8.3 plyr_0.1.9 proto_0.3-8
loaded via a namespace (and not attached):
[1] tools_2.9.1
No, there aren't - because you've restricted the scale to exclude
them. You probably want the xlim and ylim arguments to
coord_cartesian to zoom into the region of interest.
Hadley
But how could the scales work any other way? If you set
scale_colour_discrete(limits = c("a", "b")) you don't expect "c" and
"d" to some how influence the display of the plot, do you?
> while the coord_(xlim=) syntax restricts the
> *viewport*. Scale_ functions affects the mapping between data and
> plot, while coord_ functions just change the plot. In retrospect, some
> of these functions and parameters perhaps should have been named
> something else...
Possibly, but unless you come up with completely novel names,
everything already has some existing meaning to confuse people.
Hadley
I agree it's a confusing, but I'm not sure what to do about it. It's
mainly a problem because the grammar incorporates statistical
transformations, and changes to the data implied by the scale must be
applied before the statistical transformation (which is why it isn't
so much a problem for geoms with the identity stat).
Hadley