Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
424 views
in Technique[技术] by (71.8m points)

r - Mapping variable to hexagon size with geom_hex

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...