Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

custom scaling of wind rose python

I am trying to compare wind roses in python, but it is difficult because I cannot figure out how to make the same scale across all of the plots. Someone else asked the same question here Custom percentage scale used by windrose.py but it was not answered .

Example code:

from windrose import WindroseAxes
import numpy as np
import matplotlib.pyplot as plt

wind_dir = np.array([30,45,90,43,180])
wind_sd = np.arange(1,wind_dir.shape[0]+1)
bins_range = np.arange(1,6,1) # this sets the legend scale
fig,ax = plt.subplots()
ax = WindroseAxes.from_ax()

bin_range below sets scale of bars, but I need to change the y-axis frequency scale so it can be compared to other wind roses with different data.

ax.bar(wind_dir,wind_sd,normed=True,bins=bins_range) 

this set_ylim does seem to work, but the yaxis ticks do not change

ax.set_ylim(0,50)

this set_ticks line below does not do anything and I do not know why

ax.yaxis.set_ticks(np.arange(0,50,10))

ax.set_legend()
plt.show()
like image 951
pwprnt Avatar asked Jun 12 '18 15:06

pwprnt


1 Answers

from windrose import WindroseAxes
import numpy as np
import matplotlib.pyplot as plt

wind_dir = np.array([30,45,90,43,180])
wind_sd = np.arange(1,wind_dir.shape[0]+1)
bins_range = np.arange(1,6,1) # this sets the legend scale

ax = WindroseAxes.from_ax()
ax.bar(wind_dir,wind_sd,normed=True,bins=bins_range)
ax.set_yticks(np.arange(10, 60, step=10))
ax.set_yticklabels(np.arange(10, 60, step=10))
plt.show()

enter image description here

like image 59
KRKirov Avatar answered Oct 17 '22 08:10

KRKirov