[R] R Stacked Histogram

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Tue Jan 6 16:54:54 CET 2009

Dear Jason,

Have a look at scale_y_continuous() and scale_fill_discrete(). This might work (untested as your example is not reproducible with a (dummy) dataset).

qplot(Age, data = recerts_combined_values, binwidth = 5, fill = combined_values$Test.Type, main="Combined Age Histogram") + scale_x_continuous("Age, months") + scale_y_continuous("Counts") + scale_fill_discrete("Type of Tests")



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
tel. + 32 54/436 185
Thierry.Onkelinx op inbo.be 

To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

-----Oorspronkelijk bericht-----
Van: r-help-bounces op r-project.org [mailto:r-help-bounces op r-project.org] Namens Jason Rupert
Verzonden: dinsdag 6 januari 2009 16:00
Aan: r-help op r-project.org
Onderwerp: Re: [R] R Stacked Histogram

Great advice.  I did a quick read and came up with the following:
qplot(Age, data = recerts_combined_values, binwidth = 5,
         fill = combined_values$Test.Type, 
         ylab="Counts", xlab="Age, months", 
         main="Combined Age Histogram", 
         legend.name = "Type of Tests")

Unfortunatley, here is a description of the results:
(1) the "main" title font size by default is too large and is clipped by the image (guess I need to figure out how to fix this), 
(2) ylab appears to fail - it does not replace the default "count" label - what should I do to fix this?
(3) like (2), neither using "legend.name" nor "legend.title" appears to replace/change the name of the legend title/name.  
By any chance can you provide some advice for tackeling these items?  These are probably due to me being a noobie on the ggplot2 package.  
Thanks again.

--- On Mon, 1/5/09, hadley wickham <h.wickham op gmail.com> wrote:

From: hadley wickham <h.wickham op gmail.com>
Subject: Re: [R] R Stacked Histogram
To: jasonkrupert op yahoo.com
Cc: r-help op r-project.org
Date: Monday, January 5, 2009, 7:42 AM

On Sun, Jan 4, 2009 at 6:51 PM, Jason Rupert <jasonkrupert op yahoo.com>
> Understood.  Will head the warning about odd way to display data.
> Any recommendations about where I look to find full details about
> I tried ?qplot, but it did not return full details.
> That description was missing a few items, e.g. fill, which is used below.

The best place to start is the qplot chapter of the ggplot2 book -




	[[alternative HTML version deleted]]

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

More information about the R-help mailing list