Skip to content

Instantly share code, notes, and snippets.

@tslumley
Created April 21, 2016 05:59
Show Gist options
  • Save tslumley/901f39025e72939bbbe0c1b35c4621b9 to your computer and use it in GitHub Desktop.
Save tslumley/901f39025e72939bbbe0c1b35c4621b9 to your computer and use it in GitHub Desktop.
Hexmaps for Australian electorates, by state
hexmap<-function(x,y,id,...){
xcent<-x*sqrt(3) - (y%%2) *sqrt(3)/2
ycent<-y*1.5
plot(x,y,type="n",ylim=range(ycent)+c(-2,2),xlim=range(xcent)+c(-2,2))
for(i in 1:length(x)){
polygon(hex_x+xcent[i],hex_y+ycent[i])
text(xcent[i],ycent[i],id[i],cex=0.4)
}
}
x y electorate
0 0 "Melbourne Ports"
0 1 "Melbourne"
1 0 "Higgins"
-1 0 "Gellibrand"
1 -1 "Goldstein"
2 -1 "Hotham"
1 1 "Kooyong"
2 1 "Deakin"
3 1 "Menzies"
2 0 "Chisolm"
3 -1 "Bruce"
3 0 "Aston"
3 -2 "Isaccs"
4 -1 "Holt"
4 -3 "Dunkley"
-1 2 "Maribyrnong"
0 2 "Wills"
1 2 "Batman"
2 2 "Jagajaga"
2 3 "Scullin"
4 0 "La Trobe"
5 1 "Casey"
-2 2 "Gorton"
-1 3 "Calwell"
-1 1 "Lalor"
-2 3 "Ballarat"
-1 -1 "Corio"
-2 -2 "Corangamite"
3 -4 "Flinders"
5 -1 "McMillan"
2 4 "McEwen"
-2 4 "Bendigo"
-2 1 "Wannon"
-3 3 "Mallee"
1 4 "Murray"
6 1 "Indi"
6 -1 "Gippsland"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment