[R-sig-Geo] fix color scale

Lyndon Estes lestes at princeton.edu
Fri Oct 29 15:50:43 CEST 2010


Hi Peter,

I am not sure which plot function you are using, but I did something
similar where I plotted a series of maps for crop yields with a
constant scale for yield, using sp.plot. My data were in an attribute
table linked to a polygon, whereas yours are grids, but maybe
something in the following can be used?

  # Loop through columns of shapefile (eval.shp2) to plot: Yield from
various cultivars
  for (i in 4:13) {

   print(paste("Plotting column: ", i))  # Column counter

    # Establish scale limits and title vector
      scmax  <- round(max(eval.shp2 at data[, 4:12]) / 100, 0) * 100  #
Set max scale value
      scmin  <- round(min(eval.shp2 at data[, 4:12]) / 100, 0) * 100  #
Set min scale value
      byval  <- 25
      titlevec <- paste("district maize yields (kg/ha) 1981-99:
Cultivar", culnames[i - 3])

    # Spplot
    print(spplot(eval.shp2[-c(22,69),], z = i,
          sp.layout = list(sa.lst),
          col.regions = topo.colors(500),
          at = seq(scmin, scmax, by = byval), main = titlevec))
  }

In your case, since you are using grids, maybe you can read the
interpolated grids' metadata first to extract the max and min and
values for setting your scale.  Or perhaps you know in advance what
the max and min should be, and can simply enter those values?

Hope this is somewhat useful.

Cheers, Lyndon




On Thu, Oct 28, 2010 at 3:12 PM, Peter Larson <pslarson2 at gmail.com> wrote:
> Hello!
>
> I have a problem.
>
> I am using IDW to interpolate a daily series of geospatial
> observations. Thus, I want to produce a large number of sequential
> maps.
>
> I want them to all represent the same color scale. Is there any way to
> fix the color scale so that it is the same for all the plots?
>
> Thanks,
>
> Pete
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



-- 
Lyndon Estes
Research Associate
Woodrow Wilson School
Princeton University
+1-609-258-2392 (o)
+1-609-258-6082 (f)
+1-202-431-0496 (m)
lestes at princeton.edu



More information about the R-sig-Geo mailing list