Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mapping variable to hexagon size with geom_hex

Tags:

r

ggplot2

Does anyone know if its possible to map to hexagon size with ggplot? Size is listed as an argument in the geom_hex documentation, but there are no examples of size mapping in stat_hexbin, so this just seems to relate to bin size.

Take for example:

ggplot(economics, aes(x=uempmed, y=unemploy)) + geom_hex()

enter image description here

But looking for instance at population distribution (below) it might be useful to map binned mean population to hexagon size, but I've not found a formula for this (if one exists).

ggplot(economics, aes(x=uempmed, y=unemploy, col=pop)) + geom_point()

enter image description here

Any ideas?

like image 542
geotheory Avatar asked Nov 03 '22 21:11

geotheory


1 Answers

Apparently the official answer is that ggplot does not have functionality to map to hexagon area. But as you can see a workaround solution is possible, now posted in a gist at github.

enter image description here

like image 64
geotheory Avatar answered Nov 15 '22 05:11

geotheory