Note that there are some explanatory texts on larger screens.

plurals
  1. POColorbar for two contour plots
    text
    copied!<p>I have two contour plots but I want the colorbar to apply to both. My code so far is shown. How can I create a single colorbar that can be applied to both plots?</p> <pre><code> import numpy as np import matplotlib.pyplot as plt import matplotlib.tri as tri import scipy, pylab x=[14.86, 14.48, 14.09, 13.70, 13.32, 12.93, 12.54, 12.16, 14.82, 14.43, 14.04, 13.65, 13.26, 12.87, 12.48, 12.09, 14.16, 13.71, 13.26, 12.82, 12.37, 11.92, 11.47, 11.02, 13.48, 12.96, 12.44, 11.93, 11.41, 10.90, 10.38, 9.86, 12.79, 12.21, 11.62, 11.04, 10.45, 9.87, 9.29, 8.70, 12.10, 11.48, 10.85, 10.23, 9.60, 8.98, 8.35, 7.73, 11.72, 11.08, 10.44, 9.79, 9.15, 8.51, 7.87, 7.23] y= [0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 3.17, 3.17, 3.17, 3.17, 3.17, 3.17, 3.17, 3.17, 6.43, 6.43, 6.43, 6.43, 6.43, 6.43, 6.43, 6.43, 9.60, 9.60, 9.60, 9.60, 9.60, 9.60, 9.60, 9.60, 12.77, 12.77, 12.77, 12.77, 12.77, 12.77, 12.77, 12.77, 16.03, 16.03, 16.03, 16.03, 16.03, 16.03, 16.03, 16.03, 19.20, 19.20, 19.20, 19.20, 19.20, 19.20, 19.20, 19.20] z=[80.73, 81.75, 82.44, 82.81, 82.85, 82.57, 81.97, 81.04, 82.75, 83.78, 84.54, 85.01, 85.19, 85.09, 84.71, 84.04, 87.38, 88.11, 88.82, 89.50, 90.14, 90.76, 91.35, 91.91, 91.33, 92.04, 92.84, 93.73, 94.71, 95.79, 96.95, 98.21, 93.24, 94.24, 95.30, 96.41, 97.57, 98.79, 100.06, 101.39, 94.10, 95.35, 96.59, 97.83, 99.06, 100.29, 101.52, 102.74, 94.39, 95.77, 97.11, 98.41, 99.66, 100.86, 102.02, 103.14] z1=[84.18, 84.96, 85.49, 85.77, 85.81, 85.59, 85.13, 84.42, 86.23, 87.02, 87.63, 88.03, 88.25, 88.27, 88.10, 87.73, 91.09, 91.28, 91.64, 92.19, 92.92, 93.82, 94.90, 96.16, 94.83, 94.99, 95.46, 96.23, 97.30, 98.69, 100.37, 102.36, 96.42, 96.90, 97.64, 98.65, 99.91, 101.44, 103.23, 105.28, 97.02, 97.81, 98.79, 99.95, 101.29, 102.82, 104.53, 106.43, 97.16, 98.16, 99.28, 100.51, 101.86, 103.33, 104.91, 106.61] plt.subplot(121) triang = tri.Triangulation(x, y) plt.tricontour(x, y, z, 15, linewidths=0.5, colors='k') plt.tricontourf(x, y, z, 15, cmap=plt.cm.jet) plt.plot(x, y, 'ko', ms=3) plt.xlim(min(x),25) plt.ylim(min(y),25) plt.xlabel('e') plt.ylabel('d') plt.title('title1') plt.subplot(122) triang = tri.Triangulation(x, y) plt.tricontour(x, y, z1, 15, linewidths=0.5, colors='k') plt.tricontourf(x, y, z1, 15, cmap=plt.cm.jet) plt.plot(x, y, 'ko', ms=3) plt.xlim(min(x),25) plt.ylim(min(y),25) plt.xlabel('e') plt.ylabel('d') plt.title('title2') plt.show() </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload