geom_dhb | R Documentation |
A ggplot2
geom for the District Health Board hexmap: geom_dhb
wraps geom_map
and geom_label_dhb
wraps geom_text
.
geom_dhb(mapping = NULL, data = NULL, stat="identity",..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE,coord=TRUE) geom_label_dhb(mapping = NULL, data = NULL, ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, short=FALSE) geom_dhbtri(mapping = NULL, data = NULL, stat="identity",..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE,coord=TRUE) geom_region(mapping = NULL, data = NULL, stat="identity",..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE,coord=TRUE) geom_label_region(mapping = NULL, data = NULL, ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE,short=FALSE) geom_regiontri(mapping = NULL, data = NULL,stat="identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE,coord=TRUE)
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. Usually inherited from the plot data |
stat |
The statistical transformation to use on the data for this layer, as a string. |
... |
Other arguments passed on to layer(), such as aesthetics, used to set an aesthetic to a fixed value, like |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends? |
inherit.aes |
If |
coord |
If |
short |
If |
The geoms
dhb_fixname
data(immune) summary(immune) immune$vax_pct<-cut(immune$Pcttotal,c(0,.80,.85,.90,.95,1)) ggplot(immune)+ geom_dhb(aes(fill=vax_pct,map_id=dhb_fixname(DHB)))+ scale_fill_viridis_d(drop=FALSE)+ geom_label_dhb(short=TRUE,colour="white") ## size variation, plus stacking to show the full-size hexes underneath, ## plus no labels ggplot(immune)+ geom_dhb(aes(map_id=dhb_fixname(DHB)),fill="white",colour="grey",coord=FALSE)+ geom_dhb(aes(fill=vax_pct,map_id=dhb_fixname(DHB),radius=sqrt(Ntotal)),alpha=0.5)+ scale_fill_viridis_d(drop=FALSE) data(immune_long) ggplot(immune_long) + geom_dhb(aes(map_id=dhb_fixname(DHB),fill=pct_vax), alpha=0.5,colour="lightgrey") + scale_fill_viridis_d(drop=FALSE)+ geom_label_dhb(short=TRUE,colour="black",cex=3)+ facet_wrap(~ethnicity) data(dhb_cars) tris<-tri_alloc(dhb_cars[,-1], c("0","1","2","3+"), names=dhb_cars$dhb ) tri_data<-data.frame(DHB=rep(rownames(tris),6), cars=as.vector(tris), tri_id=rep(1:6,each=nrow(tris))) ggplot(tri_data)+ geom_dhbtri(aes(map_id=DHB,class_id=tri_id, fill=cars),alpha=0.5)+ scale_fill_viridis_d()+ geom_label_dhb(short=TRUE) data(region_ethnicity) tri_eth<-tri_alloc(as.matrix(region_ethnicity[,-1]), classes=c("Asian","Euro","Maori","MELAA","Pacific"), names=region_ethnicity$Area) tri_data<-data.frame(Region=rep(rownames(tri_eth),6), ethnicity=as.vector(tri_eth), tri_id=rep(1:6,each=nrow(tri_eth))) ggplot(tri_data)+ geom_regiontri(aes(map_id=Region,class_id=tri_id, fill=ethnicity))+ geom_label_region(colour="Black", short=TRUE,cex=3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.