Shading
You can control five aspects of the shading: the density of the lines, the angle of the shading, the border of the shaded region, the colour of the lines and the line type. Here are their default values:
density = NULL angle = 45
border = NULL col=NA lty = par("lty"), ...)
Other graphical parameters such as xpd, lend, ljoin and lmitre (Table 27.1) can be given as arguments.
The following data come from a long-term study of the botanical composition of a pasture, where the response variable is the dry mass of a grass species called Festuca rubra (FR), and the two explanatory variables are total hay biomass and soil pH:
data<-read.table("c:\\temp\\pgr.txt",header=T) attach(data) names(data) [1] "FR" "hay" "pH"
The idea is to draw polygons to represent the convex hulls for the abundance of Festuca in the space defined by hay biomass and soil pH. The polygon is to be red for Festuca > 5, green for Festuca > 10 and cross-hatched in blue for Festuca > 20. After all of the solid objects have been drawn, the data are to be overlaid as a scatterplot with pch = 16:
plot(hay,pH) x<-hay[FR>5] y<-pH[FR>5] polygon(x[chull(x,y)],y[chull(x,y)],col="red")

x<-hay[FR>10] y<-pH[FR>10] polygon(x[chull(x,y)],y[chull(x,y)],col="green") x<-hay[FR>20] y<-pH[FR>20] polygon(x[chull(x,y)],y[chull(x,y)],density=10,angle=90,col="blue") polygon(x[chull(x,y)],y[chull(x,y)],density=10,angle=0,col="blue") ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access