Skip to content

Instantly share code, notes, and snippets.

@rafapereirabr
Last active June 29, 2021 22:54
Show Gist options
  • Save rafapereirabr/a9c6d144f213e71b4a1f6f22d665af9c to your computer and use it in GitHub Desktop.
Save rafapereirabr/a9c6d144f213e71b4a1f6f22d665af9c to your computer and use it in GitHub Desktop.
Create rainbow color map of Brazil in R
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')
@rafapereirabr
Copy link
Author

pridemonth

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment