[R] Histogram color
Greg Snow
Greg.Snow at imail.org
Thu Mar 4 21:14:02 CET 2010
Here is another approach:
x <- rnorm(100)
tmp <- hist(x, plot=FALSE)
plot(tmp, col='blue')
tu <- par('usr')
par(xpd=FALSE)
clip( tu[1], mean(x) - sd(x), tu[3], tu[4] )
plot(tmp, col='red', add=TRUE)
clip( mean(x) + sd(x), tu[2], tu[3], tu[4] )
plot(tmp, col='red', add=TRUE)
--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Ashta
> Sent: Thursday, March 04, 2010 5:42 AM
> To: R help
> Subject: [R] Histogram color
>
> In a histogram , is it possible to have different colors?
> Example. I generated
>
> x <- rnorm(1000000)
> hist(x)
>
> I want the histogram to have different colors based on the following
> condition
> mean(x)+sd(x) with red color and mean(x) - sd(x) with red color as
> well. The middle one with blue color.
> Is it possible to do that in R?
> Thanks
>
> ______________________________________________
> 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