I would like to add labels to geom_hex, which raises two questions:
minimal example:
pipeline <- read.csv(url('http://dl.dropboxusercontent.com/u/7446674/pipeline.csv'),sep="\t",header=T)
pipeline <- pipeline[pipeline$Units>0,]
ggplot(pipeline,aes(x=Longitude,y=Latitude))+
#stat_density2d(n=25,aes(fill=..level..), geom="polygon") +
geom_hex(bins=12)+
coord_equal(ratio = 1/1)+
theme_bw()+
ggtitle('San Francisco Development Pipeline\nQ2 2013')
(Also, on the geom_hex, if anyone knows if weighs have been implemented yet I would be interested in knowing that, too)
You can label each bin with its count using:
ggplot(pipeline,aes(x=Longitude,y=Latitude))+
geom_hex(bins=12)+
stat_binhex(aes(label=..count..), geom="text", bins=12, colour="white") +
coord_equal(ratio = 1/1)+
theme_bw()+
ggtitle('San Francisco Development Pipeline\nQ2 2013')
(PS: was it the counts you wanted as labels? It seemed that way, but I wasn't entirely sure)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With