[R] multiple graphs on one plot
drj|m|emon @end|ng |rom gm@||@com
Mon May 13 08:30:34 CEST 2019
First, a little mind reading. My crystal ball says that "cw" can be
interpreted as "carapace width". It didn't tell me the parameters of
the distribution, so:
multhist(mf, xlab="CW", ylab="Frequency", ylim=c(0,100),main="All Measured
Crabs", col=c("dark gray", "light gray"),
legend("topright", c("Females", "Males"), fill=c("dark gray", "light gray"))
This produces what I think you are after. Note that it may be
misleading as the distribution of carapace width in real mud crabs
doesn't look normal to me.
On Mon, May 13, 2019 at 3:00 PM Andrew Halford <andrew.halford using gmail.com> wrote:
> Hi Listers
> I've been trying to make a single graphic that has frequency histograms for
> male and female mud crabs displayed side by side (such as when using the
> beside=TRUE command for barplots). I then want to display a normal
> distribution on top of the male and female histograms.
> I have been using the multhist command in Plotrix to generate the
> histograms without too much problem, but I cannot get the normal
> distributions to plot up on the same graph.
> Histograms plot
> mf <-
> multhist(mf, xlab="CW", ylab="Frequency", ylim=c(0,100),main="All Measured
> Crabs", col=c("dark gray", "light gray"),
> breaks=seq(90,210, by=10),beside=TRUE,space=c(0,0.5))
> legend("topright", c("Females", "Males"), fill=c("dark gray", "light gray"))
> Then I try to add a normal distribution curve just to the female data but I
> cant get the output to plot
> points(seq(min(mf[]), max(mf[]), length.out=300),
> dnorm(seq(min(mf[]), max(mf[]), length.out=300),
> mean(mf[]), sd(mf[])),type="l", col="dark gray")
> Even trying to add an abline to the plot doesn't work.
> What am I missing?
> Andrew Halford Ph.D
> Senior Coastal Fisheries Scientist
> Pacific Community | Communauté du Pacifique CPS – B.P. D5 | 98848 Noumea,
> New Caledonia | Nouméa, Nouvelle-Calédonie
> [[alternative HTML version deleted]]
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help