[R] Question about ggplot2
Joshua Wiley
jwiley.psych at gmail.com
Tue Nov 2 15:33:39 CET 2010
Dear Shige,
You can use scale_y_continuous() to achieve this.
year.plot <- ggplot(d, aes(year, rate))
year.plot + stat_summary(fun.y = "mean", geom = "line") +
scale_y_continuous(limits = c(0, .1))
where limits may be whatever you like for the y axis.
Cheers,
Josh
On Tue, Nov 2, 2010 at 6:57 AM, Shige Song <shigesong at gmail.com> wrote:
> Dear All,
>
> I am trying to graph a simple scatter plot where the x axis is year
> and the y axis is a percentage (percentage of infant death). Instead
> of plotting the raw data, I want to plot summary statistics such as
> mean and median. Here is the problem: the value range of y is between
> 0 and 1, but since infant death is a rare event, the mean and median
> is very low (something like 5%), which shows up as a horizontal line
> at the bottom of the figure. My question is: how do I change the scale
> of the y-axis so that it does not have the range between 0 and 1 but
> between 0 and 0.1? Many thanks.
>
> By the way, I am using ggplot2, and here is my code:
>
> -------------------------------
> year.plot <- ggplot(d, aes(year, rate))
> year.plot + stat_summary(fun.y = "mean", geom = "line")
> -------------------------------
>
> Best,
> Shige
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/
More information about the R-help
mailing list