R + ggplot2, multiple histograms in the same plot with each histogram normalised to unit area? -
Sorry for the novice R question ...
I have data. A single variable will be distributed separately to these measurements, depending on whether the thing is being done type A or Type B; That is, you can imagine that my column names are: measurement, type label (A or B) I want to plot the histogram of different measurements of A and B, and by inserting two histograms in the same plot, each Histogram unit is normalized in the field (this is because I hope the ratio of A and B is quite different). From unit area, I mean that A and B have unit area, not unit area in A + B. Actually, I want something like ground-density, but I do not want an easy distribution for everyone; I want to histogram times did not interleave, but plotted one over the other. Not stacked, though it would be interesting to know how to do this (The aim of this conspiracy is to find the difference between the sizes of the distribution which is a quantitative difference between A and B which can be used to differentiate between them. ) Two or more histograms - do not reinforce the plots with density - in the same plot with each common area unit. Thanks!
something like that?
Set # example .seed ( 1) df & lt; - data.fr (type = c (representative ("a", 1000), representative ("b", 4000)), value = c (rnorm (1000, mean = 25, sd = 10), rchisq (400015) )) # You start here ... library (ggplot2) ggplot (df, aes (x = value)) + geom_histogram (aes (y = .. density .., fill = type), color = "grey80" ) + Facet_grid (type ~.)
Note that many samples of type are four times more B
.
You can also set to float using the y-axis scales:
facet_grid (...)
.
Comments
Post a Comment