|
18 | 18 | '''
|
19 | 19 |
|
20 | 20 | import matplotlib.pyplot as plt
|
| 21 | +import matplotlib.transforms as mtrans |
| 22 | +import numpy as np |
| 23 | + |
21 | 24 | from matplotlib.transforms import offset_copy
|
22 |
| -import matplotlib.transforms as tns |
23 | 25 |
|
24 | 26 | xs = np.arange(7)
|
25 | 27 | ys = xs**2
|
|
31 | 33 | # we only need to make one transform. To get the
|
32 | 34 | # transform argument to offset_copy, we need to make the axes
|
33 | 35 | # first; the subplot command above is one way to do this.
|
34 |
| -trans_offset = tns.offset_copy(ax.transData, fig=fig, |
35 |
| - x=0.05, y=0.10, units='inches') |
| 36 | +trans_offset = mtrans.offset_copy(ax.transData, fig=fig, |
| 37 | + x=0.05, y=0.10, units='inches') |
36 | 38 |
|
37 | 39 | for x, y in zip(xs, ys):
|
38 | 40 | plt.plot((x,), (y,), 'ro')
|
|
42 | 44 | # offset_copy works for polar plots also.
|
43 | 45 | ax = plt.subplot(2, 1, 2, polar=True)
|
44 | 46 |
|
45 |
| -trans_offset = tns.offset_copy(ax.transData, fig=fig, y=6, units='dots') |
| 47 | +trans_offset = mtrans.offset_copy(ax.transData, fig=fig, y=6, units='dots') |
46 | 48 |
|
47 | 49 | for x, y in zip(xs, ys):
|
48 | 50 | plt.polar((x,), (y,), 'ro')
|
49 | 51 | plt.text(x, y, '%d, %d' % (int(x), int(y)),
|
50 |
| - transform=trans_offset, |
51 |
| - horizontalalignment='center', |
52 |
| - verticalalignment='bottom') |
| 52 | + transform=trans_offset, |
| 53 | + horizontalalignment='center', |
| 54 | + verticalalignment='bottom') |
53 | 55 |
|
54 | 56 | plt.show()
|
0 commit comments