# [R] Using a constant scale across X-Y plots

Lisa lschwei at mac.com
Sun Dec 28 01:08:36 CET 2008

```I am working off an example from Deepayan Sarkar's
Lattice:Multivariate Data Visualiization with R. I am trying to create
Figure 5.6, essentially, but I would like to be able depict different
metro areas.  These of course  have different lat/longs, so I need to
make different graphs.  BUT (and this has been the tricky part), I
would like to produce graphics for each metropolitan region using the
same depth scale for all, so that dark gray means the same thing
consistently.

That's the part that is proving way too hard for my little brain and
limited R experience.

I'm assuming I don't have to include the quakes data to play around
with.

depth.col <- gray.colors(100)[cut(quakes\$depth, 100, label = FALSE)]

depth.ord <- rev(order(quakes\$depth))

depth.breaks <- do.breaks(range(quakes.ordered\$depth), 50)

quakes.ordered\$color <- level.colors(quakes.ordered\$depth, at =
depth.breaks, col.regions = gray.colors)

xyplot(lat ~ long | Magnitude, data = quakes.ordered, aspect = "iso",
groups = color, cex = 2, col = "black", panel = function(x, y,
groups, ..., subscripts) { fill <- groups[subscripts] panel.grid(h =
-1, v = -1) panel.xyplot(x, y, pch = 21, fill = fill, ...) }, legend =
list(right =
list(fun = draw.colorkey, args = list(key = list(col = gray.colors, at
= depth.breaks), draw = FALSE))), xlab = "Longitude", ylab = "Latitude")

Any ideas how how I might approach this?

Many thanks.
Lisa

```