0

I'm using ggplot to map some data on a gradient scale and I want to produce a map of the US with HUC boundaries and corresponding data. I know how to do it with states, yielding an image of the US, with each state having a different color, representing a different value using this code:

data("fifty_states")
states <- read_csv("mapping - Sheet1-4.csv")

low_color='green' 
high_color="blue"
legend_title = 'Slope'
ggplot(states, aes(map_id = State)) + 
  geom_map(aes(fill = Sen_Slope_Color_10 ),color="#ffffff",size=.15, map = fifty_states) + 
  expand_limits(x = fifty_states$long, y = fifty_states$lat) +
  coord_map() +
  labs(x = "", y = "") +
  scale_x_continuous(breaks = NULL) + 
  scale_y_continuous(breaks = NULL) +
  scale_fill_continuous(low = low_color, high= high_color, guide = guide_colorbar(title = legend_title)) + # creates shading pattern
  theme(#legend.position = "bottom", 
    panel.background = element_blank()) + 
  fifty_states_inset_boxes()

Here is a look at the data: States data

I want to do the same thing, but doing it with HUC (watershed boundaries). Does anyone know how to modify this code to do that?

Leigh
  • 1
  • 1
  • 1
    Please share sample of your data using `dput()` (not `str` or `head` or picture/screenshot) so others can help. See more here https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example?rq=1 – Tung Aug 27 '18 at 01:52
  • Or at least links to the sources of the data where you downloaded from – Tung Aug 27 '18 at 01:53
  • I just added a picture of the data, and I have the same data for the HUCs as well. – Leigh Aug 27 '18 at 02:36
  • 1
    A picture of data is useless and doesn't do anything to let us reproduce your problem. Please read the post that Tung linked to: you should use `dput` to export your data (or a [MCVE] of your data) and paste the output into the question. If you don't post a reproducible example of your data, we can't help you and your question will be closed. – divibisan Aug 27 '18 at 19:10

0 Answers0