'How can I change the color of a single ggplot layer?
I need to change the white part of this ggplot to color = 'red', fill='red', alpha=0.1 without changing the colors of the other 2 layers in the plot. I want to see the base layer under the white area. I have tried several variations of aes(color = 'red', fill='red', alpha=0.1) inside and outside of the geom_sf(). I have also moved new_scale_color() to different places in the code. How can this be accomplished?
#####################################################
#create ggplot object combing NAIP, treat, and home ranges
HR_ani <- NAIPgg + geom_sf(data=treatment, aes(color = 'red', fill='red', alpha=0.1)) + new_scale_color() +
geom_sf(data = (deer1),aes(color = Id, fill = Id, alpha = Id)) +
scale_alpha_manual(values = c(0.8, 0.4)) + #manually set the alpha values for each indiv
scale_color_manual(values = viridis(3)[1:10]) + #manually set the colours for each individual
scale_fill_manual(values = viridis(2)[1:10]) + #manually set the colours for each individual
theme(legend.position="none", panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
axis.text.x = element_blank(), axis.text.y = element_blank()) +
transition_states(YearMonth, wrap=T, transition_length = 0, state_length = .5) + labs(title = "YearMonth: {closest_state}", size=50)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

