usmap icon indicating copy to clipboard operation
usmap copied to clipboard

Add simultaneous plotting of counties and states

Open pdil opened this issue 6 years ago • 0 comments

Is your feature request related to a problem? Please describe. There should be a way to plot both states and counties simultaneously. For example, plotting Alaska as a state with several Alaskan counties also outlined within them (possibly with different aesthetic features).

Describe the solution you'd like This needs more thought but perhaps a boolean parameter to plot_usmap indicating that the include/exclude parameters that are states should be plotted as states and counties should be plotted as counties (instead of just following what is defined in the regions parameter).

Describe alternatives you've considered Currently, the only way to achieve something like this is to create two separate plot_usmap objects (one for the states and one for counties) and then combine them by extracting the $layers[[1]] object from the plot_usmap object which is both not ideal and could be unreliable if ggplot2 behavior were to be changed in a future update.

For example:

library(usmap)
library(ggplot2)

states <- plot_usmap("states", include = "CA")
counties <- plot_usmap("counties", include = "06073", color = "red")

ggplot() +
  states$layers[[1]] +
  counties$layers[[1]] +
  counties$theme +
  coord_equal()

pdil avatar Oct 02 '19 18:10 pdil