Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add simultaneous plotting of counties and states #26

Closed
pdil opened this issue Oct 2, 2019 · 1 comment
Closed

Add simultaneous plotting of counties and states #26

pdil opened this issue Oct 2, 2019 · 1 comment
Assignees
Labels
new feature A new feature that adds functionality to the package wontfix A suggestion or bug report that has been rejected by the package maintainers
Milestone

Comments

@pdil
Copy link
Owner

pdil commented Oct 2, 2019

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 pdil added the enhancement A suggestion or feature that improves existing functionality label Oct 2, 2019
@pdil pdil added this to the v0.6.0 milestone Oct 2, 2019
@pdil pdil self-assigned this Oct 2, 2019
@pdil pdil pinned this issue Oct 2, 2019
@pdil pdil unpinned this issue Oct 8, 2020
@pdil pdil added needs refinement Features, enhancements, or bugs that require more refinement before they are ready to be worked on new feature A new feature that adds functionality to the package and removed enhancement A suggestion or feature that improves existing functionality labels Nov 6, 2020
@pdil pdil pinned this issue Nov 11, 2020
@pdil pdil removed this from the v0.6.0 milestone Feb 7, 2022
@pdil pdil unpinned this issue Feb 7, 2022
@pdil pdil added this to the v0.7.0 milestone Mar 3, 2022
@pdil pdil pinned this issue Mar 3, 2022
@pdil pdil added wontfix A suggestion or bug report that has been rejected by the package maintainers and removed needs refinement Features, enhancements, or bugs that require more refinement before they are ready to be worked on labels Jan 19, 2024
@pdil
Copy link
Owner Author

pdil commented Jan 19, 2024

The recommended way to do this as of usmap 0.7.0 is to manually add a geom_sf() layer:

counties <- us_map("counties")

plot_usmap(color = "red") + 
  ggplot2::geom_sf(data = counties, fill = NA)

@pdil pdil closed this as completed Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature A new feature that adds functionality to the package wontfix A suggestion or bug report that has been rejected by the package maintainers
Projects
None yet
Development

No branches or pull requests

1 participant