Modify color in pie charts on a geographical map
1
0
Entering edit mode
16 months ago

Hi, I have generated the pie charts on a geographical map using ggplot following the tutorial (https://towardsdatascience.com/using-ggplot-to-plot-pie-charts-on-a-geographical-map-bb54d22d6e13),

# Using map_data()
worldmap <- map_data ("world")
colours_group = c("#EE2700", "#5EFF01","#94569d", "#3404FE","#FBFF00", "#F200FE", "#6AFDFF", "#F29A03","#7F415C", "#F3985D")
mapplot1 <- ggplot(worldmap) +
  geom_map(data = worldmap, map = worldmap, aes(x=long, y=lat, map_id=region), color = "black", fill = NA) +
  geom_scatterpie(aes(x=longitude, y=latitude, group = Countries, r = multiplier*6),
                  data = final_data, cols = colnames(final_data[,c(2:11)])) + 
  scale_fill_manual("vunrisk", values = colours_group)

mapplot1 + theme(axis.title.x = element_blank(), axis.title.y = element_blank(), axis.text.x =element_blank(), axis.ticks.x = element_blank(), axis.text.y = element_blank(), axis.ticks.y = element_blank(), panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
                 panel.background = element_blank(), axis.line = element_blank())

I am trying to replace the default colours with the following colours but its not working:

colours = c("#EE2700", "#5EFF01","#94569d", "#3404FE","#FBFF00", "#F200FE", "#6AFDFF", "#F29A03","#7F415C", "#F3985D")
ggplot • 856 views
ADD COMMENT
0
Entering edit mode
16 months ago

I have designed the solution. I have specified the lists of colors:

colours_group = c("#EE2700", "#5EFF01","#94569d", "#3404FE","#FBFF00", "#F200FE", "#6AFDFF", "#F29A03","#7F415C", "#F3985D")

and then I added replaced the default colors using:

scale_fill_manual("vunrisk", values = colours_group)

I have incorporated the solution the question

ADD COMMENT

Login before adding your answer.

Traffic: 2342 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6