[R] ggplot question: changing the label for the Y axis on a histogram

Steven Rytina, Prof. steven.rytina at mcgill.ca
Mon Jul 25 21:24:53 CEST 2011

Thanks for taking a look.

	As you can see from my (reduced) example below, I am drawing on counts and then asking bin to aggregate.
	My hunch is that ylab() somehow gets over-ridden in the collaboration implicit in geom_histogram.

	Accordingly, any comment that illuminates the actual mechanics invoked by this (and how to examine them) would be much appareciated. 
vals<-c(-2.601,-2.073,-1.341,-1.126,-1.022,-0.847,-0.839,-0.791,-0.790,-0.683,-0.572,-0.556,-0.538,-0.454,-0.394,-0.342,-0.313,-0.184,-	0.138,0.302,0.307

-----Original Message-----
From: istazahn at gmail.com [mailto:istazahn at gmail.com] On Behalf Of Ista Zahn
Sent: Monday, July 25, 2011 2:02 PM
To: Steven Rytina, Prof.
Cc: r-help at r-project.org
Subject: Re: [R] ggplot question: changing the label for the Y axis on a histogram

Hi Steven,
The basic example works:

qplot(rnorm(100)) + ylab("Bin Counts")

Please post a reproducible example that illustrates the problem you are having.


On Mon, Jul 25, 2011 at 1:40 PM, Steven Rytina, Prof.
<steven.rytina at mcgill.ca> wrote:
> Some help with how to re-label the vertical axis in a histogram  would be appreciated.
>                qplot(off.sc,weight=rel.freq,binwidth=.29,main="test Figure"+ylab("New from inside"))+ylab("New from outside")+
>                                                                xlab("off.sc\nAggregated frequency plots for 17 equal intervals.")
> The code produces a proper histogram. However, the y axis is labeled count
>                and this needs to be changed because the data is relative frequencies (sample proportions.)
> ylab() does not do the trick (in either position). Does anyone know what works?
>                Thanks
>                Steve Rytina, McGill University
>        [[alternative HTML version deleted]]
> ______________________________________________
> 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.

Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology

More information about the R-help mailing list