pythonwindroserose-plot

Plotting a wind rose the Windrose Library


I've got wind data which includes wind speed and wind direction.

However, my wind direction is defined anti-clockwise. Meaning, 45 deg for my data is actually NW.

Is there any chance to change this using Windrose in Python?

I've got the following code to plot the Windrose:

from windrose import WindroseAxes
import matplotlib.pyplot as plt

theta = [0, 60, 120, 180, 240, 300]
speed = [10, 0, 10, 40, 50, 40]

ax = WindroseAxes.from_ax()
ax.bar(theta, speed)
plt.show()

Solution

  • The direction of your windrose is determined by the theta list. If 90° is not on the side you wish, you can convert all theta angles to the opposite and therefore create a mirror of your original image.

    Let's imagine your original code is the following.

    from windrose import WindroseAxes                                                                                                                                                                                                                                                                                                                                                                                                                                                            
    import matplotlib.pyplot as plt                                                                                                                                                                                                                                                                                                                                                                                                                                                              
    
    theta = [0, 90]                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
    speed = [10, 10]                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
    
    ax = WindroseAxes.from_ax()                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
    ax.bar(theta, speed)                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
    plt.show()
    

    And this shows you a graph with a bar on the East, while you want it on the West (or the opposite).

    If you take the opposite angle, you swap the graph. The following code would server your purpose.

    from windrose import WindroseAxes
    import matplotlib.pyplot as plt
    
    theta = [0, 90]
    theta = [360 - x for x in theta] # Take the opposite angle
    speed = [10, 10]
    
    ax = WindroseAxes.from_ax()
    ax.bar(theta, speed)
    plt.show()