Skip to content

Instantly share code, notes, and snippets.

@jimmyodonnell
Last active December 15, 2022 09:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jimmyodonnell/2976fcd130f20baeea36 to your computer and use it in GitHub Desktop.
Save jimmyodonnell/2976fcd130f20baeea36 to your computer and use it in GitHub Desktop.
Create sample plots from the population genetics software STRUCTURE
# sample structure plots
# to suppress axis ticks, use:
# xaxt = "n", yaxt = "n"
# no borders lty=0 or border=0
par(mfcol=c(4,2), mar=c(2,2,1,1), oma=c(2,4,2,2))
plot(0,1,type="n", ylim=c(0,1), xlim=c(0,100), xlab=NA, ylab=NA, yaxp = c(0, 1, 2))
rect(0,0,100,1, col="yellow", border=0)
plot(0,1,type="n", ylim=c(0,1), xlim=c(0,100), xlab=NA, ylab=NA, yaxp = c(0, 1, 2))
rect(0,0,50,1, col="yellow", border=0)
rect(50,0,100,1, col="dodgerblue", border=0)
plot(0,1,type="n", ylim=c(0,1), xlim=c(0,100), xlab=NA, ylab=NA, yaxp = c(0, 1, 2))
rect(0,0,33.3,1, col="yellow", border=0)
rect(33.3, 0, 66.6, 1, col="dodgerblue", border=0)
rect(66.6, 0, 100, 1, col="orange", border=0)
plot(0,1,type="n", ylim=c(0,1), xlim=c(0,100), xlab=NA, ylab=NA, yaxp = c(0, 1, 2))
rect(0, 0, 25, 1, col="yellow", border=0)
rect(25, 0, 50, 1, col="dodgerblue", border=0)
rect(50, 0, 75, 1, col="orange", border=0)
rect(75, 0, 100, 1, col="hotpink", border=0)
plot(0,1,type="n", ylim=c(0,1), xlim=c(0,100), xlab=NA, ylab=NA, yaxp = c(0, 1, 2))
rect(0,0,100,1, col="yellow", border=0)
plot(0,1,type="n", ylim=c(0,1), xlim=c(0,100), xlab=NA, ylab=NA, yaxp = c(0, 1, 2))
rect(0,0,100,0.5, col="yellow", border=0)
rect(0, 0.5, 100, 1, col="dodgerblue", border=0)
plot(0,1,type="n", ylim=c(0,1), xlim=c(0,100), xlab=NA, ylab=NA, yaxp = c(0, 1, 2))
rect(0, 0, 100, 0.333, col="yellow", border=0)
rect(0, 0.333, 100, 0.666, col="dodgerblue", border=0)
rect(0, 0.666, 100, 1, col="orange", border=0)
plot(0,1,type="n", ylim=c(0,1), xlim=c(0,100), xlab=NA, ylab=NA, yaxp = c(0, 1, 2))
rect(0, 0, 100, 0.25, col="yellow", border=0)
rect(0, 0.25, 100, 0.5, col="dodgerblue", border=0)
rect(0, 0.5, 100, 0.75, col="orange", border=0)
rect(0, 0.75, 100, 1, col="hotpink", border=0)
mtext(c("Low Gene Flow Among Clusters","High Gene Flow Among Clusters"), outer=TRUE, at=c(0.25,0.75))
mtext(c("K=4","K=3","K=2","K=1"), side=2, outer=TRUE, at=c(0.135,0.385,0.635,0.885), las=2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment