|
1 | 1 | """ |
| 2 | +============ |
| 3 | +Artist tests |
| 4 | +============ |
| 5 | +
|
2 | 6 | Test unit support with each of the matplotlib primitive artist types |
3 | 7 |
|
4 | 8 | The axes handles unit conversions and the artists keep a pointer to |
5 | 9 | their axes parent, so you must init the artists with the axes instance |
6 | 10 | if you want to initialize them with unit data, or else they will not |
7 | | -know how to convert the units to scalars |
| 11 | +know how to convert the units to scalars. |
8 | 12 | """ |
9 | 13 | import random |
10 | 14 | import matplotlib.lines as lines |
|
31 | 35 | ax.add_collection(lc) |
32 | 36 |
|
33 | 37 | # test a plain-ol-line |
34 | | -line = lines.Line2D([0*cm, 1.5*cm], [0*cm, 2.5*cm], lw=2, color='black', axes=ax) |
| 38 | +line = lines.Line2D( |
| 39 | + [0*cm, 1.5*cm], [0*cm, 2.5*cm], lw=2, color='black', axes=ax) |
35 | 40 | ax.add_line(line) |
36 | 41 |
|
37 | 42 | if 0: |
38 | 43 | # test a patch |
39 | 44 | # Not supported at present. |
40 | | - rect = patches.Rectangle((1*cm, 1*cm), width=5*cm, height=2*cm, alpha=0.2, axes=ax) |
| 45 | + rect = patches.Rectangle( |
| 46 | + (1*cm, 1*cm), width=5*cm, height=2*cm, alpha=0.2, axes=ax) |
41 | 47 | ax.add_patch(rect) |
42 | 48 |
|
43 | 49 |
|
|
46 | 52 |
|
47 | 53 | ax.set_xlim(-1*cm, 10*cm) |
48 | 54 | ax.set_ylim(-1*cm, 10*cm) |
49 | | -#ax.xaxis.set_units(inch) |
| 55 | +# ax.xaxis.set_units(inch) |
50 | 56 | ax.grid(True) |
51 | 57 | ax.set_title("Artists with units") |
52 | 58 | plt.show() |
0 commit comments