Skip to content
Prev 273296 / 398506 Next

Plotting a polygon with xyplot

markm0705 <markm0705 <at> gmail.com> writes:
Before you try this with lattice, you might spend some time
getting your abscissa values in an order that will plot the
contour in a sequential fashion.  It's not obvious how to
do this a priori.  Here is a simple-minded attempt after looking
at your graphic, just using base graphics.  Maybe, it will
be sufficient for you to tweak it a bit further for what you
want.

Data_poly<- 
read.table("http://r.789695.n4.nabble.com/file/n3870788/111004_Lode_Outlines.csv",
header = TRUE,sep = ",",)
par(mfrow = c(1, 2), pty = "s")
plot(z ~ y, Data_poly, type = "l")

fh <- with(Data_poly, which(z > 240))
D_poly <- rbind(Data_poly[fh, ], Data_poly[-rev(fh), ])
D_poly <- rbind(D_poly, Data_poly[1, ])

plot(z ~ y, D_poly, type = "n")
with(D_poly, polygon(y, z, col = "lightblue"))