title: Is it possible to achieve a continuous color gradient with surface plot using matplotlib?
body: <p>I am trying to visualise the pixel intensity of a photo by plotting a 3D graph. In the code below, <code>lab</code> is an image I want to analyse. The code will look at the pixel intensity of every pixels in the image and plot a graph, where the height denotes the pixel intensity.</p>
  <p>Here is a portion of my code:</p>
  <pre><code>import cv2
  import numpy as np
  
  import matplotlib.pyplot as plt
  from mpl_toolkits.mplot3d import Axes3D
  from matplotlib import cm
  
  from skimage import io, color
  import glob
  from PIL import Image
  
  
  plt.figure(dpi=1200)
      ax = plt.axes(projection='3d')
      y = range(lab.shape[0])
      x = range(lab.shape[1])
      X, Y = np.meshgrid(x, y)
  
      ax.view_init(elev=60., azim=60)
  
      thickness = ax.plot_surface(
          X,
          Y,
          lab[:, :, 0],  # change value here to adjust the height
          cmap=cm.coolwarm,
          antialiased=False)
  
      # Add a color bar which maps values to colors.
      fig.colorbar(thickness, shrink=0.5, aspect=5)
  </code></pre>
  <p>It outputs:
  <a href="https://i.stack.imgur.com/d5E75.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/d5E75.jpg" alt="enter image description here" /></a></p>
  <p>As you can see, the colour gradient is not continuous despite the graph having many fine details and slight fluctuations in height which is not represented by the color map.
  Is it possible to achieve a continuous color gradient with surface plot using matplotlib like the image below?
  <a href="https://i.stack.imgur.com/FaKpX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FaKpX.png" alt="enter image description here" /></a></p>
  <p>Thank you.</p>