Here's one way, cast to Spatial*Lines and control the object colours directly:
ct1 <- subset(ct, NAME %in% c("Azerbaijan", "Uzbekistan", "Tajikistan", "Turkmenistan", "Croatia")) plot(as(ct1, "SpatialLinesDataFrame"), col=seq_len(nrow(ct1)), lwd=3) You can get the source of these S4 methods like this: showMethods("plot") that tells you the base signature (x="SpatialPolygons", y="missing") (or SpatialLines), which can be found with findMethods("plot")[["SpatialPolygons#missing"]] which tells you the source is in the (unexported) function which ultimately traverses the objects to be plotted with lower level plotting functions: sp:::plot.SpatialPolygons Cheers, Mike. On Wed, Jul 2, 2014 at 1:54 PM, Spencer Graves <spencer.gra...@prodsyse.com> wrote: > How can one control the color of lines with > plot(SpatialPolygonsDataFrame)? > > > Adding lwd=9 to the arguments for plot produces black borders so > wide most of the red disappears: > > > map(xlim=c(10, 90), ylim=c(30, 60)) > library(raster) > ct <- getData("countries") > plot(subset(ct, NAME %in% c("Azerbaijan", "Uzbekistan", "Tajikistan", > "Turkmenistan", "Croatia")), > add=TRUE, col='red', lwd=9) > > > A related question is how can I see the plot function used here? > Methods dispatch does not take this to plot.default nor to > plot.SpatialPolygonsDataFrame, as it would with an S3 method. > > > Thanks, > Spencer > > > ######################### > Thanks to Gilles Leduc, Greg Snow, Thomas Adams, Barry Rowlingson, > and Michael Sumner for their replies. For the archives, in case someone > else might find this in the archives, I will record here two solutions to > my problem. > > > 1. Michael's reply was the simplest, especially since it worked > with "map" adding "add=TRUE" and "col" to the plot: > > map(xlim=c(10, 90), ylim=c(30, 60)) > library(raster) > ct <- getData("countries") > plot(subset(ct, NAME %in% c("Azerbaijan", "Uzbekistan", "Tajikistan", > "Turkmenistan", "Croatia")), > add=TRUE, col='red') > > > 2. Before I saw Michael's reply, I had solved the problem with much > greater effort: (1) I downloaded a zip file for each country from " > www.diva-gis.org/datadown", as suggested by Gilles. (2) Unzipping > produced folders with names like "..\TWN_adm" and files with names > beginning "TWN_adm0", "TWN_adm1", and "TWN_adm2" and extensions bdf, prj, > sbn, sbx, shp, and shx. I could then get what I wanted with code like the > following: > > > Taiwan0 <- readShapeSpatial("..\TWN_adm0") > map(xlim=c(100, 150), ylim=c(10, 30)) > plot(Taiwan0, add=TRUE, col='blue', lwd=3, fill=FALSE) > > > Again, thanks for the replies. > > > On 7/1/2014 4:38 PM, Michael Sumner wrote: > >> An example: >> >> library(raster) >> ct <- getData("countries") >> plot(subset(ct, NAME %in% c("Azerbaijan", "Uzbekistan", "Tajikistan", >> "Turkmenistan", "Croatia")) >> >> >> >> >> On Wed, Jul 2, 2014 at 9:09 AM, Michael Sumner <mdsum...@gmail.com> >> wrote: >> >> >>> On Wed, Jul 2, 2014 at 7:56 AM, Thomas Adams <tea...@gmail.com> wrote: >>> >>> Spencer, >>>> >>>> Maybe I'm not sure what you're asking but here >>>> http://www.gadm.org/version1 >>>> are current shapefiles by country. The highlighting (selection) canals >>>> be >>>> done in GRASS GIS, QGIS, GMT >>>> >>>> >>>> raster::getData can read this. See here http://www.gadm.org/ and >>> >>> library(raster) >>> ?getData >>> >>> >>> >>> >>> >>> >>> Tom >>>> >>>> >>>> On Tue, Jul 1, 2014 at 2:29 PM, Spencer Graves < >>>> spencer.gra...@prodsyse.com> >>>> wrote: >>>> >>>> What would you suggest I do to create a world map highlighting >>>>> Taiwan and post-Soviet states like Azerbaijan, Uzbekistan, Tajikistan, >>>>> Turkmenistan, and Croatia? >>>>> >>>>> >>>>> The region argument in maps::map won't recognize any of these, >>>>> and >>>>> my literature search identified hundreds of packages with some spatial >>>>> / >>>>> geographical / mapping content. >>>>> >>>>> >>>>> Thanks, >>>>> Spencer Graves >>>>> >>>>> _______________________________________________ >>>>> R-sig-Geo mailing list >>>>> R-sig-Geo@r-project.org >>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo >>>>> >>>>> >>>> -- >>>> Michael Sumner >>>> Software and Database Engineer >>>> Australian Antarctic Division >>>> Hobart, Australia >>>> e-mail: mdsum...@gmail.com >>>> >>> > _______________________________________________ > R-sig-Geo mailing list > R-sig-Geo@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > -- Michael Sumner Software and Database Engineer Australian Antarctic Division Hobart, Australia e-mail: mdsum...@gmail.com [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo