[R-sig-Geo] Issue when producing bubble plot (sp)

Edzer Pebesma edzer.pebesma at uni-muenster.de
Mon May 27 16:38:28 CEST 2013



On 05/27/2013 03:06 PM, Thiago V. dos Santos wrote:
>  Dear R-siggers,
> 
> I'm trying to produce a bubble plot using the sp package. The plot is ok, but there are two issues I would like to improve. To see them, please reproduce the code below:
> 
> ----------------------------------------
> 
> require(sp)
> require(rgdal)
> 
> # Read PR shapefile
> download.file('https://dl.dropboxusercontent.com/u/27700634/PR.zip', 'PR.zip')
> unzip('PR.zip')
> pr <- readOGR('.', 'PR')
> 
> # Read plot data
> dcoef <- read.csv('https://dl.dropboxusercontent.com/u/27700634/data.csv',sep=';', header=T)
> 
> coordinates(dcoef) <- c('Longitude','Latitude')
> 
> # Coerce the polygon outlines to a SpatialLines object 
> spl <- list('sp.lines', as(pr, 'SpatialLines'))
> 
> # basic bubble plot
> bubble(dcoef, 'pvalue', main = 'P-values', key.entries = seq(0.2, 1, by=0.2), sp.layout=spl)
> ----------------------------------------
> 
> Here is the first issue: how can I "zoom out" the plot to show the entire shapefile contour, and not focus only on the dots domain?
> 

bb = bbox(pr)
bubble(dcoef, 'pvalue', main = 'P-values', key.entries = seq(0.2, 1,
by=0.2), sp.layout=spl, xlim = bb[1,], ylim = bb[2,])


> Now, going ahead with the code:
> 
> ----------------------------------------
> 
> # More sophisticated plot
> rv = list('sp.polygons', pr, fill = 'lightgrey') # 
> arrow = list('SpatialPolygonsRescale', 
>              layout.north.arrow(), 
>              offset=c(-51, -24), 
>              scale = 0.5, which = 2)
> 
> bubble(dcoef, 'pvalue',                   # data.frame and column to be plotted
>        main = 'P-values',                 # title
>        col='red',                         # color of bubbles
>        key.entries = seq(0.2, 1, by=0.2), # legend
>        scales=list(draw = TRUE),          # degrees in axes
>        sp.layout=list(rv, arrow))         # include additional items
> ----------------------------------------
> 
> 
> Here are two issues: 
> i) same as below: how can I show the entire shapefile contour, and not focus only on the dots domain?

same as above, I'd guess.

> 
> ii) why does the north arrow insist in not appearing?

remove the 'which = 2' when defining arrow -- this tells spplot to plot
the arrow in the second panel; your plot has only one.

> 
> Thanks in advance for any suggestion.
> 
> Greetings,
> --
> Thiago V. dos Santos
> PhD student
> Land and Atmospheric Science
> University of Minnesota
> http://www.laas.umn.edu/CurrentStudents/MeettheStudents/ThiagodosSantos/index.htm
> Phone: (612) 323 9898
> 	[[alternative HTML version deleted]]
> 
> 
> 
> _______________________________________________
> 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
83 33081, Fax: +49 251 8339763 http://ifgi.uni-muenster.de



More information about the R-sig-Geo mailing list