|
1 | 1 | import numpy as np |
2 | 2 |
|
| 3 | +from matplotlib import docstring |
3 | 4 | from matplotlib.contour import ContourSet |
4 | 5 | from matplotlib.tri.triangulation import Triangulation |
5 | 6 |
|
@@ -107,175 +108,164 @@ def _contour_args(self, args, kwargs): |
107 | 108 | return (tri, z) |
108 | 109 |
|
109 | 110 |
|
110 | | -def tricontour(ax, *args, **kwargs): |
111 | | - """ |
112 | | - Draw contours on an unstructured triangular grid. |
113 | | -
|
114 | | - `.tricontour` and `.tricontourf` draw contour lines and filled contours, |
115 | | - respectively. Except as noted, function signatures and return values are |
116 | | - the same for both versions. |
117 | | -
|
118 | | - The triangulation can be specified in one of two ways; either :: |
119 | | -
|
120 | | - tricontour(triangulation, ...) |
121 | | -
|
122 | | - where *triangulation* is a `.Triangulation` object, or :: |
| 111 | +docstring.interpd.update(_tricontour_doc=""" |
| 112 | +Draw contour %(type)s on an unstructured triangular grid. |
123 | 113 |
|
124 | | - tricontour(x, y, ...) |
125 | | - tricontour(x, y, triangles, ...) |
126 | | - tricontour(x, y, triangles=triangles, ...) |
127 | | - tricontour(x, y, mask=mask, ...) |
128 | | - tricontour(x, y, triangles, mask=mask, ...) |
| 114 | +The triangulation can be specified in one of two ways; either :: |
129 | 115 |
|
130 | | - in which case a `.Triangulation` object will be created. See that class' |
131 | | - docstring for an explanation of these cases. |
| 116 | + %(func)s(triangulation, ...) |
132 | 117 |
|
133 | | - The remaining arguments may be:: |
| 118 | +where *triangulation* is a `.Triangulation` object, or :: |
134 | 119 |
|
135 | | - tricontour(..., Z) |
| 120 | + %(func)s(x, y, ...) |
| 121 | + %(func)s(x, y, triangles, ...) |
| 122 | + %(func)s(x, y, triangles=triangles, ...) |
| 123 | + %(func)s(x, y, mask=mask, ...) |
| 124 | + %(func)s(x, y, triangles, mask=mask, ...) |
136 | 125 |
|
137 | | - where *Z* is the array of values to contour, one per point in the |
138 | | - triangulation. The level values are chosen automatically. |
| 126 | +in which case a `.Triangulation` object will be created. See that class' |
| 127 | +docstring for an explanation of these cases. |
139 | 128 |
|
140 | | - :: |
| 129 | +The remaining arguments may be:: |
141 | 130 |
|
142 | | - tricontour(..., Z, N) |
| 131 | + %(func)s(..., Z) |
143 | 132 |
|
144 | | - contour up to *N+1* automatically chosen contour levels (*N* intervals). |
| 133 | +where *Z* is the array of values to contour, one per point in the |
| 134 | +triangulation. The level values are chosen automatically. |
145 | 135 |
|
146 | | - :: |
| 136 | +:: |
147 | 137 |
|
148 | | - tricontour(..., Z, V) |
| 138 | + %(func)s(..., Z, N) |
149 | 139 |
|
150 | | - draw contour lines at the values specified in sequence *V*, |
151 | | - which must be in increasing order. |
| 140 | +contour up to *N+1* automatically chosen contour levels (*N* intervals). |
152 | 141 |
|
153 | | - :: |
| 142 | +:: |
154 | 143 |
|
155 | | - tricontourf(..., Z, V) |
| 144 | + %(func)s(..., Z, V) |
156 | 145 |
|
157 | | - fill the (len(*V*)-1) regions between the values in *V*, |
158 | | - which must be in increasing order. |
| 146 | +draw contour %(type)s at the values specified in sequence *V*, which must be in |
| 147 | +increasing order. |
159 | 148 |
|
160 | | - :: |
| 149 | +:: |
161 | 150 |
|
162 | | - tricontour(Z, **kwargs) |
| 151 | + %(func)s(Z, **kwargs) |
163 | 152 |
|
164 | | - Use keyword args to control colors, linewidth, origin, cmap ... see |
165 | | - below for more details. |
| 153 | +Use keyword arguments to control colors, linewidth, origin, cmap ... see below |
| 154 | +for more details. |
166 | 155 |
|
167 | | - `~.Axes.tricontour` returns a `~matplotlib.tri.TriContourSet` object. |
| 156 | +Returns |
| 157 | +------- |
| 158 | +`~matplotlib.tri.TriContourSet` |
168 | 159 |
|
169 | | - Optional keyword arguments: |
| 160 | +Other Parameters |
| 161 | +---------------- |
| 162 | +colors : [ *None* | str | (mpl_colors) ] |
| 163 | + If *None*, the colormap specified by cmap will be used. |
170 | 164 |
|
171 | | - *colors*: [ *None* | str | (mpl_colors) ] |
172 | | - If *None*, the colormap specified by cmap will be used. |
| 165 | + If a string, like 'r' or 'red', all levels will be plotted in this color. |
173 | 166 |
|
174 | | - If a string, like 'r' or 'red', all levels will be plotted in this |
175 | | - color. |
| 167 | + If a tuple of colors (string, float, rgb, etc), different levels will be |
| 168 | + plotted in different colors in the order specified. |
176 | 169 |
|
177 | | - If a tuple of colors (string, float, rgb, etc), different levels will |
178 | | - be plotted in different colors in the order specified. |
| 170 | +alpha : float |
| 171 | + The alpha blending value |
179 | 172 |
|
180 | | - *alpha*: float |
181 | | - The alpha blending value |
| 173 | +cmap : [ *None* | Colormap ] |
| 174 | + A cm :class:`~matplotlib.colors.Colormap` instance or *None*. If *cmap* is |
| 175 | + *None* and *colors* is *None*, a default Colormap is used. |
182 | 176 |
|
183 | | - *cmap*: [ *None* | Colormap ] |
184 | | - A cm :class:`~matplotlib.colors.Colormap` instance or |
185 | | - *None*. If *cmap* is *None* and *colors* is *None*, a |
186 | | - default Colormap is used. |
| 177 | +norm : [ *None* | Normalize ] |
| 178 | + A :class:`matplotlib.colors.Normalize` instance for scaling data values to |
| 179 | + colors. If *norm* is *None* and *colors* is *None*, the default linear |
| 180 | + scaling is used. |
187 | 181 |
|
188 | | - *norm*: [ *None* | Normalize ] |
189 | | - A :class:`matplotlib.colors.Normalize` instance for |
190 | | - scaling data values to colors. If *norm* is *None* and |
191 | | - *colors* is *None*, the default linear scaling is used. |
| 182 | +levels : [level0, level1, ..., leveln] |
| 183 | + A list of floating point numbers indicating the level curves to draw, in |
| 184 | + increasing order; e.g., to draw just the zero contour pass ``levels=[0]`` |
192 | 185 |
|
193 | | - *levels* [level0, level1, ..., leveln] |
194 | | - A list of floating point numbers indicating the level |
195 | | - curves to draw, in increasing order; e.g., to draw just |
196 | | - the zero contour pass ``levels=[0]`` |
| 186 | +origin : [ *None* | 'upper' | 'lower' | 'image' ] |
| 187 | + If *None*, the first value of *Z* will correspond to the lower left corner, |
| 188 | + location (0, 0). If 'image', the rc value for ``image.origin`` will be |
| 189 | + used. |
197 | 190 |
|
198 | | - *origin*: [ *None* | 'upper' | 'lower' | 'image' ] |
199 | | - If *None*, the first value of *Z* will correspond to the |
200 | | - lower left corner, location (0, 0). If 'image', the rc |
201 | | - value for ``image.origin`` will be used. |
| 191 | + This keyword is not active if *X* and *Y* are specified in the call to |
| 192 | + contour. |
202 | 193 |
|
203 | | - This keyword is not active if *X* and *Y* are specified in |
204 | | - the call to contour. |
| 194 | +extent : [ *None* | (x0, x1, y0, y1) ] |
| 195 | + If *origin* is not *None*, then *extent* is interpreted as in |
| 196 | + :func:`matplotlib.pyplot.imshow`: it gives the outer pixel boundaries. In |
| 197 | + this case, the position of Z[0, 0] is the center of the pixel, not a |
| 198 | + corner. If *origin* is *None*, then (*x0*, *y0*) is the position of Z[0, |
| 199 | + 0], and (*x1*, *y1*) is the position of Z[-1, -1]. |
205 | 200 |
|
206 | | - *extent*: [ *None* | (x0, x1, y0, y1) ] |
| 201 | + This keyword is not active if *X* and *Y* are specified in the call to |
| 202 | + contour. |
207 | 203 |
|
208 | | - If *origin* is not *None*, then *extent* is interpreted as |
209 | | - in :func:`matplotlib.pyplot.imshow`: it gives the outer |
210 | | - pixel boundaries. In this case, the position of Z[0, 0] |
211 | | - is the center of the pixel, not a corner. If *origin* is |
212 | | - *None*, then (*x0*, *y0*) is the position of Z[0, 0], and |
213 | | - (*x1*, *y1*) is the position of Z[-1, -1]. |
| 204 | +locator : [ *None* | ticker.Locator subclass ] |
| 205 | + If *locator* is None, the default :class:`~matplotlib.ticker.MaxNLocator` |
| 206 | + is used. The locator is used to determine the contour levels if they are |
| 207 | + not given explicitly via the *V* argument. |
214 | 208 |
|
215 | | - This keyword is not active if *X* and *Y* are specified in |
216 | | - the call to contour. |
| 209 | +extend : [ 'neither' | 'both' | 'min' | 'max' ] |
| 210 | + Unless this is 'neither', contour levels are automatically added to one or |
| 211 | + both ends of the range so that all data are included. These added ranges |
| 212 | + are then mapped to the special colormap values which default to the ends of |
| 213 | + the colormap range, but can be set via |
| 214 | + :meth:`matplotlib.colors.Colormap.set_under` and |
| 215 | + :meth:`matplotlib.colors.Colormap.set_over` methods. |
217 | 216 |
|
218 | | - *locator*: [ *None* | ticker.Locator subclass ] |
219 | | - If *locator* is None, the default |
220 | | - :class:`~matplotlib.ticker.MaxNLocator` is used. The |
221 | | - locator is used to determine the contour levels if they |
222 | | - are not given explicitly via the *V* argument. |
| 217 | +xunits, yunits : [ *None* | registered units ] |
| 218 | + Override axis units by specifying an instance of a |
| 219 | + :class:`matplotlib.units.ConversionInterface`.""") |
223 | 220 |
|
224 | | - *extend*: [ 'neither' | 'both' | 'min' | 'max' ] |
225 | | - Unless this is 'neither', contour levels are automatically |
226 | | - added to one or both ends of the range so that all data |
227 | | - are included. These added ranges are then mapped to the |
228 | | - special colormap values which default to the ends of the |
229 | | - colormap range, but can be set via |
230 | | - :meth:`matplotlib.colors.Colormap.set_under` and |
231 | | - :meth:`matplotlib.colors.Colormap.set_over` methods. |
232 | 221 |
|
233 | | - *xunits*, *yunits*: [ *None* | registered units ] |
234 | | - Override axis units by specifying an instance of a |
235 | | - :class:`matplotlib.units.ConversionInterface`. |
236 | | -
|
237 | | - tricontour-only keyword arguments: |
| 222 | +@docstring.Substitution(func='tricontour', type='lines') |
| 223 | +@docstring.dedent_interpd |
| 224 | +def tricontour(ax, *args, **kwargs): |
| 225 | + """ |
| 226 | + %(_tricontour_doc)s |
238 | 227 |
|
239 | | - *linewidths*: [ *None* | number | tuple of numbers ] |
| 228 | + linewidths : [ *None* | number | tuple of numbers ] |
240 | 229 | If *linewidths* is *None*, defaults to :rc:`lines.linewidth`. |
241 | 230 |
|
242 | 231 | If a number, all levels will be plotted with this linewidth. |
243 | 232 |
|
244 | | - If a tuple, different levels will be plotted with different |
245 | | - linewidths in the order specified |
| 233 | + If a tuple, different levels will be plotted with different linewidths |
| 234 | + in the order specified |
246 | 235 |
|
247 | | - *linestyles*: [ *None* | 'solid' | 'dashed' | 'dashdot' | 'dotted' ] |
| 236 | + linestyles : [ *None* | 'solid' | 'dashed' | 'dashdot' | 'dotted' ] |
248 | 237 | If *linestyles* is *None*, the 'solid' is used. |
249 | 238 |
|
250 | | - *linestyles* can also be an iterable of the above strings |
251 | | - specifying a set of linestyles to be used. If this |
252 | | - iterable is shorter than the number of contour levels |
253 | | - it will be repeated as necessary. |
| 239 | + *linestyles* can also be an iterable of the above strings specifying a |
| 240 | + set of linestyles to be used. If this iterable is shorter than the |
| 241 | + number of contour levels it will be repeated as necessary. |
| 242 | +
|
| 243 | + If contour is using a monochrome colormap and the contour level is less |
| 244 | + than 0, then the linestyle specified in |
| 245 | + :rc:`contour.negative_linestyle` will be used. |
| 246 | + """ |
| 247 | + kwargs['filled'] = False |
| 248 | + return TriContourSet(ax, *args, **kwargs) |
254 | 249 |
|
255 | | - If contour is using a monochrome colormap and the contour |
256 | | - level is less than 0, then the linestyle specified |
257 | | - in :rc:`contour.negative_linestyle` will be used. |
258 | 250 |
|
259 | | - tricontourf-only keyword arguments: |
| 251 | +@docstring.Substitution(func='tricontourf', type='regions') |
| 252 | +@docstring.dedent_interpd |
| 253 | +def tricontourf(ax, *args, **kwargs): |
| 254 | + """ |
| 255 | + %(_tricontour_doc)s |
260 | 256 |
|
261 | | - *antialiased*: bool |
| 257 | + antialiased : bool |
262 | 258 | enable antialiasing |
263 | 259 |
|
264 | | - Note: `.tricontourf` fills intervals that are closed at the top; that is, |
265 | | - for boundaries *z1* and *z2*, the filled region is:: |
| 260 | + Notes |
| 261 | + ----- |
| 262 | + `.tricontourf` fills intervals that are closed at the top; that is, for |
| 263 | + boundaries *z1* and *z2*, the filled region is:: |
266 | 264 |
|
267 | 265 | z1 < Z <= z2 |
268 | 266 |
|
269 | 267 | except for the lowest interval, which is closed on both sides (i.e. it |
270 | 268 | includes the lowest value). |
271 | 269 | """ |
272 | | - kwargs['filled'] = False |
273 | | - return TriContourSet(ax, *args, **kwargs) |
274 | | - |
275 | | - |
276 | | -def tricontourf(ax, *args, **kwargs): |
277 | 270 | kwargs['filled'] = True |
278 | 271 | return TriContourSet(ax, *args, **kwargs) |
279 | | - |
280 | | - |
281 | | -tricontourf.__doc__ = tricontour.__doc__ |
0 commit comments