matplotlib  1.5.2
About: matplotlib is a python 2D plotting library which produces publication quality figures in a variety of hardcopy formats and interactive environments across platforms.
  Fossies Dox: matplotlib-1.5.2.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

colorbar.py
Go to the documentation of this file.
1 '''
2 Colorbar toolkit with two classes and a function:
3 
4  :class:`ColorbarBase`
5  the base class with full colorbar drawing functionality.
6  It can be used as-is to make a colorbar for a given colormap;
7  a mappable object (e.g., image) is not needed.
8 
9  :class:`Colorbar`
10  the derived class for use with images or contour plots.
11 
12  :func:`make_axes`
13  a function for resizing an axes and adding a second axes
14  suitable for a colorbar
15 
16 The :meth:`~matplotlib.figure.Figure.colorbar` method uses :func:`make_axes`
17 and :class:`Colorbar`; the :func:`~matplotlib.pyplot.colorbar` function
18 is a thin wrapper over :meth:`~matplotlib.figure.Figure.colorbar`.
19 
20 '''
21 from __future__ import (absolute_import, division, print_function,
22  unicode_literals)
23 
24 from matplotlib.externals import six
25 from matplotlib.externals.six.moves import xrange, zip
26 
27 import warnings
28 
29 import numpy as np
30 
31 import matplotlib as mpl
32 import matplotlib.artist as martist
33 import matplotlib.cbook as cbook
34 import matplotlib.collections as collections
35 import matplotlib.colors as colors
36 import matplotlib.contour as contour
37 import matplotlib.cm as cm
38 import matplotlib.gridspec as gridspec
39 import matplotlib.patches as mpatches
40 import matplotlib.path as mpath
41 import matplotlib.ticker as ticker
42 import matplotlib.transforms as mtrans
43 
44 from matplotlib import docstring
45 
46 make_axes_kw_doc = '''
47 
48  ============= ====================================================
49  Property Description
50  ============= ====================================================
51  *orientation* vertical or horizontal
52  *fraction* 0.15; fraction of original axes to use for colorbar
53  *pad* 0.05 if vertical, 0.15 if horizontal; fraction
54  of original axes between colorbar and new image axes
55  *shrink* 1.0; fraction by which to shrink the colorbar
56  *aspect* 20; ratio of long to short dimensions
57  *anchor* (0.0, 0.5) if vertical; (0.5, 1.0) if horizontal;
58  the anchor point of the colorbar axes
59  *panchor* (1.0, 0.5) if vertical; (0.5, 0.0) if horizontal;
60  the anchor point of the colorbar parent axes. If
61  False, the parent axes' anchor will be unchanged
62  ============= ====================================================
63 
64 '''
65 
66 colormap_kw_doc = '''
67 
68  ============ ====================================================
69  Property Description
70  ============ ====================================================
71  *extend* [ 'neither' | 'both' | 'min' | 'max' ]
72  If not 'neither', make pointed end(s) for out-of-
73  range values. These are set for a given colormap
74  using the colormap set_under and set_over methods.
75  *extendfrac* [ *None* | 'auto' | length | lengths ]
76  If set to *None*, both the minimum and maximum
77  triangular colorbar extensions with have a length of
78  5% of the interior colorbar length (this is the
79  default setting). If set to 'auto', makes the
80  triangular colorbar extensions the same lengths as
81  the interior boxes (when *spacing* is set to
82  'uniform') or the same lengths as the respective
83  adjacent interior boxes (when *spacing* is set to
84  'proportional'). If a scalar, indicates the length
85  of both the minimum and maximum triangular colorbar
86  extensions as a fraction of the interior colorbar
87  length. A two-element sequence of fractions may also
88  be given, indicating the lengths of the minimum and
89  maximum colorbar extensions respectively as a
90  fraction of the interior colorbar length.
91  *extendrect* [ *False* | *True* ]
92  If *False* the minimum and maximum colorbar extensions
93  will be triangular (the default). If *True* the
94  extensions will be rectangular.
95  *spacing* [ 'uniform' | 'proportional' ]
96  Uniform spacing gives each discrete color the same
97  space; proportional makes the space proportional to
98  the data interval.
99  *ticks* [ None | list of ticks | Locator object ]
100  If None, ticks are determined automatically from the
101  input.
102  *format* [ None | format string | Formatter object ]
103  If None, the
104  :class:`~matplotlib.ticker.ScalarFormatter` is used.
105  If a format string is given, e.g., '%.3f', that is
106  used. An alternative
107  :class:`~matplotlib.ticker.Formatter` object may be
108  given instead.
109  *drawedges* [ False | True ] If true, draw lines at color
110  boundaries.
111  ============ ====================================================
112 
113  The following will probably be useful only in the context of
114  indexed colors (that is, when the mappable has norm=NoNorm()),
115  or other unusual circumstances.
116 
117  ============ ===================================================
118  Property Description
119  ============ ===================================================
120  *boundaries* None or a sequence
121  *values* None or a sequence which must be of length 1 less
122  than the sequence of *boundaries*. For each region
123  delimited by adjacent entries in *boundaries*, the
124  color mapped to the corresponding value in values
125  will be used.
126  ============ ===================================================
127 
128 '''
129 
130 colorbar_doc = '''
131 
132 Add a colorbar to a plot.
133 
134 Function signatures for the :mod:`~matplotlib.pyplot` interface; all
135 but the first are also method signatures for the
136 :meth:`~matplotlib.figure.Figure.colorbar` method::
137 
138  colorbar(**kwargs)
139  colorbar(mappable, **kwargs)
140  colorbar(mappable, cax=cax, **kwargs)
141  colorbar(mappable, ax=ax, **kwargs)
142 
143 arguments:
144 
145  *mappable*
146  the :class:`~matplotlib.image.Image`,
147  :class:`~matplotlib.contour.ContourSet`, etc. to
148  which the colorbar applies; this argument is mandatory for the
149  :meth:`~matplotlib.figure.Figure.colorbar` method but optional for the
150  :func:`~matplotlib.pyplot.colorbar` function, which sets the
151  default to the current image.
152 
153 keyword arguments:
154 
155  *cax*
156  None | axes object into which the colorbar will be drawn
157  *ax*
158  None | parent axes object(s) from which space for a new
159  colorbar axes will be stolen. If a list of axes is given
160  they will all be resized to make room for the colorbar axes.
161  *use_gridspec*
162  False | If *cax* is None, a new *cax* is created as an instance of
163  Axes. If *ax* is an instance of Subplot and *use_gridspec* is True,
164  *cax* is created as an instance of Subplot using the
165  grid_spec module.
166 
167 
168 Additional keyword arguments are of two kinds:
169 
170  axes properties:
171 %s
172  colorbar properties:
173 %s
174 
175 If *mappable* is a :class:`~matplotlib.contours.ContourSet`, its *extend*
176 kwarg is included automatically.
177 
178 Note that the *shrink* kwarg provides a simple way to keep a vertical
179 colorbar, for example, from being taller than the axes of the mappable
180 to which the colorbar is attached; but it is a manual method requiring
181 some trial and error. If the colorbar is too tall (or a horizontal
182 colorbar is too wide) use a smaller value of *shrink*.
183 
184 For more precise control, you can manually specify the positions of
185 the axes objects in which the mappable and the colorbar are drawn. In
186 this case, do not use any of the axes properties kwargs.
187 
188 It is known that some vector graphics viewer (svg and pdf) renders white gaps
189 between segments of the colorbar. This is due to bugs in the viewers not
190 matplotlib. As a workaround the colorbar can be rendered with overlapping
191 segments::
192 
193  cbar = colorbar()
194  cbar.solids.set_edgecolor("face")
195  draw()
196 
197 However this has negative consequences in other circumstances. Particularly
198 with semi transparent images (alpha < 1) and colorbar extensions and is not
199 enabled by default see (issue #1188).
200 
201 returns:
202  :class:`~matplotlib.colorbar.Colorbar` instance; see also its base class,
203  :class:`~matplotlib.colorbar.ColorbarBase`. Call the
204  :meth:`~matplotlib.colorbar.ColorbarBase.set_label` method
205  to label the colorbar.
206 
207 ''' % (make_axes_kw_doc, colormap_kw_doc)
208 
209 docstring.interpd.update(colorbar_doc=colorbar_doc)
210 
211 
212 def _set_ticks_on_axis_warn(*args, **kw):
213  # a top level function which gets put in at the axes'
214  # set_xticks set_yticks by _patch_ax
215  warnings.warn("Use the colorbar set_ticks() method instead.")
216 
217 
219  '''
220  Draw a colorbar in an existing axes.
221 
222  This is a base class for the :class:`Colorbar` class, which is the
223  basis for the :func:`~matplotlib.pyplot.colorbar` function and the
224  :meth:`~matplotlib.figure.Figure.colorbar` method, which are the
225  usual ways of creating a colorbar.
226 
227  It is also useful by itself for showing a colormap. If the *cmap*
228  kwarg is given but *boundaries* and *values* are left as None,
229  then the colormap will be displayed on a 0-1 scale. To show the
230  under- and over-value colors, specify the *norm* as::
231 
232  colors.Normalize(clip=False)
233 
234  To show the colors versus index instead of on the 0-1 scale,
235  use::
236 
237  norm=colors.NoNorm.
238 
239  Useful attributes:
240 
241  :attr:`ax`
242  the Axes instance in which the colorbar is drawn
243 
244  :attr:`lines`
245  a list of LineCollection if lines were drawn, otherwise
246  an empty list
247 
248  :attr:`dividers`
249  a LineCollection if *drawedges* is True, otherwise None
250 
251  Useful public methods are :meth:`set_label` and :meth:`add_lines`.
252 
253  '''
254  _slice_dict = {'neither': slice(0, None),
255  'both': slice(1, -1),
256  'min': slice(1, None),
257  'max': slice(0, -1)}
258 
259  n_rasterize = 50 # rasterize solids if number of colors >= n_rasterize
260 
261  def __init__(self, ax, cmap=None,
262  norm=None,
263  alpha=None,
264  values=None,
265  boundaries=None,
266  orientation='vertical',
267  ticklocation='auto',
268  extend='neither',
269  spacing='uniform', # uniform or proportional
270  ticks=None,
271  format=None,
272  drawedges=False,
273  filled=True,
274  extendfrac=None,
275  extendrect=False,
276  label='',
277  ):
278  #: The axes that this colorbar lives in.
279  self.ax = ax
280  self._patch_ax()
281  if cmap is None:
282  cmap = cm.get_cmap()
283  if norm is None:
284  norm = colors.Normalize()
285  self.alpha = alpha
286  cm.ScalarMappable.__init__(self, cmap=cmap, norm=norm)
287  self.values = values
288  self.boundaries = boundaries
289  self.extend = extend
290  self._inside = self._slice_dict[extend]
291  self.spacing = spacing
292  self.orientation = orientation
293  self.drawedges = drawedges
294  self.filled = filled
295  self.extendfrac = extendfrac
296  self.extendrect = extendrect
297  self.solids = None
298  self.lines = list()
299  self.outline = None
300  self.patch = None
301  self.dividers = None
302 
303  if ticklocation == 'auto':
304  ticklocation = 'bottom' if orientation == 'horizontal' else 'right'
305  self.ticklocation = ticklocation
306 
307  self.set_label(label)
308  if cbook.iterable(ticks):
309  self.locator = ticker.FixedLocator(ticks, nbins=len(ticks))
310  else:
311  self.locator = ticks # Handle default in _ticker()
312  if format is None:
313  if isinstance(self.norm, colors.LogNorm):
315  else:
317  elif cbook.is_string_like(format):
318  self.formatter = ticker.FormatStrFormatter(format)
319  else:
320  self.formatter = format # Assume it is a Formatter
321  # The rest is in a method so we can recalculate when clim changes.
322  self.config_axis()
323  self.draw_all()
324 
325  def _extend_lower(self):
326  """Returns whether the lower limit is open ended."""
327  return self.extend in ('both', 'min')
328 
329  def _extend_upper(self):
330  """Returns whether the uper limit is open ended."""
331  return self.extend in ('both', 'max')
332 
333  def _patch_ax(self):
334  # bind some methods to the axes to warn users
335  # against using those methods.
336  self.ax.set_xticks = _set_ticks_on_axis_warn
337  self.ax.set_yticks = _set_ticks_on_axis_warn
338 
339  def draw_all(self):
340  '''
341  Calculate any free parameters based on the current cmap and norm,
342  and do all the drawing.
343  '''
344  self._process_values()
345  self._find_range()
346  X, Y = self._mesh()
347  C = self._values[:, np.newaxis]
348  self._config_axes(X, Y)
349  if self.filled:
350  self._add_solids(X, Y, C)
351 
352  def config_axis(self):
353  ax = self.ax
354  if self.orientation == 'vertical':
355  ax.xaxis.set_ticks([])
356  # location is either one of 'bottom' or 'top'
357  ax.yaxis.set_label_position(self.ticklocation)
358  ax.yaxis.set_ticks_position(self.ticklocation)
359  else:
360  ax.yaxis.set_ticks([])
361  # location is either one of 'left' or 'right'
362  ax.xaxis.set_label_position(self.ticklocation)
363  ax.xaxis.set_ticks_position(self.ticklocation)
364 
365  self._set_label()
366 
367  def update_ticks(self):
368  """
369  Force the update of the ticks and ticklabels. This must be
370  called whenever the tick locator and/or tick formatter changes.
371  """
372  ax = self.ax
373  ticks, ticklabels, offset_string = self._ticker()
374  if self.orientation == 'vertical':
375  ax.yaxis.set_ticks(ticks)
376  ax.set_yticklabels(ticklabels)
377  ax.yaxis.get_major_formatter().set_offset_string(offset_string)
378 
379  else:
380  ax.xaxis.set_ticks(ticks)
381  ax.set_xticklabels(ticklabels)
382  ax.xaxis.get_major_formatter().set_offset_string(offset_string)
383 
384  def set_ticks(self, ticks, update_ticks=True):
385  """
386  set tick locations. Tick locations are updated immediately unless
387  update_ticks is *False*. To manually update the ticks, call
388  *update_ticks* method explicitly.
389  """
390  if cbook.iterable(ticks):
391  self.locator = ticker.FixedLocator(ticks, nbins=len(ticks))
392  else:
393  self.locator = ticks
394 
395  if update_ticks:
396  self.update_ticks()
397  self.stale = True
398 
399  def set_ticklabels(self, ticklabels, update_ticks=True):
400  """
401  set tick labels. Tick labels are updated immediately unless
402  update_ticks is *False*. To manually update the ticks, call
403  *update_ticks* method explicitly.
404  """
405  if isinstance(self.locator, ticker.FixedLocator):
406  self.formatter = ticker.FixedFormatter(ticklabels)
407  if update_ticks:
408  self.update_ticks()
409  else:
410  warnings.warn("set_ticks() must have been called.")
411  self.stale = True
412 
413  def _config_axes(self, X, Y):
414  '''
415  Make an axes patch and outline.
416  '''
417  ax = self.ax
418  ax.set_frame_on(False)
419  ax.set_navigate(False)
420  xy = self._outline(X, Y)
421  ax.update_datalim(xy)
422  ax.set_xlim(*ax.dataLim.intervalx)
423  ax.set_ylim(*ax.dataLim.intervaly)
424  if self.outline is not None:
425  self.outline.remove()
426  self.outline = mpatches.Polygon(
427  xy, edgecolor=mpl.rcParams['axes.edgecolor'],
428  facecolor='none',
429  linewidth=mpl.rcParams['axes.linewidth'],
430  closed=True,
431  zorder=2)
432  ax.add_artist(self.outline)
433  self.outline.set_clip_box(None)
434  self.outline.set_clip_path(None)
435  c = mpl.rcParams['axes.facecolor']
436  if self.patch is not None:
437  self.patch.remove()
438  self.patch = mpatches.Polygon(xy, edgecolor=c,
439  facecolor=c,
440  linewidth=0.01,
441  zorder=-1)
442  ax.add_artist(self.patch)
443 
444  self.update_ticks()
445 
446  def _set_label(self):
447  if self.orientation == 'vertical':
448  self.ax.set_ylabel(self._label, **self._labelkw)
449  else:
450  self.ax.set_xlabel(self._label, **self._labelkw)
451  self.stale = True
452 
453  def set_label(self, label, **kw):
454  '''
455  Label the long axis of the colorbar
456  '''
457  self._label = '%s' % (label, )
458  self._labelkw = kw
459  self._set_label()
460 
461  def _outline(self, X, Y):
462  '''
463  Return *x*, *y* arrays of colorbar bounding polygon,
464  taking orientation into account.
465  '''
466  N = X.shape[0]
467  ii = [0, 1, N - 2, N - 1, 2 * N - 1, 2 * N - 2, N + 1, N, 0]
468  x = np.take(np.ravel(np.transpose(X)), ii)
469  y = np.take(np.ravel(np.transpose(Y)), ii)
470  x = x.reshape((len(x), 1))
471  y = y.reshape((len(y), 1))
472  if self.orientation == 'horizontal':
473  return np.hstack((y, x))
474  return np.hstack((x, y))
475 
476  def _edges(self, X, Y):
477  '''
478  Return the separator line segments; helper for _add_solids.
479  '''
480  N = X.shape[0]
481  # Using the non-array form of these line segments is much
482  # simpler than making them into arrays.
483  if self.orientation == 'vertical':
484  return [list(zip(X[i], Y[i])) for i in xrange(1, N - 1)]
485  else:
486  return [list(zip(Y[i], X[i])) for i in xrange(1, N - 1)]
487 
488  def _add_solids(self, X, Y, C):
489  '''
490  Draw the colors using :meth:`~matplotlib.axes.Axes.pcolormesh`;
491  optionally add separators.
492  '''
493  if self.orientation == 'vertical':
494  args = (X, Y, C)
495  else:
496  args = (np.transpose(Y), np.transpose(X), np.transpose(C))
497  kw = dict(cmap=self.cmap,
498  norm=self.norm,
499  alpha=self.alpha,
500  edgecolors='None')
501  # Save, set, and restore hold state to keep pcolor from
502  # clearing the axes. Ordinarily this will not be needed,
503  # since the axes object should already have hold set.
504  _hold = self.ax.ishold()
505  self.ax.hold(True)
506  col = self.ax.pcolormesh(*args, **kw)
507  self.ax.hold(_hold)
508  #self.add_observer(col) # We should observe, not be observed...
509 
510  if self.solids is not None:
511  self.solids.remove()
512  self.solids = col
513  if self.dividers is not None:
514  self.dividers.remove()
515  self.dividers = None
516  if self.drawedges:
517  linewidths = (0.5 * mpl.rcParams['axes.linewidth'],)
518  self.dividers = collections.LineCollection(self._edges(X, Y),
519  colors=(mpl.rcParams['axes.edgecolor'],),
520  linewidths=linewidths)
521  self.ax.add_collection(self.dividers)
522  elif len(self._y) >= self.n_rasterize:
523  self.solids.set_rasterized(True)
524 
525  def add_lines(self, levels, colors, linewidths, erase=True):
526  '''
527  Draw lines on the colorbar.
528 
529  *colors* and *linewidths* must be scalars or
530  sequences the same length as *levels*.
531 
532  Set *erase* to False to add lines without first
533  removing any previously added lines.
534  '''
535  y = self._locate(levels)
536  igood = (y < 1.001) & (y > -0.001)
537  y = y[igood]
538  if cbook.iterable(colors):
539  colors = np.asarray(colors)[igood]
540  if cbook.iterable(linewidths):
541  linewidths = np.asarray(linewidths)[igood]
542  N = len(y)
543  x = np.array([0.0, 1.0])
544  X, Y = np.meshgrid(x, y)
545  if self.orientation == 'vertical':
546  xy = [list(zip(X[i], Y[i])) for i in xrange(N)]
547  else:
548  xy = [list(zip(Y[i], X[i])) for i in xrange(N)]
549  col = collections.LineCollection(xy, linewidths=linewidths)
550 
551  if erase and self.lines:
552  for lc in self.lines:
553  lc.remove()
554  self.lines = []
555  self.lines.append(col)
556  col.set_color(colors)
557  self.ax.add_collection(col)
558  self.stale = True
559 
560  def _ticker(self):
561  '''
562  Return the sequence of ticks (colorbar data locations),
563  ticklabels (strings), and the corresponding offset string.
564  '''
565  locator = self.locator
566  formatter = self.formatter
567  if locator is None:
568  if self.boundaries is None:
569  if isinstance(self.norm, colors.NoNorm):
570  nv = len(self._values)
571  base = 1 + int(nv / 10)
572  locator = ticker.IndexLocator(base=base, offset=0)
573  elif isinstance(self.norm, colors.BoundaryNorm):
574  b = self.norm.boundaries
575  locator = ticker.FixedLocator(b, nbins=10)
576  elif isinstance(self.norm, colors.LogNorm):
577  locator = ticker.LogLocator()
578  else:
579  locator = ticker.MaxNLocator()
580  else:
581  b = self._boundaries[self._inside]
582  locator = ticker.FixedLocator(b, nbins=10)
583  if isinstance(self.norm, colors.NoNorm) and self.boundaries is None:
584  intv = self._values[0], self._values[-1]
585  else:
586  intv = self.vmin, self.vmax
587  locator.create_dummy_axis(minpos=intv[0])
588  formatter.create_dummy_axis(minpos=intv[0])
589  locator.set_view_interval(*intv)
590  locator.set_data_interval(*intv)
591  formatter.set_view_interval(*intv)
592  formatter.set_data_interval(*intv)
593 
594  b = np.array(locator())
595  if isinstance(locator, ticker.LogLocator):
596  eps = 1e-10
597  b = b[(b <= intv[1] * (1 + eps)) & (b >= intv[0] * (1 - eps))]
598  else:
599  eps = (intv[1] - intv[0]) * 1e-10
600  b = b[(b <= intv[1] + eps) & (b >= intv[0] - eps)]
601  ticks = self._locate(b)
602  formatter.set_locs(b)
603  ticklabels = [formatter(t, i) for i, t in enumerate(b)]
604  offset_string = formatter.get_offset()
605  return ticks, ticklabels, offset_string
606 
607  def _process_values(self, b=None):
608  '''
609  Set the :attr:`_boundaries` and :attr:`_values` attributes
610  based on the input boundaries and values. Input boundaries
611  can be *self.boundaries* or the argument *b*.
612  '''
613  if b is None:
614  b = self.boundaries
615  if b is not None:
616  self._boundaries = np.asarray(b, dtype=float)
617  if self.values is None:
618  self._values = 0.5 * (self._boundaries[:-1]
619  + self._boundaries[1:])
620  if isinstance(self.norm, colors.NoNorm):
621  self._values = (self._values + 0.00001).astype(np.int16)
622  return
623  self._values = np.array(self.values)
624  return
625  if self.values is not None:
626  self._values = np.array(self.values)
627  if self.boundaries is None:
628  b = np.zeros(len(self.values) + 1, 'd')
629  b[1:-1] = 0.5 * (self._values[:-1] - self._values[1:])
630  b[0] = 2.0 * b[1] - b[2]
631  b[-1] = 2.0 * b[-2] - b[-3]
632  self._boundaries = b
633  return
634  self._boundaries = np.array(self.boundaries)
635  return
636  # Neither boundaries nor values are specified;
637  # make reasonable ones based on cmap and norm.
638  if isinstance(self.norm, colors.NoNorm):
639  b = self._uniform_y(self.cmap.N + 1) * self.cmap.N - 0.5
640  v = np.zeros((len(b) - 1,), dtype=np.int16)
641  v[self._inside] = np.arange(self.cmap.N, dtype=np.int16)
642  if self._extend_lower():
643  v[0] = -1
644  if self._extend_upper():
645  v[-1] = self.cmap.N
646  self._boundaries = b
647  self._values = v
648  return
649  elif isinstance(self.norm, colors.BoundaryNorm):
650  b = list(self.norm.boundaries)
651  if self._extend_lower():
652  b = [b[0] - 1] + b
653  if self._extend_upper():
654  b = b + [b[-1] + 1]
655  b = np.array(b)
656  v = np.zeros((len(b) - 1,), dtype=float)
657  bi = self.norm.boundaries
658  v[self._inside] = 0.5 * (bi[:-1] + bi[1:])
659  if self._extend_lower():
660  v[0] = b[0] - 1
661  if self._extend_upper():
662  v[-1] = b[-1] + 1
663  self._boundaries = b
664  self._values = v
665  return
666  else:
667  if not self.norm.scaled():
668  self.norm.vmin = 0
669  self.norm.vmax = 1
670 
671  self.norm.vmin, self.norm.vmax = mtrans.nonsingular(self.norm.vmin,
672  self.norm.vmax,
673  expander=0.1)
674 
675  b = self.norm.inverse(self._uniform_y(self.cmap.N + 1))
676  if self._extend_lower():
677  b[0] = b[0] - 1
678  if self._extend_upper():
679  b[-1] = b[-1] + 1
680  self._process_values(b)
681 
682  def _find_range(self):
683  '''
684  Set :attr:`vmin` and :attr:`vmax` attributes to the first and
685  last boundary excluding extended end boundaries.
686  '''
687  b = self._boundaries[self._inside]
688  self.vmin = b[0]
689  self.vmax = b[-1]
690 
691  def _central_N(self):
692  '''number of boundaries **before** extension of ends'''
693  nb = len(self._boundaries)
694  if self.extend == 'both':
695  nb -= 2
696  elif self.extend in ('min', 'max'):
697  nb -= 1
698  return nb
699 
700  def _extended_N(self):
701  '''
702  Based on the colormap and extend variable, return the
703  number of boundaries.
704  '''
705  N = self.cmap.N + 1
706  if self.extend == 'both':
707  N += 2
708  elif self.extend in ('min', 'max'):
709  N += 1
710  return N
711 
712  def _get_extension_lengths(self, frac, automin, automax, default=0.05):
713  '''
714  Get the lengths of colorbar extensions.
715 
716  A helper method for _uniform_y and _proportional_y.
717  '''
718  # Set the default value.
719  extendlength = np.array([default, default])
720  if isinstance(frac, six.string_types):
721  if frac.lower() == 'auto':
722  # Use the provided values when 'auto' is required.
723  extendlength[0] = automin
724  extendlength[1] = automax
725  else:
726  # Any other string is invalid.
727  raise ValueError('invalid value for extendfrac')
728  elif frac is not None:
729  try:
730  # Try to set min and max extension fractions directly.
731  extendlength[:] = frac
732  # If frac is a sequence contaning None then NaN may
733  # be encountered. This is an error.
734  if np.isnan(extendlength).any():
735  raise ValueError()
736  except (TypeError, ValueError):
737  # Raise an error on encountering an invalid value for frac.
738  raise ValueError('invalid value for extendfrac')
739  return extendlength
740 
741  def _uniform_y(self, N):
742  '''
743  Return colorbar data coordinates for *N* uniformly
744  spaced boundaries, plus ends if required.
745  '''
746  if self.extend == 'neither':
747  y = np.linspace(0, 1, N)
748  else:
749  automin = automax = 1. / (N - 1.)
750  extendlength = self._get_extension_lengths(self.extendfrac,
751  automin, automax,
752  default=0.05)
753  if self.extend == 'both':
754  y = np.zeros(N + 2, 'd')
755  y[0] = 0. - extendlength[0]
756  y[-1] = 1. + extendlength[1]
757  elif self.extend == 'min':
758  y = np.zeros(N + 1, 'd')
759  y[0] = 0. - extendlength[0]
760  else:
761  y = np.zeros(N + 1, 'd')
762  y[-1] = 1. + extendlength[1]
763  y[self._inside] = np.linspace(0, 1, N)
764  return y
765 
766  def _proportional_y(self):
767  '''
768  Return colorbar data coordinates for the boundaries of
769  a proportional colorbar.
770  '''
771  if isinstance(self.norm, colors.BoundaryNorm):
772  y = (self._boundaries - self._boundaries[0])
773  y = y / (self._boundaries[-1] - self._boundaries[0])
774  else:
775  y = self.norm(self._boundaries.copy())
776  if self.extend == 'min':
777  # Exclude leftmost interval of y.
778  clen = y[-1] - y[1]
779  automin = (y[2] - y[1]) / clen
780  automax = (y[-1] - y[-2]) / clen
781  elif self.extend == 'max':
782  # Exclude rightmost interval in y.
783  clen = y[-2] - y[0]
784  automin = (y[1] - y[0]) / clen
785  automax = (y[-2] - y[-3]) / clen
786  else:
787  # Exclude leftmost and rightmost intervals in y.
788  clen = y[-2] - y[1]
789  automin = (y[2] - y[1]) / clen
790  automax = (y[-2] - y[-3]) / clen
791  extendlength = self._get_extension_lengths(self.extendfrac,
792  automin, automax,
793  default=0.05)
794  if self.extend in ('both', 'min'):
795  y[0] = 0. - extendlength[0]
796  if self.extend in ('both', 'max'):
797  y[-1] = 1. + extendlength[1]
798  yi = y[self._inside]
799  norm = colors.Normalize(yi[0], yi[-1])
800  y[self._inside] = norm(yi)
801  return y
802 
803  def _mesh(self):
804  '''
805  Return X,Y, the coordinate arrays for the colorbar pcolormesh.
806  These are suitable for a vertical colorbar; swapping and
807  transposition for a horizontal colorbar are done outside
808  this function.
809  '''
810  x = np.array([0.0, 1.0])
811  if self.spacing == 'uniform':
812  y = self._uniform_y(self._central_N())
813  else:
814  y = self._proportional_y()
815  self._y = y
816  X, Y = np.meshgrid(x, y)
817  if self._extend_lower() and not self.extendrect:
818  X[0, :] = 0.5
819  if self._extend_upper() and not self.extendrect:
820  X[-1, :] = 0.5
821  return X, Y
822 
823  def _locate(self, x):
824  '''
825  Given a set of color data values, return their
826  corresponding colorbar data coordinates.
827  '''
828  if isinstance(self.norm, (colors.NoNorm, colors.BoundaryNorm)):
829  b = self._boundaries
830  xn = x
831  else:
832  # Do calculations using normalized coordinates so
833  # as to make the interpolation more accurate.
834  b = self.norm(self._boundaries, clip=False).filled()
835  xn = self.norm(x, clip=False).filled()
836 
837  # The rest is linear interpolation with extrapolation at ends.
838  ii = np.searchsorted(b, xn)
839  i0 = ii - 1
840  itop = (ii == len(b))
841  ibot = (ii == 0)
842  i0[itop] -= 1
843  ii[itop] -= 1
844  i0[ibot] += 1
845  ii[ibot] += 1
846 
847  db = np.take(b, ii) - np.take(b, i0)
848  y = self._y
849  dy = np.take(y, ii) - np.take(y, i0)
850  z = np.take(y, i0) + (xn - np.take(b, i0)) * dy / db
851  return z
852 
853  def set_alpha(self, alpha):
854  self.alpha = alpha
855 
856  def remove(self):
857  """
858  Remove this colorbar from the figure
859  """
860 
861  fig = self.ax.figure
862  fig.delaxes(self.ax)
863 
864 
866  """
867  This class connects a :class:`ColorbarBase` to a
868  :class:`~matplotlib.cm.ScalarMappable` such as a
869  :class:`~matplotlib.image.AxesImage` generated via
870  :meth:`~matplotlib.axes.Axes.imshow`.
871 
872  It is not intended to be instantiated directly; instead,
873  use :meth:`~matplotlib.figure.Figure.colorbar` or
874  :func:`~matplotlib.pyplot.colorbar` to make your colorbar.
875 
876  """
877  def __init__(self, ax, mappable, **kw):
878  # Ensure the given mappable's norm has appropriate vmin and vmax set
879  # even if mappable.draw has not yet been called.
880  mappable.autoscale_None()
881 
882  self.mappable = mappable
883  kw['cmap'] = cmap = mappable.cmap
884  kw['norm'] = norm = mappable.norm
885 
886  if isinstance(mappable, contour.ContourSet):
887  CS = mappable
888  kw['alpha'] = mappable.get_alpha()
889  kw['boundaries'] = CS._levels
890  kw['values'] = CS.cvalues
891  kw['extend'] = CS.extend
892  #kw['ticks'] = CS._levels
893  kw.setdefault('ticks', ticker.FixedLocator(CS.levels, nbins=10))
894  kw['filled'] = CS.filled
895  ColorbarBase.__init__(self, ax, **kw)
896  if not CS.filled:
897  self.add_lines(CS)
898  else:
899  if getattr(cmap, 'colorbar_extend', False) is not False:
900  kw.setdefault('extend', cmap.colorbar_extend)
901 
902  if isinstance(mappable, martist.Artist):
903  kw['alpha'] = mappable.get_alpha()
904 
905  ColorbarBase.__init__(self, ax, **kw)
906 
907  def on_mappable_changed(self, mappable):
908  """
909  Updates this colorbar to match the mappable's properties.
910 
911  Typically this is automatically registered as an event handler
912  by :func:`colorbar_factory` and should not be called manually.
913 
914  """
915  self.set_cmap(mappable.get_cmap())
916  self.set_clim(mappable.get_clim())
917  self.update_normal(mappable)
918 
919  def add_lines(self, CS, erase=True):
920  '''
921  Add the lines from a non-filled
922  :class:`~matplotlib.contour.ContourSet` to the colorbar.
923 
924  Set *erase* to False if these lines should be added to
925  any pre-existing lines.
926  '''
927  if not isinstance(CS, contour.ContourSet) or CS.filled:
928  raise ValueError('add_lines is only for a ContourSet of lines')
929  tcolors = [c[0] for c in CS.tcolors]
930  tlinewidths = [t[0] for t in CS.tlinewidths]
931  # The following was an attempt to get the colorbar lines
932  # to follow subsequent changes in the contour lines,
933  # but more work is needed: specifically, a careful
934  # look at event sequences, and at how
935  # to make one object track another automatically.
936  #tcolors = [col.get_colors()[0] for col in CS.collections]
937  #tlinewidths = [col.get_linewidth()[0] for lw in CS.collections]
938  #print 'tlinewidths:', tlinewidths
939  ColorbarBase.add_lines(self, CS.levels, tcolors, tlinewidths,
940  erase=erase)
941 
942  def update_normal(self, mappable):
943  '''
944  update solid, lines, etc. Unlike update_bruteforce, it does
945  not clear the axes. This is meant to be called when the image
946  or contour plot to which this colorbar belongs is changed.
947  '''
948  self.draw_all()
949  if isinstance(self.mappable, contour.ContourSet):
950  CS = self.mappable
951  if not CS.filled:
952  self.add_lines(CS)
953  self.stale = True
954 
955  def update_bruteforce(self, mappable):
956  '''
957  Destroy and rebuild the colorbar. This is
958  intended to become obsolete, and will probably be
959  deprecated and then removed. It is not called when
960  the pyplot.colorbar function or the Figure.colorbar
961  method are used to create the colorbar.
962 
963  '''
964  # We are using an ugly brute-force method: clearing and
965  # redrawing the whole thing. The problem is that if any
966  # properties have been changed by methods other than the
967  # colorbar methods, those changes will be lost.
968  self.ax.cla()
969  # clearing the axes will delete outline, patch, solids, and lines:
970  self.outline = None
971  self.patch = None
972  self.solids = None
973  self.lines = list()
974  self.dividers = None
975  self.set_alpha(mappable.get_alpha())
976  self.cmap = mappable.cmap
977  self.norm = mappable.norm
978  self.config_axis()
979  self.draw_all()
980  if isinstance(self.mappable, contour.ContourSet):
981  CS = self.mappable
982  if not CS.filled:
983  self.add_lines(CS)
984  #if self.lines is not None:
985  # tcolors = [c[0] for c in CS.tcolors]
986  # self.lines.set_color(tcolors)
987  #Fixme? Recalculate boundaries, ticks if vmin, vmax have changed.
988  #Fixme: Some refactoring may be needed; we should not
989  # be recalculating everything if there was a simple alpha
990  # change.
991 
992  def remove(self):
993  """
994  Remove this colorbar from the figure. If the colorbar was created with
995  ``use_gridspec=True`` then restore the gridspec to its previous value.
996  """
997 
998  ColorbarBase.remove(self)
999  self.mappable.callbacksSM.disconnect(self.mappable.colorbar_cid)
1000  self.mappable.colorbar = None
1001  self.mappable.colorbar_cid = None
1002 
1003  try:
1004  ax = self.mappable.axes
1005  except AttributeError:
1006  return
1007 
1008  try:
1009  gs = ax.get_subplotspec().get_gridspec()
1010  subplotspec = gs.get_topmost_subplotspec()
1011  except AttributeError:
1012  # use_gridspec was False
1013  pos = ax.get_position(original=True)
1014  ax.set_position(pos)
1015  else:
1016  # use_gridspec was True
1017  ax.set_subplotspec(subplotspec)
1018 
1019 
1020 @docstring.Substitution(make_axes_kw_doc)
1021 def make_axes(parents, location=None, orientation=None, fraction=0.15,
1022  shrink=1.0, aspect=20, **kw):
1023  '''
1024  Resize and reposition parent axes, and return a child
1025  axes suitable for a colorbar::
1026 
1027  cax, kw = make_axes(parent, **kw)
1028 
1029  Keyword arguments may include the following (with defaults):
1030 
1031  location : [None|'left'|'right'|'top'|'bottom']
1032  The position, relative to **parents**, where the colorbar axes
1033  should be created. If None, the value will either come from the
1034  given ``orientation``, else it will default to 'right'.
1035 
1036  orientation : [None|'vertical'|'horizontal']
1037  The orientation of the colorbar. Typically, this keyword shouldn't
1038  be used, as it can be derived from the ``location`` keyword.
1039 
1040  %s
1041 
1042  Returns (cax, kw), the child axes and the reduced kw dictionary to be
1043  passed when creating the colorbar instance.
1044  '''
1045  locations = ["left", "right", "top", "bottom"]
1046  if orientation is not None and location is not None:
1047  msg = ('position and orientation are mutually exclusive. '
1048  'Consider setting the position to any of '
1049  '{0}'.format(', '.join(locations)))
1050  raise TypeError(msg)
1051 
1052  # provide a default location
1053  if location is None and orientation is None:
1054  location = 'right'
1055 
1056  # allow the user to not specify the location by specifying the
1057  # orientation instead
1058  if location is None:
1059  location = 'right' if orientation == 'vertical' else 'bottom'
1060 
1061  if location not in locations:
1062  raise ValueError('Invalid colorbar location. Must be one '
1063  'of %s' % ', '.join(locations))
1064 
1065  default_location_settings = {'left': {'anchor': (1.0, 0.5),
1066  'panchor': (0.0, 0.5),
1067  'pad': 0.10,
1068  'orientation': 'vertical'},
1069  'right': {'anchor': (0.0, 0.5),
1070  'panchor': (1.0, 0.5),
1071  'pad': 0.05,
1072  'orientation': 'vertical'},
1073  'top': {'anchor': (0.5, 0.0),
1074  'panchor': (0.5, 1.0),
1075  'pad': 0.05,
1076  'orientation': 'horizontal'},
1077  'bottom': {'anchor': (0.5, 1.0),
1078  'panchor': (0.5, 0.0),
1079  'pad': 0.15, # backwards compat
1080  'orientation': 'horizontal'},
1081  }
1082 
1083  loc_settings = default_location_settings[location]
1084 
1085  # put appropriate values into the kw dict for passing back to
1086  # the Colorbar class
1087  kw['orientation'] = loc_settings['orientation']
1088  kw['ticklocation'] = location
1089 
1090  anchor = kw.pop('anchor', loc_settings['anchor'])
1091  parent_anchor = kw.pop('panchor', loc_settings['panchor'])
1092  pad = kw.pop('pad', loc_settings['pad'])
1093 
1094  # turn parents into a list if it is not already
1095  if not isinstance(parents, (list, tuple)):
1096  parents = [parents]
1097 
1098  fig = parents[0].get_figure()
1099  if not all(fig is ax.get_figure() for ax in parents):
1100  raise ValueError('Unable to create a colorbar axes as not all '
1101  'parents share the same figure.')
1102 
1103  # take a bounding box around all of the given axes
1104  parents_bbox = mtrans.Bbox.union([ax.get_position(original=True).frozen()
1105  for ax in parents])
1106 
1107  pb = parents_bbox
1108  if location in ('left', 'right'):
1109  if location == 'left':
1110  pbcb, _, pb1 = pb.splitx(fraction, fraction + pad)
1111  else:
1112  pb1, _, pbcb = pb.splitx(1 - fraction - pad, 1 - fraction)
1113  pbcb = pbcb.shrunk(1.0, shrink).anchored(anchor, pbcb)
1114  else:
1115  if location == 'bottom':
1116  pbcb, _, pb1 = pb.splity(fraction, fraction + pad)
1117  else:
1118  pb1, _, pbcb = pb.splity(1 - fraction - pad, 1 - fraction)
1119  pbcb = pbcb.shrunk(shrink, 1.0).anchored(anchor, pbcb)
1120 
1121  # define the aspect ratio in terms of y's per x rather than x's per y
1122  aspect = 1.0 / aspect
1123 
1124  # define a transform which takes us from old axes coordinates to
1125  # new axes coordinates
1126  shrinking_trans = mtrans.BboxTransform(parents_bbox, pb1)
1127 
1128  # transform each of the axes in parents using the new transform
1129  for ax in parents:
1130  new_posn = shrinking_trans.transform(ax.get_position())
1131  new_posn = mtrans.Bbox(new_posn)
1132  ax.set_position(new_posn)
1133  if parent_anchor is not False:
1134  ax.set_anchor(parent_anchor)
1135 
1136  cax = fig.add_axes(pbcb)
1137  cax.set_aspect(aspect, anchor=anchor, adjustable='box')
1138  return cax, kw
1139 
1140 
1141 @docstring.Substitution(make_axes_kw_doc)
1142 def make_axes_gridspec(parent, **kw):
1143  '''
1144  Resize and reposition a parent axes, and return a child axes
1145  suitable for a colorbar. This function is similar to
1146  make_axes. Prmary differences are
1147 
1148  * *make_axes_gridspec* only handles the *orientation* keyword
1149  and cannot handle the "location" keyword.
1150 
1151  * *make_axes_gridspec* should only be used with a subplot parent.
1152 
1153  * *make_axes* creates an instance of Axes. *make_axes_gridspec*
1154  creates an instance of Subplot.
1155 
1156  * *make_axes* updates the position of the
1157  parent. *make_axes_gridspec* replaces the grid_spec attribute
1158  of the parent with a new one.
1159 
1160  While this function is meant to be compatible with *make_axes*,
1161  there could be some minor differences.::
1162 
1163  cax, kw = make_axes_gridspec(parent, **kw)
1164 
1165  Keyword arguments may include the following (with defaults):
1166 
1167  *orientation*
1168  'vertical' or 'horizontal'
1169 
1170  %s
1171 
1172  All but the first of these are stripped from the input kw set.
1173 
1174  Returns (cax, kw), the child axes and the reduced kw dictionary to be
1175  passed when creating the colorbar instance.
1176  '''
1177 
1178  orientation = kw.setdefault('orientation', 'vertical')
1179  kw['ticklocation'] = 'auto'
1180 
1181  fraction = kw.pop('fraction', 0.15)
1182  shrink = kw.pop('shrink', 1.0)
1183  aspect = kw.pop('aspect', 20)
1184 
1185  x1 = 1.0 - fraction
1186 
1187  # for shrinking
1188  pad_s = (1. - shrink) * 0.5
1189  wh_ratios = [pad_s, shrink, pad_s]
1190 
1191  gs_from_subplotspec = gridspec.GridSpecFromSubplotSpec
1192  if orientation == 'vertical':
1193  pad = kw.pop('pad', 0.05)
1194  wh_space = 2 * pad / (1 - pad)
1195 
1196  gs = gs_from_subplotspec(1, 2,
1197  subplot_spec=parent.get_subplotspec(),
1198  wspace=wh_space,
1199  width_ratios=[x1 - pad, fraction]
1200  )
1201 
1202  gs2 = gs_from_subplotspec(3, 1,
1203  subplot_spec=gs[1],
1204  hspace=0.,
1205  height_ratios=wh_ratios,
1206  )
1207 
1208  anchor = (0.0, 0.5)
1209  panchor = (1.0, 0.5)
1210  else:
1211  pad = kw.pop('pad', 0.15)
1212  wh_space = 2 * pad / (1 - pad)
1213 
1214  gs = gs_from_subplotspec(2, 1,
1215  subplot_spec=parent.get_subplotspec(),
1216  hspace=wh_space,
1217  height_ratios=[x1 - pad, fraction]
1218  )
1219 
1220  gs2 = gs_from_subplotspec(1, 3,
1221  subplot_spec=gs[1],
1222  wspace=0.,
1223  width_ratios=wh_ratios,
1224  )
1225 
1226  aspect = 1.0 / aspect
1227  anchor = (0.5, 1.0)
1228  panchor = (0.5, 0.0)
1229 
1230  parent.set_subplotspec(gs[0])
1231  parent.update_params()
1232  parent.set_position(parent.figbox)
1233  parent.set_anchor(panchor)
1234 
1235  fig = parent.get_figure()
1236  cax = fig.add_subplot(gs2[1])
1237  cax.set_aspect(aspect, anchor=anchor, adjustable='box')
1238  return cax, kw
1239 
1240 
1242  """
1243  A Colorbar which is created using :class:`~matplotlib.patches.Patch`
1244  rather than the default :func:`~matplotlib.axes.pcolor`.
1245 
1246  It uses a list of Patch instances instead of a
1247  :class:`~matplotlib.collections.PatchCollection` because the
1248  latter does not allow the hatch pattern to vary among the
1249  members of the collection.
1250  """
1251  def __init__(self, ax, mappable, **kw):
1252  # we do not want to override the behaviour of solids
1253  # so add a new attribute which will be a list of the
1254  # colored patches in the colorbar
1255  self.solids_patches = []
1256  Colorbar.__init__(self, ax, mappable, **kw)
1257 
1258  def _add_solids(self, X, Y, C):
1259  """
1260  Draw the colors using :class:`~matplotlib.patches.Patch`;
1261  optionally add separators.
1262  """
1263  # Save, set, and restore hold state to keep pcolor from
1264  # clearing the axes. Ordinarily this will not be needed,
1265  # since the axes object should already have hold set.
1266  _hold = self.ax.ishold()
1267  self.ax.hold(True)
1268 
1269  kw = {'alpha': self.alpha, }
1270 
1271  n_segments = len(C)
1272 
1273  # ensure there are sufficent hatches
1274  hatches = self.mappable.hatches * n_segments
1275 
1276  patches = []
1277  for i in xrange(len(X) - 1):
1278  val = C[i][0]
1279  hatch = hatches[i]
1280 
1281  xy = np.array([[X[i][0], Y[i][0]],
1282  [X[i][1], Y[i][0]],
1283  [X[i + 1][1], Y[i + 1][0]],
1284  [X[i + 1][0], Y[i + 1][1]]])
1285 
1286  if self.orientation == 'horizontal':
1287  # if horizontal swap the xs and ys
1288  xy = xy[..., ::-1]
1289 
1290  patch = mpatches.PathPatch(mpath.Path(xy),
1291  facecolor=self.cmap(self.norm(val)),
1292  hatch=hatch, linewidth=0,
1293  antialiased=False, **kw)
1294  self.ax.add_patch(patch)
1295  patches.append(patch)
1296 
1297  if self.solids_patches:
1298  for solid in self.solids_patches:
1299  solid.remove()
1300 
1301  self.solids_patches = patches
1302 
1303  if self.dividers is not None:
1304  self.dividers.remove()
1305  self.dividers = None
1306 
1307  if self.drawedges:
1308  self.dividers = collections.LineCollection(self._edges(X, Y),
1309  colors=(mpl.rcParams['axes.edgecolor'],),
1310  linewidths=(0.5 * mpl.rcParams['axes.linewidth'],))
1311  self.ax.add_collection(self.dividers)
1312 
1313  self.ax.hold(_hold)
1314 
1315 
1316 def colorbar_factory(cax, mappable, **kwargs):
1317  """
1318  Creates a colorbar on the given axes for the given mappable.
1319 
1320  Typically, for automatic colorbar placement given only a mappable use
1321  :meth:`~matplotlib.figure.Figure.colorbar`.
1322 
1323  """
1324  # if the given mappable is a contourset with any hatching, use
1325  # ColorbarPatch else use Colorbar
1326  if (isinstance(mappable, contour.ContourSet)
1327  and any([hatch is not None for hatch in mappable.hatches])):
1328  cb = ColorbarPatch(cax, mappable, **kwargs)
1329  else:
1330  cb = Colorbar(cax, mappable, **kwargs)
1331 
1332  cid = mappable.callbacksSM.connect('changed', cb.on_mappable_changed)
1333  mappable.colorbar = cb
1334  mappable.colorbar_cid = cid
1335 
1336  return cb
def __init__(self, ax, cmap=None, norm=None, alpha=None, values=None, boundaries=None, orientation='vertical', ticklocation='auto', extend='neither', spacing='uniform', ticks=None, format=None, drawedges=False, filled=True, extendfrac=None, extendrect=False, label='')
Definition: colorbar.py:277
def add_lines(self, levels, colors, linewidths, erase=True)
Definition: colorbar.py:525
def update_normal(self, mappable)
Definition: colorbar.py:942
def on_mappable_changed(self, mappable)
Definition: colorbar.py:907
def set_ticklabels(self, ticklabels, update_ticks=True)
Definition: colorbar.py:399
def update_bruteforce(self, mappable)
Definition: colorbar.py:955
def _add_solids(self, X, Y, C)
Definition: colorbar.py:488
def add_lines(self, CS, erase=True)
Definition: colorbar.py:919
def _process_values(self, b=None)
Definition: colorbar.py:607
def pcolormesh(args, kwargs)
Definition: pyplot.py:3084
def copy(source)
Definition: docstring.py:100
def make_axes_gridspec(parent, kw)
Definition: colorbar.py:1142
def _get_extension_lengths(self, frac, automin, automax, default=0.05)
Definition: colorbar.py:712
def set_ticks(self, ticks, update_ticks=True)
Definition: colorbar.py:384
def set_cmap(self, cmap)
Definition: cm.py:300
def set_label(self, label, kw)
Definition: colorbar.py:453
def __init__(self, ax, mappable, kw)
Definition: colorbar.py:1251
def set_clim(self, vmin=None, vmax=None)
Definition: cm.py:282
def __init__(self, ax, mappable, kw)
Definition: colorbar.py:877
def make_axes(parents, location=None, orientation=None, fraction=0.15, shrink=1.0, aspect=20, kw)
Definition: colorbar.py:1022
def colorbar_factory(cax, mappable, kwargs)
Definition: colorbar.py:1316
def set_alpha(self, alpha)
Definition: colorbar.py:853
def hold(b=None)
Figure and Axes hybrid ##.
Definition: pyplot.py:773
def _config_axes(self, X, Y)
Definition: colorbar.py:413