[R-sig-teaching] Shading Area

Steven Stoline sstoline at gmail.com
Wed Nov 25 18:47:42 CET 2015


Dear Robin:

it works

with many thanks
steve


On Wed, Nov 25, 2015 at 12:44 PM, Donatello, Robin <rdonatello at csuchico.edu>
wrote:

> Use the polygon() function where x and y are the vertices of the area you
> want shaded.
>
> polygon(x=c(0,10,10,0),c(3,3,7,7),col=adjustcolor("gray", alpha.f=.5))
> polygon(x=c(5,7,7,5),c(0,0,10,10),col=adjustcolor("blue", alpha.f=.5))
>
>
> Robin Donatello, DrPH
> Assistant Professor
> Department of Mathematics and Statistics
> California State University Chico
> Holt 216
> 530-898-5767
> rdonatello at csuchico.edu
> www.norcalbiostat.com
>
> ________________________________________
> From: R-sig-teaching <r-sig-teaching-bounces at r-project.org> on behalf of
> Steven Stoline <sstoline at gmail.com>
> Sent: Wednesday, November 25, 2015 9:34 AM
> To: R-sig-teaching
> Subject: [R-sig-teaching] Shading Area
>
> Dear All:
>
>
> How to shade the area between the lines  y = 3 and y = 7 (with gray color
> (say),  and between the lines x = 5 and x = 7? with color light blue (say).
>
>
>
> *here is the R code:*
> ====================
>
>
>
> plot(0:10, 0:10, type = "n", xaxt = "n", yaxs = "i", xaxs = "i", yaxt =
> "n", xlab = "", ylab = "")
>
>
> text(10.15, 0, "x", pos = 4, xpd = NA, cex = 1.25)
>
> text(0, 11.00, "y", pos = 1.85, xpd = NA, cex = 1.25)
>
>
>
> abline(h=3.0, col="red", lwd=1.5)
> abline(h=7, col="red", lwd=1.5)
>
>
> abline(v=5.0, col="gray", lwd=2.0)
> abline(v=7, col="gray", lwd=2.0)
>
>
> segments(0,5, 6,5, lty=2, lwd=2.0)
> segments(6,0, 6,5, lty=2, lwd=2.0)
>
>
> with thanks
> steve
>
> -------------------------
> Steven M. Stoline
> 1123 Forest Avenue
> Portland, ME 04112
> sstoline at gmail.com
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-teaching at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-teaching
>



-- 
Steven M. Stoline
1123 Forest Avenue
Portland, ME 04112
sstoline at gmail.com

	[[alternative HTML version deleted]]



More information about the R-sig-teaching mailing list