How to set the line width and color when building a shapefile using a graph ()

I have a simple shapefile that I want to build with a common plot () (I noticed that ggplot is very slow when building maps).

I can correctly build a figure with code

library(maptools) map_shp <- readShapePoly(map_filepath) map <- fortify(map_shp) plot(map) 

But how can I determine the color and width of the lines?

+8
r maps plot shapefile
source share
1 answer

If you don't use ggplot2 for everything, you can get around fortify() and just use the sp package, well-designed tools for building objects of the SpatialPolygons* class:

 library(rgdal) # For readOGR(), generally preferable to readShapePoly() IMHO library(spdep) # For the "columbus.shp" file that ships with the package map <- readOGR(dsn = system.file("etc/shapes", package="spdep"), layer = "columbus") plot(map, border="red", lwd=3) 

enter image description here

+14
source share

All Articles