I am trying to make a contour plot using meshgrid with Python. My dependent variable is not a direct function of the two, but I enter the values by hand. Consider the following example code:
import numpy as np
import matplotlib.pyplot as plt
Array1 = np.arange(-5,5,0.5)
Array2 = np.arange(-5,5,0.5)
X, Y = np.meshgrid(Array1, Array2)
Z = np.ones(X.shape)
Z((1,2)) = 3
Z((1,5)) = 8
Z((3,4)) = -3
plt.contour(X, Y, Z, 500)
This creates a contour plot that spans X values between -5 and 5, but Y values only between -5 and -2. Why does this happen, that part of the plot stays blank without contour lines. I expected lines to cover the whole plane, for -5 <X <5 and for -5 < Y < 5.
Thanks.