|
29 | 29 | norm = cm.colors.Normalize(vmax=abs(Z).max(), vmin=-abs(Z).max()) |
30 | 30 | cmap = cm.PRGn |
31 | 31 |
|
32 | | -plt.figure() |
| 32 | +fig = plt.figure() |
| 33 | +fig.subplots_adjust(hspace=0.3) |
33 | 34 |
|
34 | 35 |
|
35 | 36 | plt.subplot(2, 2, 1) |
|
46 | 47 | # contour separately; don't try to change the edgecolor or edgewidth |
47 | 48 | # of the polygons in the collections returned by contourf. |
48 | 49 | # Use levels output from previous call to guarantee they are the same. |
49 | | -cset2 = plt.contour(X, Y, Z, cset1.levels, |
50 | | - colors='k', |
51 | | - hold='on') |
| 50 | + |
| 51 | +cset2 = plt.contour(X, Y, Z, cset1.levels, colors='k') |
| 52 | + |
52 | 53 | # We don't really need dashed contour lines to indicate negative |
53 | 54 | # regions, so let's turn them off. |
| 55 | + |
54 | 56 | for c in cset2.collections: |
55 | 57 | c.set_linestyle('solid') |
56 | 58 |
|
57 | 59 | # It is easier here to make a separate call to contour than |
58 | 60 | # to set up an array of colors and linewidths. |
59 | 61 | # We are making a thick green line as a zero contour. |
60 | 62 | # Specify the zero level as a tuple with only 0 in it. |
61 | | -cset3 = plt.contour(X, Y, Z, (0,), |
62 | | - colors='g', |
63 | | - linewidths=2, |
64 | | - hold='on') |
| 63 | + |
| 64 | +cset3 = plt.contour(X, Y, Z, (0,), colors='g', linewidths=2) |
65 | 65 | plt.title('Filled contours') |
66 | 66 | plt.colorbar(cset1) |
67 | | -#hot() |
68 | 67 |
|
69 | 68 |
|
70 | 69 | plt.subplot(2, 2, 2) |
71 | 70 |
|
72 | 71 | plt.imshow(Z, extent=extent, cmap=cmap, norm=norm) |
73 | 72 | v = plt.axis() |
74 | | -plt.contour(Z, levels, hold='on', colors='k', |
75 | | - origin='upper', extent=extent) |
| 73 | +plt.contour(Z, levels, colors='k', origin='upper', extent=extent) |
76 | 74 | plt.axis(v) |
77 | 75 | plt.title("Image, origin 'upper'") |
78 | 76 |
|
79 | 77 | plt.subplot(2, 2, 3) |
80 | 78 |
|
81 | 79 | plt.imshow(Z, origin='lower', extent=extent, cmap=cmap, norm=norm) |
82 | 80 | v = plt.axis() |
83 | | -plt.contour(Z, levels, hold='on', colors='k', |
84 | | - origin='lower', extent=extent) |
| 81 | +plt.contour(Z, levels, colors='k', origin='lower', extent=extent) |
85 | 82 | plt.axis(v) |
86 | 83 | plt.title("Image, origin 'lower'") |
87 | 84 |
|
|
95 | 92 | # domain that is contoured does not extend beyond these pixel centers. |
96 | 93 | im = plt.imshow(Z, interpolation='nearest', extent=extent, cmap=cmap, norm=norm) |
97 | 94 | v = plt.axis() |
98 | | -plt.contour(Z, levels, hold='on', colors='k', |
99 | | - origin='image', extent=extent) |
| 95 | +plt.contour(Z, levels, colors='k', origin='image', extent=extent) |
100 | 96 | plt.axis(v) |
101 | 97 | ylim = plt.get(plt.gca(), 'ylim') |
102 | 98 | plt.setp(plt.gca(), ylim=ylim[::-1]) |
103 | | -plt.title("Image, origin from rc, reversed y-axis") |
| 99 | +plt.title("Origin from rc, reversed y-axis") |
104 | 100 | plt.colorbar(im) |
105 | 101 |
|
106 | 102 | plt.show() |
0 commit comments