我正在使用ggplot在渐变比例上映射一些数据,并且我想生成带有HUC边界和相应数据的美国地图。我知道如何用州来做到这一点,产生美国的图像,每个州都有不同的颜色,使用以下代码表示不同的值:
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()
下面是数据: States data
我想做同样的事情,但是要用HUC(分水岭边界)来做。有谁知道如何修改此代码来做到这一点?