|
1 | 1 | """ |
2 | | -========================================================= |
3 | | -Line, Poly and RegularPoly Collection with autoscaling |
4 | | -========================================================= |
| 2 | +===================================== |
| 3 | +Line, Poly and RegularPoly Collection |
| 4 | +===================================== |
5 | 5 |
|
6 | 6 | For the first two subplots, we will use spirals. Their size will be set in |
7 | 7 | plot units, not data units. Their positions will be set in data units by using |
|
38 | 38 | # Make some offsets |
39 | 39 | xyo = rs.randn(npts, 2) |
40 | 40 |
|
41 | | -# Make a list of colors cycling through the default series. |
| 41 | +# Make a list of colors from the default color cycle. |
42 | 42 | colors = plt.rcParams['axes.prop_cycle'].by_key()['color'] |
43 | 43 |
|
44 | 44 | fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2) |
|
59 | 59 | # but it is good enough to generate a plot that you can use |
60 | 60 | # as a starting point. If you know beforehand the range of |
61 | 61 | # x and y that you want to show, it is better to set them |
62 | | -# explicitly, leave out the *autolim* keyword argument (or set it to False), |
63 | | -# and omit the 'ax1.autoscale_view()' call below. |
| 62 | +# explicitly, set the *autolim* keyword argument to False. |
64 | 63 |
|
65 | 64 | # Make a transform for the line segments such that their size is |
66 | 65 | # given in points: |
67 | 66 | col.set_color(colors) |
68 | 67 |
|
69 | | -ax1.autoscale_view() # See comment above, after ax1.add_collection. |
70 | 68 | ax1.set_title('LineCollection using offsets') |
71 | 69 |
|
72 | 70 |
|
|
79 | 77 | col.set_color(colors) |
80 | 78 |
|
81 | 79 |
|
82 | | -ax2.autoscale_view() |
83 | 80 | ax2.set_title('PolyCollection using offsets') |
84 | 81 |
|
85 | 82 | # 7-sided regular polygons |
|
90 | 87 | col.set_transform(trans) # the points to pixels transform |
91 | 88 | ax3.add_collection(col, autolim=True) |
92 | 89 | col.set_color(colors) |
93 | | -ax3.autoscale_view() |
94 | 90 | ax3.set_title('RegularPolyCollection using offsets') |
95 | 91 |
|
96 | 92 |
|
|
114 | 110 | col = collections.LineCollection(segs, offsets=offs) |
115 | 111 | ax4.add_collection(col, autolim=True) |
116 | 112 | col.set_color(colors) |
117 | | -ax4.autoscale_view() |
118 | 113 | ax4.set_title('Successive data offsets') |
119 | 114 | ax4.set_xlabel('Zonal velocity component (m/s)') |
120 | 115 | ax4.set_ylabel('Depth (m)') |
|
136 | 131 | # - `matplotlib.collections.LineCollection` |
137 | 132 | # - `matplotlib.collections.RegularPolyCollection` |
138 | 133 | # - `matplotlib.axes.Axes.add_collection` |
139 | | -# - `matplotlib.axes.Axes.autoscale_view` |
140 | 134 | # - `matplotlib.transforms.Affine2D` |
141 | 135 | # - `matplotlib.transforms.Affine2D.scale` |
0 commit comments