Prolbem changing the color of a map in ggplot2

Hello everyone. I have the following code. It plots the shape of some countries. As can be seen, I want to use the palette Bluges to have the countries in the same colors.

library(maps)
library(ggplot2)
library(dplyr)
library(RColorBrewer)




p=c("Brazil", "Argentina", "Chile", "Uruguay", "Paraguay", "Ecuador", "Peru", "Venezuela",
    "Colombia", "Bolivia", "French Guiana", "Surinam", "Guyana")

mp<-map_data("world", region=p) 

mlola <- mp %>%  group_by(region) %>% 
  summarize(mlo= mean(long), mla=mean(lat))


ggplot(mp,aes( x= long, y = lat, group=group, fill=region)) +
  geom_polygon(aes(color="Bluges"))+
  theme(panel.background = element_rect(fill=NA))

However, if I execute the code, geom_polygon(aes(color="Bluges"))+ has no effect at all on the resulting plot.
Can someone please tell me how to change this to have all the countries in different shades of blue?

Best regards.

Something like this?

myPalette = colorRampPalette(brewer.pal(n=20, "Blues"))

ggplot(mp,aes( x= long, y = lat, group=group, fill=region)) +
  geom_polygon()+
  theme(panel.background = element_rect(fill=NA)) +
  scale_fill_manual(values = myPalette(13))

Yes, that's it.

Thanks

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.