Skip to content

Instantly share code, notes, and snippets.

@runiq
Last active December 17, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save runiq/5620738 to your computer and use it in GitHub Desktop.
Save runiq/5620738 to your computer and use it in GitHub Desktop.
PGF backend callback bug
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
def on_draw(event):
print "on_draw!"
f = plt.figure()
f.canvas.mpl_connect('draw_event', on_draw)
ax = f.add_subplot(111)
ax.plot(xrange(10))
print "Save to img.png, fires on_draw():"
f.savefig('img.png')
print "Save to img.pgf, implicit switch to PGF backend, doesn't fire on_draw():"
f.savefig('img.pgf')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment