Reputation: 101
I want to shade the area of the XY plane where Y<18 x^2.
This is my code:
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(-.25, .25, 25)
y = np.linspace(0, 1, 20)
X,Y = np.meshgrid(x, y)
Z = masqarr(1,X, Y)
plt.imshow( (Y< 18*X**2).astype(float) ,
extent=(X.min(),X.max(),Y.min(),Y.max()),origin="lower", cmap="Greys", alpha = 0.3, aspect='auto', interpolation = 'hanning');
However, the output I get produces a plot with plateau as in:
How can I gat a proper smooth plot?
Upvotes: 0
Views: 79
Reputation: 2082
This is a resolution problem, you are defining your axes with too few poitns. I tried this:
import numpy as np
import matplotlib.pyplot as plt
resolution = 200
x = np.linspace(-.25, .25, resolution)
y = np.linspace(0, 1, resolution)
X,Y = np.meshgrid(x, y)
plt.imshow( (Y< 18*X**2).astype(float) ,
extent=(X.min(),X.max(),Y.min(),Y.max()),origin="lower", cmap="Greys", alpha = 0.3, aspect='auto', interpolation = 'hanning');
plt.show()
Upvotes: 1