code: """
  ============================
  Contourf and log color scale
  ============================
  
  Demonstrate use of a log color scale in contourf
  """
  
  import matplotlib.pyplot as plt
  import numpy as np
  from numpy import ma
  from matplotlib import ticker, cm
  
  N = 100
  x = np.linspace(-3.0, 3.0, N)
  y = np.linspace(-2.0, 2.0, N)
  
  X, Y = np.meshgrid(x, y)
  
  # A low hump with a spike coming out.
  # Needs to have z/colour axis on a log scale so we see both hump and spike.
  # linear scale only shows the spike.
  Z1 = np.exp(-(X)**2 - (Y)**2)
  Z2 = np.exp(-(X * 10)**2 - (Y * 10)**2)
  z = Z1 + 50 * Z2
  
  # Put in some negative values (lower left corner) to cause trouble with logs:
  z[:5, :5] = -1
  
  # The following is not strictly essential, but it will eliminate
  # a warning.  Comment it out to see the warning.
  z = ma.masked_where(z <= 0, z)
  
  
  # Automatic selection of levels works; setting the
  # log locator tells contourf to use a log scale:
  fig, ax = plt.subplots()
  cs = ax.contourf(X, Y, z, locator=ticker.LogLocator(), cmap=cm.PuBu_r)
  
  # Alternatively, you can manually set the levels
  # and the norm:
  # lev_exp = np.arange(np.floor(np.log10(z.min())-1),
  #                    np.ceil(np.log10(z.max())+1))
  # levs = np.power(10, lev_exp)
  # cs = ax.contourf(X, Y, z, levs, norm=colors.LogNorm())
  
  cbar = fig.colorbar(cs)
  
  plt.show()
  
  #############################################################################
  #
  # ------------
  #
  # References
  # """"""""""
  #
  # The use of the following functions, methods and classes is shown
  # in this example:
  
  import matplotlib
  matplotlib.axes.Axes.contourf
  matplotlib.pyplot.contourf
  matplotlib.figure.Figure.colorbar
  matplotlib.pyplot.colorbar
  matplotlib.axes.Axes.legend
  matplotlib.pyplot.legend
  matplotlib.ticker.LogLocator
   """
  ======================
  Zoom region inset axes
  ======================
  
  Example of an inset axes and a rectangle showing where the zoom is located.
  
  """
  
  import matplotlib.pyplot as plt
  import numpy as np
  
  
  def get_demo_image():
      from matplotlib.cbook import get_sample_data
      import numpy as np
      f = get_sample_data("axes_grid/bivariate_normal.npy", asfileobj=False)
      z = np.load(f)
      # z is a numpy array of 15x15
      return z, (-3, 4, -4, 3)
  
  fig, ax = plt.subplots(figsize=[5, 4])
  
  # make data
  Z, extent = get_demo_image()
  Z2 = np.zeros([150, 150], dtype="d")
  ny, nx = Z.shape
  Z2[30:30 + ny, 30:30 + nx] = Z
  
  ax.imshow(Z2, extent=extent, interpolation="nearest",
            origin="lower")
  
  # inset axes....
  axins = ax.inset_axes([0.5, 0.5, 0.47, 0.47])
  axins.imshow(Z2, extent=extent, interpolation="nearest",
            origin="lower")
  # sub region of the original image
  x1, x2, y1, y2 = -1.5, -0.9, -2.5, -1.9
  axins.set_xlim(x1, x2)
  axins.set_ylim(y1, y2)
  axins.set_xticklabels('')
  axins.set_yticklabels('')
  
  ax.indicate_inset_zoom(axins)
  
  plt.show()
  
  #############################################################################
  #
  # ------------
  #
  # References
  # """"""""""
  #
  # The use of the following functions and methods is shown in this example:
  
  import matplotlib
  matplotlib.axes.Axes.inset_axes
  matplotlib.axes.Axes.indicate_inset_zoom
  matplotlib.axes.Axes.imshow
  
apis: matplotlib.ticker.LogLocator numpy.ma.masked_where matplotlib.pyplot.subplots numpy.exp matplotlib.pyplot.show numpy.meshgrid numpy.linspace
apis: numpy.load numpy.zeros matplotlib.cbook.get_sample_data matplotlib.pyplot.subplots matplotlib.pyplot.show