I'm searching to plot multiple graphs (here is 2) from colormap or contourf functions with different axis X, Y and data Z in the same figure. However I only want to display the maximum of each data with a single color bar for all of the graphs.
In this example, I create a single figure in which I add each graph but the second graph overwrite the first one, regardless of whether its data are lower or higher.
import matplotlib.pyplot as plt
import numpy as np
a = [1,0.25]
fig = plt.figure(1)
ax = fig.gca()
for i in range(2):
x = np.linspace(-3, 3, 51)
y = np.linspace(-2*a[i], 2*a[i], 41)
X, Y = np.meshgrid(x, y)
if i == 0:
Z = (1 - X/2 + X**5 + Y**3) * np.exp(-X**2 - Y**2)
else:
Z = 0.5*np.ones((41,51))
graph = ax.contourf(X,Y,Z)
bar = fig.colorbar(graph)
plt.show()
Figure 1 displayed by the code
Here is what I want to display :
Thank you a lot, Tristan