Plotting Windrose: making a pollution rose with concentration set to color

后端 未结 1 762
名媛妹妹
名媛妹妹 2021-01-13 19:02

Trying to plot a windrose diagram with speed and direction being plotted and the concentration determining the color. Unfortunately, matplotlib only supports two variables.

1条回答
  •  执念已碎
    2021-01-13 19:20

    The plots shown can be created using a pcolormesh.

    import matplotlib.pyplot as plt
    import numpy as np
    
    theta = np.linspace(0,2*np.pi)
    r = np.linspace(2,15,16)
    
    Theta, R = np.meshgrid(theta, r)
    C = np.sinc(Theta-2)+(5-np.sqrt(R))+np.random.rand(len(r),len(theta))
    C = np.ma.masked_less_equal(C,2)
    
    fig, ax = plt.subplots(subplot_kw={"projection":"polar"})
    
    ax.pcolormesh(Theta, R, C, vmin=2, vmax=5)
    
    plt.show()
    

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