I have a simple shapefile I want to plot with the general plot() (I noticed that ggplot is extremely slow in plotting maps).
I can correctly plot the shape with the code
library(maptools)
map_shp <- readShapePoly(map_filepath)
map <- fortify(map_shp)
plot(map)
But how could I define the color and width of the lines?
If you aren't set on using ggplot2 for everything, you can sidestep fortify()
and just use the sp package's well-developed tools for plotting objects of class SpatialPolygons*
:
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)