1import matplotlib.pyplot as plt
2
3# set up a figure
4fig = plt.figure()
5ax = fig.add_subplot(111)
6x = np.arange(0, 10, 0.005)
7y = np.exp(-x/2.) * np.sin(2*np.pi*x)
8ax.plot(x,y)
9
10# what's one vertical unit & one horizontal unit in pixels?
11ax.transData.transform([(0,1),(1,0)])-ax.transData.transform((0,0))
12# Returns:
13# array([[ 0., 384.], <-- one y unit is 384 pixels (on my computer)
14# [ 496., 0.]]) <-- one x unit is 496 pixels.