|
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 |
|
34 | 38 | ax.add_collection(lc) |
35 | 39 |
|
36 | 40 | # test a plain-ol-line |
37 | | -line = lines.Line2D([0*cm, 1.5*cm], [0*cm, 2.5*cm], lw=2, color='black', axes=ax) |
| 41 | +line = lines.Line2D( |
| 42 | + [0*cm, 1.5*cm], [0*cm, 2.5*cm], lw=2, color='black', axes=ax) |
38 | 43 | ax.add_line(line) |
39 | 44 |
|
40 | 45 | if 0: |
41 | 46 | # test a patch |
42 | 47 | # Not supported at present. |
43 | | - rect = patches.Rectangle((1*cm, 1*cm), width=5*cm, height=2*cm, alpha=0.2, axes=ax) |
| 48 | + rect = patches.Rectangle( |
| 49 | + (1*cm, 1*cm), width=5*cm, height=2*cm, alpha=0.2, axes=ax) |
44 | 50 | ax.add_patch(rect) |
45 | 51 |
|
46 | 52 |
|
|
49 | 55 |
|
50 | 56 | ax.set_xlim(-1*cm, 10*cm) |
51 | 57 | ax.set_ylim(-1*cm, 10*cm) |
52 | | -#ax.xaxis.set_units(inch) |
| 58 | +# ax.xaxis.set_units(inch) |
53 | 59 | ax.grid(True) |
54 | 60 | ax.set_title("Artists with units") |
55 | 61 | plt.show() |
0 commit comments