-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwind_rose.py
More file actions
34 lines (28 loc) · 1.13 KB
/
Copy pathwind_rose.py
File metadata and controls
34 lines (28 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import seaborn
def wind_rose(rosedata, wind_dirs, palette=None):
if palette is None:
palette = seaborn.color_palette('inferno', n_colors=rosedata.shape[1])
bar_dir, bar_width = _convert_dir(wind_dirs)
fig, ax = pyplot.subplots(figsize=(10, 10), subplot_kw=dict(polar=True))
ax.set_theta_direction('clockwise')
ax.set_theta_zero_location('N')
for n, (c1, c2) in enumerate(zip(rosedata.columns[:-1], rosedata.columns[1:])):
if n == 0:
# first column only
ax.bar(bar_dir, rosedata[c1].values,
width=bar_width,
color=palette[0],
edgecolor='none',
label=c1,
linewidth=0)
# all other columns
ax.bar(bar_dir, rosedata[c2].values,
width=bar_width,
bottom=rosedata.cumsum(axis=1)[c1].values,
color=palette[n+1],
edgecolor='none',
label=c2,
linewidth=0)
leg = ax.legend(loc=(0.75, 0.95), ncol=2)
xtl = ax.set_xticklabels(['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW'])
return fig