Search code examples
matplotlibsurf

matplotlib surface plot with hidden zaxis


when I change the viewpoint of plot_surface in matplolib in (90,0), the zaxis is not clear, and it's useless in this plot. I want to generate the image same as matlab as below matlab surf with view (0,90),with contour lines I used matplotlib function imshow can generate matrix image, but there are no lines (similar in contourplot lines)in the image. how can i generate the image with plot_surface in python with a viewpoint of (90,0),bu without zaxis? matplotlib with plot_surface,view(90,0),withou lines and zaxis


Solution

  • You can use contourf from matplotlib:

    import matplotlib.pyplot as plt
    import numpy as np
    
    X, Y = np.meshgrid(range(100), range(100))
    Z = X**2+Y**2
    
    plt.contourf(X, Y, Z, [i for i in np.linspace(Z.min(),Z.max(),30)])
    plt.show()
    

    , which results in:

    Contourf matplotlib