[S] Summary: Creating shaded polygons

Jean Adams (Jean_Adams@usgs.gov)
Fri, 1 May 1998 17:48:48 -0600



Thanks to Patrick J. Sullivan, Anne E. York, Jens Oehlschlaegel, Brian
D. Ripley for taking the time to respond to my question. Brian
Ripley's reply, pasted here, gave me all the information I needed to
get the job done.

-----
On a graphsheet the image colours always start at 17. How many there
are is set by image.color.style and the related command-line options.
Setting image.color.style="Trellis black and white" (check the help
page for the precise form) gives 100 equally-spaced greys. To see what
you have, try the following (extracted from show.settings, itself
omitted from some versions of 4.0)

plot(c(1, 100), c(0, 1), type = "n", axes = F, xlab = "", ylab = "")
panel.histogram(1:100, rep(1, 100), col = 17:116, border = F)

This will show the first 100 polygon colours, repeating if there are
fewer.
-----

With this information, I was able to reproduce my example with gray
scale shading (instead of density lines).

reg1 <- list(x=c(1, 4, 3, 1), y=c(1, 4, 5, 5))
reg2 <- list(x=c(1, 3, 3), y=c(1, 1, 3))
reg3 <- list(x=c(3, 5, 5, 3, 4, 3), y=c(1, 1, 5, 5, 4, 3))
val <- c(20, 50, 5) # assume this is on a scale of 1 to 100
graphsheet(image.color.scheme="trellis black on white")
plot(1:5, 1:5, type="n", axes=F, xlab="", ylab="")
polygon(reg1, col=116-val[1])
polygon(reg2, col=116-val[2])
polygon(reg3, col=116-val[3])

Thanks again for the help.

JVA


Jean V. Adams USGS Biological Resources Division
e-mail: jean_adams@usgs.gov Great Lakes Science Center
phone: (734) 214-9307 1451 Green Road
FAX: 734-994-8780 Ann Arbor, MI 48105-2899 USA

______________________________ Reply Separator _________________________________
Subject: [S] Creating shaded polygons
Author: <jean_adams@brd.usgs.gov>
Date: 04/30/98 11:09 AM

I would like to create several figures containing polygons in which
the level of shading used for each polygon's fill is set according to
the value of another variable. But I don't know how to use the range
of shades available for, say, an image() plot in a call to polygon().

Here is a much simplified example of what I want to do, using
different densities of "shading lines" instead of the gray scale (or
whatever color) shades that I would prefer.

reg1 <- list(x=c(1, 4, 3, 1), y=c(1, 4, 5, 5))
reg2 <- list(x=c(1, 3, 3), y=c(1, 1, 3))
reg3 <- list(x=c(3, 5, 5, 3, 4, 3), y=c(1, 1, 5, 5, 4, 3))
val <- c(20, 50, 5)
graphsheet()
plot(1:5, 1:5, type="n", axes=F, xlab="", ylab="")
polygon(reg1, density=val[1])
polygon(reg2, density=val[2])
polygon(reg3, density=val[3])

If you have any suggestions, please send them to me and I will
summarize for the group. Thanks for your help.

JVA
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news