class_docstr: Draw a heatmap plot of a matrix with nice labels and colormaps.
class_docstr_tok: ["Draw","a","heatmap","plot","of","a","matrix","with","nice","labels","and","colormaps","."]
docstr: Use some heuristics to set good defaults for colorbar and range.
docstr_tok: ["Use","some","heuristics","to","set","good","defaults","for","colorbar","and","range","."]
code: def _determine_cmap_params(
      self, plot_data, vmin, vmax, cmap, center, robust
  ):
      """Use some heuristics to set good defaults for colorbar and range."""
  
      # plot_data is a np.ma.array instance
      calc_data = plot_data.astype(float).filled(np.nan)
      if vmin is None:
          if robust:
              vmin = np.nanpercentile(calc_data, 2)
          else:
              vmin = np.nanmin(calc_data)
      if vmax is None:
          if robust:
              vmax = np.nanpercentile(calc_data, 98)
          else:
              vmax = np.nanmax(calc_data)
      self.vmin, self.vmax = vmin, vmax
  
      # Choose default colormaps if not provided
      if cmap is None:
          if center is None:
              self.cmap = cm.rocket
          else:
              self.cmap = cm.icefire
      elif isinstance(cmap, str):
          self.cmap = get_colormap(cmap)
      elif isinstance(cmap, list):
          self.cmap = mpl.colors.ListedColormap(cmap)
      else:
          self.cmap = cmap
  
      # Recenter a divergent colormap
      if center is not None:
          # Copy bad values
          # in mpl<3.2 only masked values are honored with "bad" color spec
          # (see https://github.com/matplotlib/matplotlib/pull/14257)
          bad = self.cmap(np.ma.masked_invalid([np.nan]))[0]
  
          # under/over values are set for sure when cmap extremes
          # do not map to the same color as +-inf
          under = self.cmap(-np.inf)
          over = self.cmap(np.inf)
          under_set = under != self.cmap(0)
          over_set = over != self.cmap(self.cmap.N - 1)
  
          vrange = max(vmax - center, center - vmin)
          normlize = mpl.colors.Normalize(
              center - vrange, center + vrange
          )
          cmin, cmax = normlize([vmin, vmax])
          cc = np.linspace(cmin, cmax, 256)
          self.cmap = mpl.colors.ListedColormap(self.cmap(cc))
          self.cmap.set_bad(bad)
          if under_set:
              self.cmap.set_under(under)
          if over_set:
              self.cmap.set_over(over)
  
imports: import warnings
  import matplotlib
  from matplotlib.collections import LineCollection
  import matplotlib.pyplot
  from matplotlib import gridspec
  import numpy
  import pandas
  from .None import cm
  from .axisgrid import Grid
  from ._compat import get_colormap
  from .utils import despine, axis_ticklabels_overlap, relative_luminance, to_utf8, _draw_figure
label_desc: Use image node_id 2 for calling the _HeatMapper obj's underlying member method code with example usage: obj._determine_cmap_params(plot_data, vmin, vmax, cmap, center, robust) without return types