Skip to content

Instantly share code, notes, and snippets.

@pmagwene
Created March 7, 2012 05:08
Show Gist options
  • Save pmagwene/1991040 to your computer and use it in GitHub Desktop.
Save pmagwene/1991040 to your computer and use it in GitHub Desktop.
crude dotplot in matplotlib
# assumes pyplot and numpy are in namespace
import string
x = [1,4,5,9,9,11,13,14,18,20]
cats = [i for i in string.letters[:10]]
maxx = max(x)*1.10
ax = axes([0,0,1,1])
xlim(0,maxx)
ylim(0,11)
ticks = ax.yaxis.set_ticks(range(1,11))
text = ax.yaxis.set_ticklabels(cats)
for ct,item in enumerate(cats):
hlines(ct+1, 0, maxx, linestyle='dashed',color='0.9')
plot(x, range(1,len(cats)+1), 'ko')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment