[R] Histogram plot help
David L Carlson
dcarlson at tamu.edu
Tue Dec 4 03:07:56 CET 2012
Does it work the way you want if you add prob=TRUE to the second and third
hist() commands and run do.call() before abline()?
----------------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of YAddo
> Sent: Monday, December 03, 2012 4:22 PM
> To: r-help at r-project.org
> Subject: [R] Histogram plot help
>
> Dear All:
>
> I plotted a histogram with Abline, clipping with color codes but i run
> into
> some problems. The "abline' does not show up at all, and when i
> request
> the 'prob=True' (to obtain the freqs), my clipped region colors the
> section
> of the graph instead of the plot only.
>
> Is there any way i can get the y-axis figures to be in whole numbers
> rather
> than decimals?
>
> Many thanks for your help.
> YA
>
> Here are the working codes i am tweaking.
>
> Everything worked fine before i trying adding stuffs (prob=T, etc).
>
>
> x <- rnorm(1000)
> hist(x, xlim=c(-4,4),ylab="Prevalence",prob=T,lwd=3,las=1)
> lines(density(x),col="black",lwd=2)
> usr <- par("usr")
> clip(usr[1], -2, usr[3], usr[4])
> hist(x, col = 'red', add = TRUE)
> clip(2, usr[2], usr[3], usr[4])
> hist(x, col = 'blue', add = TRUE)
> abline(v=c(-1),lty=1,lwd=3,col="black")
> do.call("clip", as.list(usr)) # reset to plot region
>
>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Histogram-
> plot-help-tp4651958.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
More information about the R-help
mailing list