Plot wind speed and direction from u, v components

前端 未结 1 1055
感动是毒
感动是毒 2021-01-24 16:46

I\'m trying to plot the wind speed and direction, but there is an error code that keeps telling me that \"sequence too large; cannot be greater than 32.\" Here is the code that

相关标签:
1条回答
  • 2021-01-24 17:29

    To plot wind U, V use barbs and quiver. Look at the code below:

    import matplotlib.pylab as plt
    import numpy as np
    
    x = np.linspace(-5, 5, 5)
    X, Y = np.meshgrid(x, x)
    d = np.arctan(Y ** 2. - .25 * Y - X)
    U, V = 5 * np.cos(d), np.sin(d)
    # barbs plot
    ax1 = plt.subplot(1, 2, 1)
    ax1.barbs(X, Y, U, V)
    #quiver plot
    ax2 = plt.subplot(1, 2, 2)
    qui = ax2.quiver(X, Y, U, V)
    plt.quiverkey(qui, 0.9, 1.05, 1, '1 m/s',labelpos='E',fontproperties={'weight': 'bold'})
    
    plt.show()
    

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