|
30 | 30 |
|
31 | 31 | subplot(2,2,1)
|
32 | 32 |
|
33 |
| -levs1, colls = contourf(X, Y, Z, levels, |
| 33 | +cset1 = contourf(X, Y, Z, levels, |
34 | 34 | cmap=cm.jet,
|
35 | 35 | )
|
36 | 36 | #If we want lines as well as filled regions, we need to call
|
37 | 37 | # contour separately; don't try to change the edgecolor or edgewidth
|
38 | 38 | # of the polygons in the collections returned by contourf.
|
39 | 39 | # Use levels output from previous call to guarantee they are the same.
|
40 |
| -levs2, colls2 = contour(X, Y, Z, levs1, |
| 40 | +cset2 = contour(X, Y, Z, cset1.levels, |
41 | 41 | colors = 'k',
|
42 | 42 | hold='on')
|
43 | 43 | # We don't really need dashed contour lines to indicate negative
|
44 | 44 | # regions, so let's turn them off.
|
45 |
| -for c in colls2: |
| 45 | +for c in cset2.collections: |
46 | 46 | c.set_linestyle('solid')
|
47 | 47 |
|
48 | 48 | # It is easier here to make a separate call to contour than
|
49 | 49 | # to set up an array of colors and linewidths.
|
50 | 50 | # We are making a thick green line as a zero contour.
|
51 | 51 | # Specify the zero level as a tuple with only 0 in it.
|
52 |
| -levs3, colls3 = contour(X, Y, Z, (0,), |
53 |
| - colors = 'g', |
54 |
| - linewidths = 2, |
55 |
| - hold='on') |
| 52 | +cset3 = contour(X, Y, Z, (0,), |
| 53 | + colors = 'g', |
| 54 | + linewidths = 2, |
| 55 | + hold='on') |
56 | 56 | title('Filled contours')
|
57 | 57 | #colorbar()
|
58 | 58 | hot()
|
|
62 | 62 |
|
63 | 63 | imshow(Z, extent=extent)
|
64 | 64 | v = axis()
|
65 |
| -contour(Z, levels, hold='on', colors = 'k', origin='upper', extent=extent) |
| 65 | +contour(Z, cset3.levels, hold='on', colors = 'k', |
| 66 | + origin='upper', extent=extent) |
66 | 67 | axis(v)
|
67 | 68 | title("Image, origin 'upper'")
|
68 | 69 |
|
69 | 70 | subplot(2,2,3)
|
70 | 71 |
|
71 | 72 | imshow(Z, origin='lower', extent=extent)
|
72 | 73 | v = axis()
|
73 |
| -contour(Z, levels, hold='on', colors = 'k', origin='lower', extent=extent) |
| 74 | +contour(Z, cset3.levels, hold='on', colors = 'k', |
| 75 | + origin='lower', extent=extent) |
74 | 76 | axis(v)
|
75 | 77 | title("Image, origin 'lower'")
|
76 | 78 |
|
|
84 | 86 | # domain that is contoured does not extend beyond these pixel centers.
|
85 | 87 | imshow(Z, interpolation='nearest', extent=extent)
|
86 | 88 | v = axis()
|
87 |
| -contour(Z, levels, hold='on', colors = 'k', origin='image', extent=extent) |
| 89 | +contour(Z, cset3.levels, hold='on', colors = 'k', |
| 90 | + origin='image', extent=extent) |
88 | 91 | axis(v)
|
89 | 92 | ylim = get(gca(), 'ylim')
|
90 | 93 | setp(gca(), ylim=ylim[::-1])
|
|
0 commit comments