Skip to content Skip to sidebar Skip to footer

Contourf() Plots White Space Over Finite Data

I'm attempting to plot a 3D chart using matplotlib.pyplot.contourf() with the following program: import numpy as np import matplotlib.pyplot as plt import scipy # calculates Fast

Solution 1:

You can fix this problem by adding option extend='both'. Eg. C = plt.contourf(P,Altitude,Fourier,100,cmap='jet',extend='both')

Ref: https://matplotlib.org/examples/pylab_examples/contourf_demo.html

Solution 2:

In the line plt.contourf(P,Altitude,Fourier,100,cmap='jet') you are taking 100 automatically chosen levels for the contour plot. "Automatic" in this case does not guarantee that those levels include all data.

If you want to make sure they all data is included you may define you own levels to use

plt.contourf(x, y, Z, np.linspace(Z.min(), Z.max(), 100))

Post a Comment for "Contourf() Plots White Space Over Finite Data"