|
37 | 37 | and bottom are horizontal). If None, the location will come from the |
38 | 38 | *orientation* if it is set (vertical colorbars on the right, horizontal |
39 | 39 | ones at the bottom), or default to 'right' if *orientation* is unset. |
| 40 | +
|
40 | 41 | orientation : None or {'vertical', 'horizontal'} |
41 | 42 | The orientation of the colorbar. It is preferable to set the *location* |
42 | 43 | of the colorbar, as that also determines the *orientation*; passing |
43 | 44 | incompatible values for *location* and *orientation* raises an exception. |
| 45 | +
|
44 | 46 | fraction : float, default: 0.15 |
45 | 47 | Fraction of original axes to use for colorbar. |
| 48 | +
|
46 | 49 | shrink : float, default: 1.0 |
47 | 50 | Fraction by which to multiply the size of the colorbar. |
| 51 | +
|
48 | 52 | aspect : float, default: 20 |
49 | 53 | Ratio of long to short dimensions. |
| 54 | +
|
50 | 55 | pad : float, default: 0.05 if vertical, 0.15 if horizontal |
51 | 56 | Fraction of original axes between colorbar and new image axes. |
| 57 | +
|
52 | 58 | anchor : (float, float), optional |
53 | 59 | The anchor point of the colorbar axes. |
54 | 60 | Defaults to (0.0, 0.5) if vertical; (0.5, 1.0) if horizontal. |
| 61 | +
|
55 | 62 | panchor : (float, float), or *False*, optional |
56 | 63 | The anchor point of the colorbar parent axes. If *False*, the parent |
57 | 64 | axes' anchor will be unchanged. |
58 | 65 | Defaults to (1.0, 0.5) if vertical; (0.5, 0.0) if horizontal. |
59 | 66 | """ |
60 | 67 |
|
61 | 68 | _colormap_kw_doc = """ |
62 | | -
|
63 | | - ============ ==================================================== |
64 | | - Property Description |
65 | | - ============ ==================================================== |
66 | | - *extend* {'neither', 'both', 'min', 'max'} |
67 | | - If not 'neither', make pointed end(s) for out-of- |
68 | | - range values. These are set for a given colormap |
69 | | - using the colormap set_under and set_over methods. |
70 | | - *extendfrac* {*None*, 'auto', length, lengths} |
71 | | - If set to *None*, both the minimum and maximum |
72 | | - triangular colorbar extensions with have a length of |
73 | | - 5% of the interior colorbar length (this is the |
74 | | - default setting). If set to 'auto', makes the |
75 | | - triangular colorbar extensions the same lengths as |
76 | | - the interior boxes (when *spacing* is set to |
77 | | - 'uniform') or the same lengths as the respective |
78 | | - adjacent interior boxes (when *spacing* is set to |
79 | | - 'proportional'). If a scalar, indicates the length |
80 | | - of both the minimum and maximum triangular colorbar |
81 | | - extensions as a fraction of the interior colorbar |
82 | | - length. A two-element sequence of fractions may also |
83 | | - be given, indicating the lengths of the minimum and |
84 | | - maximum colorbar extensions respectively as a |
85 | | - fraction of the interior colorbar length. |
86 | | - *extendrect* bool |
87 | | - If *False* the minimum and maximum colorbar extensions |
88 | | - will be triangular (the default). If *True* the |
89 | | - extensions will be rectangular. |
90 | | - *spacing* {'uniform', 'proportional'} |
91 | | - Uniform spacing gives each discrete color the same |
92 | | - space; proportional makes the space proportional to |
93 | | - the data interval. |
94 | | - *ticks* *None* or list of ticks or Locator |
95 | | - If None, ticks are determined automatically from the |
96 | | - input. |
97 | | - *format* None or str or Formatter |
98 | | - If None, `~.ticker.ScalarFormatter` is used. |
99 | | - If a format string is given, e.g., '%.3f', that is used. |
100 | | - An alternative `~.ticker.Formatter` may be given instead. |
101 | | - *drawedges* bool |
102 | | - Whether to draw lines at color boundaries. |
103 | | - *label* str |
104 | | - The label on the colorbar's long axis. |
105 | | - ============ ==================================================== |
106 | | -
|
107 | | - The following will probably be useful only in the context of |
108 | | - indexed colors (that is, when the mappable has norm=NoNorm()), |
109 | | - or other unusual circumstances. |
110 | | -
|
111 | | - ============ =================================================== |
112 | | - Property Description |
113 | | - ============ =================================================== |
114 | | - *boundaries* None or a sequence |
115 | | - *values* None or a sequence which must be of length 1 less |
116 | | - than the sequence of *boundaries*. For each region |
117 | | - delimited by adjacent entries in *boundaries*, the |
118 | | - colormapped to the corresponding value in values |
119 | | - will be used. |
120 | | - ============ =================================================== |
121 | | -
|
| 69 | +extend : {'neither', 'both', 'min', 'max'} |
| 70 | + Make pointed end(s) for out-of-range values (unless 'neither'). These are |
| 71 | + set for a given colormap using the colormap set_under and set_over methods. |
| 72 | +
|
| 73 | +extendfrac : {*None*, 'auto', length, lengths} |
| 74 | + If set to *None*, both the minimum and maximum triangular colorbar |
| 75 | + extensions will have a length of 5% of the interior colorbar length (this |
| 76 | + is the default setting). |
| 77 | +
|
| 78 | + If set to 'auto', makes the triangular colorbar extensions the same lengths |
| 79 | + as the interior boxes (when *spacing* is set to 'uniform') or the same |
| 80 | + lengths as the respective adjacent interior boxes (when *spacing* is set to |
| 81 | + 'proportional'). |
| 82 | +
|
| 83 | + If a scalar, indicates the length of both the minimum and maximum |
| 84 | + triangular colorbar extensions as a fraction of the interior colorbar |
| 85 | + length. A two-element sequence of fractions may also be given, indicating |
| 86 | + the lengths of the minimum and maximum colorbar extensions respectively as |
| 87 | + a fraction of the interior colorbar length. |
| 88 | +
|
| 89 | +extendrect : bool |
| 90 | + If *False* the minimum and maximum colorbar extensions will be triangular |
| 91 | + (the default). If *True* the extensions will be rectangular. |
| 92 | +
|
| 93 | +spacing : {'uniform', 'proportional'} |
| 94 | + For discrete colorbars (`.BoundaryNorm` or contours), 'uniform' gives each |
| 95 | + color the same space; 'proportional' makes the space proportional to the |
| 96 | + data interval. |
| 97 | +
|
| 98 | +ticks : None or list of ticks or Locator |
| 99 | + If None, ticks are determined automatically from the input. |
| 100 | +
|
| 101 | +format : None or str or Formatter |
| 102 | + If None, `~.ticker.ScalarFormatter` is used. |
| 103 | + Format strings, e.g., ``"%4.2e"`` or ``"{x:.2e}"``, are supported. |
| 104 | + An alternative `~.ticker.Formatter` may be given instead. |
| 105 | +
|
| 106 | +drawedges : bool |
| 107 | + Whether to draw lines at color boundaries. |
| 108 | +
|
| 109 | +label : str |
| 110 | + The label on the colorbar's long axis. |
| 111 | +
|
| 112 | +boundaries, values : None or a sequence |
| 113 | + If unset, the colormap will be displayed on a 0-1 scale. |
| 114 | + If sequences, *values* must have a length 1 less than *boundaries*. For |
| 115 | + each region delimited by adjacent entries in *boundaries*, the color mapped |
| 116 | + to the corresponding value in values will be used. |
| 117 | + Normally only useful for indexed colors (i.e. ``norm=NoNorm()``) or other |
| 118 | + unusual circumstances. |
122 | 119 | """ |
123 | 120 |
|
124 | 121 | docstring.interpd.update(colorbar_doc=""" |
|
186 | 183 | However this has negative consequences in other circumstances, e.g. with |
187 | 184 | semi-transparent images (alpha < 1) and colorbar extensions; therefore, this |
188 | 185 | workaround is not used by default (see issue #1188). |
189 | | -""" % (textwrap.indent(_make_axes_kw_doc, " "), _colormap_kw_doc)) |
| 186 | +""" % (textwrap.indent(_make_axes_kw_doc, " "), |
| 187 | + textwrap.indent(_colormap_kw_doc, " "))) |
190 | 188 |
|
191 | 189 |
|
192 | 190 | def _set_ticks_on_axis_warn(*args, **kwargs): |
@@ -273,6 +271,7 @@ def get_subplotspec(self): |
273 | 271 | return ss |
274 | 272 |
|
275 | 273 |
|
| 274 | +@docstring.Substitution(_colormap_kw_doc) |
276 | 275 | class Colorbar: |
277 | 276 | r""" |
278 | 277 | Draw a colorbar in an existing axes. |
@@ -325,32 +324,14 @@ class Colorbar: |
325 | 324 | alpha : float |
326 | 325 | The colorbar transparency between 0 (transparent) and 1 (opaque). |
327 | 326 |
|
328 | | - values, boundaries |
329 | | - If unset, the colormap will be displayed on a 0-1 scale. |
330 | | -
|
331 | 327 | orientation : {'vertical', 'horizontal'} |
332 | 328 |
|
333 | 329 | ticklocation : {'auto', 'left', 'right', 'top', 'bottom'} |
334 | 330 |
|
335 | | - extend : {'neither', 'both', 'min', 'max'} |
336 | | -
|
337 | | - spacing : {'uniform', 'proportional'} |
338 | | -
|
339 | | - ticks : `~matplotlib.ticker.Locator` or array-like of float |
340 | | -
|
341 | | - format : str or `~matplotlib.ticker.Formatter` |
342 | | - If string, it supports '%' operator and `str.format` formats: |
343 | | - e.g. ``"%4.2e"`` or ``"{x:.2e}"``. |
344 | | -
|
345 | 331 | drawedges : bool |
346 | 332 |
|
347 | 333 | filled : bool |
348 | | -
|
349 | | - extendfrac |
350 | | -
|
351 | | - extendrec |
352 | | -
|
353 | | - label : str |
| 334 | + %s |
354 | 335 | """ |
355 | 336 |
|
356 | 337 | n_rasterize = 50 # rasterize solids if number of colors >= n_rasterize |
|
0 commit comments