Last active
June 29, 2021 22:54
-
-
Save rafapereirabr/a9c6d144f213e71b4a1f6f22d665af9c to your computer and use it in GitHub Desktop.
Create rainbow color map of Brazil in R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(geobr) | |
library(ggplot2) | |
library(sf) | |
library(sfheaders) | |
df <- read_municipality(year=2018) | |
centrd <- st_centroid(df) | |
centrd <- sfheaders::sf_to_df(centrd, fill=T) | |
df$position <- centrd$y + centrd$x | |
ggplot() + | |
geom_sf(data=df, aes(fill=position), color=NA) + | |
scale_fill_gradientn(colours = rainbow(10)) + | |
theme_void() + | |
theme(legend.position = "none", | |
plot.title = element_markdown(color='#fe6700', size=7, hjust = 0.5), | |
plot.caption = element_markdown(color='gray70', size=4)) + | |
labs(title= '#PrideMonth', | |
caption='map by @UrbanDemog #geobr') | |
ggsave('pridemonth.png', dpi=300, width = 5, height=5, units='cm') | |
Author
rafapereirabr
commented
Jun 29, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment