Hi All,
I am trying to create a choropleth map of US states based on variable named “area_percent” from data frame “soybn.area2”.
I got the basic version (plot enclosed) but would like to fine tune a bit and need members help in this regard. My data frame looks like this
> rbind(head(soybn.area2),tail(soybn.area2))
us.states X2010 X2011 X2012 area_percent
1 alabama 350 300 310 0.42
2 arizona NA NA NA NA
3 arkansas 3190 3330 3300 4.47
4 california NA NA NA NA
5 colorado NA NA NA NA
6 connecticut NA NA NA NA
58 virginia 560 560 590 0.80
59 south dakota 4200 4100 4300 5.82
60 tennessee 1450 1290 1240 1.68
61 texas 205 165 125 0.17
62 west virginia 20 20 19 0.03
63 wisconsin 1640 1610 1680 2.27
My code to create the basic plot is given below
> library(ggplot2)
> library(scales)
> library(maps)
> states = map_data('state')
> ggplot(soybn.area2, aes(map_id = us.states)) + geom_map(aes(fill = area_percent, colour = 'grey90'), map = states)+
expand_limits(x = states$long, y = states$lat)
Now I would like to fine tune the graph with following
a) change state border colour to “grey90” vs. red as it was appearing on plot.
b) change the fill colour of states whose “area_percent” value is “NA” to some light grey (vs. existing dark grey)
c) add text label to each state on chart with those of corresponding “us.states”
Many thanks for the help and inputs.
Best regards,
S.N.V. Krishna
Hi Allan,
I just returned from a holiday. Thanks for your inputs. I redraw chart using your code. It worked for na.value and text labels but setting the colour outside aes() seems did not work.
I guess the colour argument outside aes() in geom_map is being ignored. As in the statement (below) I changed setting the colour = ‘red’ instead of ‘grey90’, but there is no effect on plot.
….geom_map(aes(fill = area_percent), colour = 'grey90', map = states) +
Could you please check at your end,
Thanks and Regards,
S.N.V. Krishna
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: http://gist.github.com/270442
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2
Hi Allan,
I just returned from a holiday. Thanks for your inputs. I redraw chart using your code. It worked for na.value and text labels but setting the colour outside aes() seems did not work.
I guess the colour argument outside aes() in geom_map is being ignored. As in the statement (below) I changed setting the colour = ‘red’ instead of ‘grey90’, but there is no effect on plot.
….geom_map(aes(fill = area_percent), colour = 'grey90', map = states) +
Could you please check at your end,
Thanks and Regards,
S.N.V. Krishna
To unsubscribe: email ggplot2+unsubscribe@googlegroups.com
More options: http://groups.google.com/group/ggplot2