I tried following the answer at the following link without success. I should mention that I'm in an entry level Data Analysis Course, so my current R skills are limited. How to match vector values with colours from a colour ramp in R?.
Anyway, my issue is that I am working with a Rosling style bubble chart, and the colors are not ramping correctly. The graph depicts data on China's New Alliances and MIDS (militarized interstate disputes). Specifically, the circle size indicates the # of MIDS from 1-7. Because area can be difficult to discern I opted to also use color in order to better distinguish the # of MIDS, as the Legend Shows.
The legend correctly shows my color scheme, however, you may notice that circles of larger size are not deep red, as they should be, nor are all the smallest circles the lightest color. In fact, some small and some large circles are dark red, and the same is true for the light yellow. I have my code and other details below.
MY CODE:
library(RColorBrewer)
my.colors99 <-colorRampPalette(c("#ffffcc", "#fd8d3c", "#800026"))(8)
my.design <- my.colors99[ChnData$mids]
radius1 <- sqrt( ChnData$mids/pi )
symbols ( ChnData$year, ChnData$alliances,
circles= radius1, inches=.35,
xlab = "Year", ylab = "New Alliances",
main = "China's New Alliances (Circles = MIDS)",
ylim=nrow(ChnData$alliances),
xlim= nrow(ChnData$year),
bg = my.colors99)
legend("topleft",
legend=c("0", "1",
"2", "3",
"4", "5",
"6", "7"), title= "# of Mids",
col=my.colors99, pch=19, cex=1, box.col="grey60",
text.col="grey30")
Some Details on the colors
my.colors99 in R returns:
"#FFFFCC" "#FEDEA2" "#FDBD79" "#FD9D50"
"#EB7838" "#C75032" "#A3282C" "#800026"
ChnData$MIDS in R returns:
"#FFFFCC" "#FEDEA2" "#FFFFCC" "#FFFFCC" "#FFFFCC" "#FFFFCC" "#FFFFCC"
"#FFFFCC" "#FFFFCC" "#FEDEA2" "#FFFFCC" "#FFFFCC" "#FFFFCC" "#FFFFCC"
"#FFFFCC" "#FFFFCC" "#FDBD79" "#FFFFCC" "#FEDEA2" "#FFFFCC" "#FFFFCC"
"#FFFFCC" "#FFFFCC" "#FFFFCC" "#FFFFCC" "#FEDEA2" "#FEDEA2" "#FEDEA2"
"#FDBD79" "#FFFFCC" "#FD9D50" "#FFFFCC" "#FEDEA2" "#FFFFCC" "#FFFFCC"
"#FFFFCC" "#FD9D50" "#FFFFCC" "#FFFFCC" "#FFFFCC" "#FEDEA2" "#FFFFCC"
"#FDBD79" "#FFFFCC" "#FEDEA2" "#FFFFCC" "#FEDEA2" "#FFFFCC" "#FEDEA2"
"#FFFFCC" "#FDBD79" "#FD9D50" "#FEDEA2" "#FFFFCC" "#FD9D50" "#EB7838"
"#FDBD79" "#A3282C" "#FFFFCC" "#EB7838" "#EB7838" "#FDBD79" "#FDBD79"
"#C75032" "#FFFFCC" "#FD9D50" "#C75032" "#FD9D50" "#EB7838" "#FDBD79"
"#FD9D50" "#FFFFCC" "#FFFFCC" "#FEDEA2" "#FD9D50" "#FFFFCC" "#FFFFCC"
"#FFFFCC" "#FDBD79" "#FDBD79" "#FFFFCC" "#FFFFCC" "#FEDEA2" "#FEDEA2"
"#FFFFCC" "#FDBD79" "#FDBD79" "#FDBD79" "#FEDEA2" "#FFFFCC" "#FD9D50"
"#FD9D50" "#EB7838" "#FDBD79" "#FFFFCC" "#FEDEA2" "#FDBD79" "#EB7838"
"#FDBD79" "#EB7838" "#FEDEA2" "#FDBD79" "#FEDEA2" "#FDBD79" "#EB7838"
To me it seems that the color scheme is certainly off, as I of course want the smallest circles, which represent the lowest # of mids to correspond to the lightest color in the ramp palette, and to darken as the circle size increases. Hopefully I provided enough details, but will be glad to answer any questions if more details are needed. Thanks for the help!
circles small, color scheme correct with 1-mids but legend isnt