[R-sig-Geo] Variable point size with spplot
Edzer Pebesma
edzer.pebesma at uni-muenster.de
Mon Mar 26 14:04:18 CEST 2012
On 03/26/2012 01:10 PM, piero campa wrote:
> Dear list,
> I used to plot points of variable size with "spplot" this way:
>
> library(RColorBrewer)
> data(meuse)
> coordinates(meuse) <- ~x+y
> spplot(meuse, zcol="om",
> col.regions=colorRampPalette(brewer.pal(7, "PuBu")[-(1:1)])(20),
> scales=list(draw=TRUE),
> cex=.4*(1:5)
> )
>
> but now, after R upgrade, this is not working properly anymore.
> As you can see from the attached image, colors are not well linked to points
> size.
>
> Any hint?
Please read this thread to understand the change:
https://stat.ethz.ch/pipermail/r-sig-geo/2012-March/014399.html
cx = (meuse$om/max(meuse$om,na.rm=T)) * 5
spplot(meuse, zcol="om",col.regions=colorRampPalette(brewer.pal(7,
"PuBu")[-(1:1)])(20),scales=list(draw=TRUE), cex=.4 * cx)
seems to give you the right bubble sizes, but not the right sizes in the
legend.
I added an argument to spplot (committed in svn), called key.cex so that
in the above call cex.key=1:5 would give sizes 1:5 in the legend. The
responsibility to match key size in plot and legend then lies with the
user, this is no longer automatic. This is a bit of a hack, but the
automatic solution needs a bit more thinking. Note that in the old
behaviour, you had 5 bubble sizes, in the example above you have
continuously varying bubble size.
>
> -Piero
>
> --
> View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Variable-point-size-with-spplot-tp7405527p7405527.html
> Sent from the R-sig-geo mailing list archive at Nabble.com.
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
--
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763 http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics e.pebesma at wwu.de
More information about the R-sig-Geo
mailing list