Is it possible to display 2D array as polar plot using Matplotlib imshow()?

前端 未结 1 1211
感动是毒
感动是毒 2021-02-20 09:51

I\'m new to matplotlib (and am loving it!), but am getting frustrated. I have a polar grid represented as a a 2D array. (rows are radial sections, columns are azimuthal sections

1条回答
  •  南笙
    南笙 (楼主)
    2021-02-20 10:10

    After some research I discovered the pcolormesh() function, which has proven to be significantly faster than using pcolor() and comparable to the speed of imshow().

    Here is my solution:

    import matplotlib.pyplot as plt
    import numpy as np
    
    #...some data processing
    
    theta,rad = np.meshgrid(used_theta, used_rad) #rectangular plot of polar data
    X = theta
    Y = rad
    
    fig = plt.figure()
    ax = fig.add_subplot(111)
    ax.pcolormesh(X, Y, data2D) #X,Y & data2D must all be same dimensions
    plt.show()
    

    0 讨论(0)
提交回复
热议问题