I am trying to analyze windroses in Python. How can I make all the plots with the same scale? I have a CSV file with wind speed and direction.
Here is my code:
from windrose import WindroseAxes
from matplotlib import pyplot as plt
import matplotlib.cm as cm
from numpy.random import random
from numpy import arange
import pandas as pd
MON=pd.read_csv(r'data.csv')
ws = MON["Ws"].values
wd = MON["Wd"].values
ax = WindroseAxes.from_ax()
ax.bar(wd, ws, normed=True, opening=0.8, edgecolor='white')
ax.set_title('plot2')
ax.set_legend()
Tthe two plots are showing two different legends. I want one fixed legend for two plots.
First plot:
sp.png
Second plot:
In order to have a consistent legend for multiple windrose plots, you can manually add a
bins=
parameter toax.bar
of the windrose. By default, there are 6 bin edges between the minimum and maximum of the given data.Here is an example where the data for the first plot has a range between 0 and 6, while the data for the second plot ranges between 0 and 9: