pythonarraysmatrix2dvisualize

2D slope display Python


The question is the following: I have to create a matrix that has values corresponding to the slope inclination. angles between 34 degrees and 28 degrees. I would need to create the matrix and display it in a plot.


Solution

  • Not sure how to create your matrix. Usually you have to compute it or load the data from somewhere, but plotting would look like this:

    import matplotlib.pyplot as plt
    
    N = 11
    # increase if you like your matrix to be larger, i.e. you like to have a finer mesh
    x = np.linspace(0,1,N)
    xx, yy = np.meshgrid(x,x)
    your_matrix = 34*xx*yy
    plt.matshow(your_matrix)
    plt.show()