I have a list of cities and their coordinates, and also for each city I have a variable varA which I want to represent in a map using ggplot and bubble chart. For example :
CityA lat 22.93977 lon 46.70663 varA 545
CityB lat 23.93977 lon 46.70663 varA 122
VarA values begin from 0 to 3000. I want the color scale to represent this range appropriately. Can you help?
A bubble chart in ggplot2
is actually a point plot (geom_point
), where the size
aesthetic is assigned to a (continuous) variable. The following example shows a bubble chart as you described for the meuse
dataset (part of the sp
package). It shows heavy metal concentrations close to the river meuse in the Netherlands.
library(sp)
data(meuse)
library(ggplot2)
theme_set(theme_bw())
ggplot(meuse, aes(x = x, y = y, size = zinc)) + geom_point()