fig = plt.figure()
ax = fig.add_subplot(111)
x = np.arange(0, 10, 0.005)
y = np.exp(-x / 2.0) * np.sin(2 * np.pi * x)
ax.plot(x, y)
ax.transData.transform([(0, 1), (1, 0)]) - ax.transData.transform((0, 0))
How can I get the length of a single unit on an axis in matplotlib, in pixels?