title: How to plot 2D gradient(rainbow) by using matplotlib?
body: <p>I try to plot stress of beam by using matplotlib library.</p>
  
  <p>I have calculated by using formulas and plot it for an example:</p>
  
  <p><a href="https://i.stack.imgur.com/YNh4t.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YNh4t.png" alt="Figure 1: Example of before and after of finite element of beam"></a></p>
  
  <p>As Figure 1, you will see that the green beam has more stress at element 3 and also element 8 Thus if i fill the color by rainbow gradient,The over all of blue beam will be same color but The green beam will have different color by the element 3 and 8 will be going to red side more than others.</p>
  
  <p><a href="https://i.stack.imgur.com/okktg.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/okktg.jpg" alt="example of stress plot"></a></p>
  
  <p>Here is some of my code.
  import matplotlib.pyplot as plt
      import matplotlib as mpl</p>
  
  <pre><code>node_coordinate = {1: [0.0, 1.0], 2: [0.0, 0.0], 3: [4.018905, 0.87781], 4: [3.978008, -0.1229], 5: [1.983549, -0.038322], 6: [2.013683, 0.958586], 7: [3.018193, 0.922264],
                     8: [2.979695, -0.079299], 9: [1.0070439, 0.989987], 10: [0.9909098, -0.014787999999999999]}
  element_stress = {'1': 0.2572e+01, '2': 0.8214e+00, '3': 0.5689e+01, '4': -0.8214e+00, '5': -0.2572e+01, '6': -0.4292e+01, '7': 0.4292e+01, '8': -0.5689e+01}
  
  cmap = mpl.cm.jet
  
  fig = plt.figure(figsize=(8, 2))
  ax1 = fig.add_axes([0.05, 0.80, 0.9, 0.15])
  ax2 = fig.add_axes([0.05, 0.4, 0.9, 0.15])
  # ax1 = fig.add_axes([0.2572e+01, 0.8214e+00, 0.5689e+01, -0.8214e+00, -0.2572e+01, -0.4292e+01, 0.4292e+01, -0.5689e+01])
  norm = mpl.colors.Normalize(vmin=0, vmax=1)
  cb1 = mpl.colorbar.ColorbarBase(ax1, cmap=cmap, norm=norm, orientation='vertical')
  cb2 = mpl.colorbar.ColorbarBase(ax2, cmap=cmap, norm=norm, orientation='horizontal')
  plt.show()
  </code></pre>
  
  <p>You will see that i know all of node co-ordinate and also element's stress value.</p>
  
  <p>p.s. Sorry for my grammar, I'm not native.</p>
  
  <p>Thank you. For suggestion.</p>