I would like to plot some different data items using ggplot2, using two different colour scales (one continuous and one discrete from two different df\'s). I can plot either exa
I don't have the time at the moment to provide a complete working example, but there's another way to do this that deserves to be mentioned here: Fill and border colour in geom_point (scale_colour_manual) in ggplot
Basically, using geom_point in conjunction with shape = 21, color = NA
allows you to control the color of a series of points using the fill
rather than color
aesthetic. Here's what my code looked like for this. I understand that there's no data provided, but hopefully it provides you with a starting point:
biloxi +
geom_point(data = filter(train, primary != 'na'),
aes(y = GEO_LATITUDE, x = GEO_LONGITUDE, fill = primary),
shape = 21, color = NA, size = 1) +
scale_fill_manual(values = c('dodgerblue', 'firebrick')) +
geom_point(data = test_map_frame,
aes(y = GEO_LATITUDE, x = GEO_LONGITUDE, color = var_score),
alpha = 1, size = 1) +
scale_color_gradient2(low = 'dodgerblue4', high = 'firebrick4', mid = 'white',
midpoint = mean(test_map_frame$var_score))
Notice how each call to geom_point invokes a different aesthetic (color
or fill
)