ylim-question

46 views
Skip to first unread message

july

unread,
Jan 17, 2011, 3:34:05 AM1/17/11
to ggplot2
Hi there,

I've created a plot with the following commands:

p <- ggplot(plotData, aes(x = variable, y = value, colour = catVar,
group = catVar))
p <- p + stat_summary(fun.y = mean, geom = "line")
p <- p + stat_summary(fun.ymax = errorUpper, fun.ymin = errorLower,
geom = "errorbar", width=0.25)

Even if I print the plot without errorbars, the y-limit is too high.
It looks like it takes the raw data to calculate the y-limit instead
of the summarized data. Is it true? Is there any other solution beside
changing the viewport?
Or is there any mistake I'm not aware of?

Brandon Hurr

unread,
Jan 17, 2011, 4:13:34 AM1/17/11
to july, ggplot2
You could set your limits manually using coord_cartesian. http://had.co.nz/ggplot2/coord_cartesian.html

p + coord_cartesian(ylim = c(325, 500), wise=TRUE) 

I'm not sure if it is taking into account the data range or the range of what is being plotted though. 

B


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

july

unread,
Jan 18, 2011, 4:17:16 AM1/18/11
to ggplot2
Okay, I was not yet aware of this option (I reached this chapter of
the book today :-)).
Anyhow, it's a bit annoying to group the data and calculate the ranges
of the summarized values by myself. This is exactly what ggplot tries
to avoid, no?

A



On Jan 17, 10:13 am, Brandon Hurr <brandon.h...@gmail.com> wrote:
> You could set your limits manually using coord_cartesian.http://had.co.nz/ggplot2/coord_cartesian.html
>
> p + coord_cartesian(ylim = c(325, 500), wise=TRUE)
>
> I'm not sure if it is taking into account the data range or the range of
> what is being plotted though.
>
> B
>
> On Mon, Jan 17, 2011 at 08:34, july <antje.niederl...@googlemail.com> wrote:
> > Hi there,
>
> > I've created a plot with the following commands:
>
> > p <- ggplot(plotData, aes(x = variable, y = value, colour = catVar,
> > group = catVar))
> > p <- p + stat_summary(fun.y = mean, geom = "line")
> > p <- p + stat_summary(fun.ymax = errorUpper, fun.ymin = errorLower,
> > geom = "errorbar", width=0.25)
>
> > Even if I print the plot without errorbars, the y-limit is too high.
> > It looks like it takes the raw data to calculate the y-limit instead
> > of the summarized data. Is it true? Is there any other solution beside
> > changing the viewport?
> > Or is there any mistake I'm not aware of?
>
> > --
> > 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<ggplot2%2Bunsu...@googlegroups.com>
> > More options:http://groups.google.com/group/ggplot2

Hadley Wickham

unread,
Jan 18, 2011, 10:35:09 AM1/18/11
to july, ggplot2
This should be fixed in the next version (hopefully)
Hadley

> More options: http://groups.google.com/group/ggplot2
>

--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

Reply all
Reply to author
Forward
0 new messages