Skip to content

Commit

Permalink
Add option to specify radius steps
Browse files Browse the repository at this point in the history
Allow user to specify the steps at which radius circles and labels will be drawn as, and also sets the rmax value to be a multiple of rstep. So for example a call to plot_windrose(t, r, kind='bar', normed=True, blowto=False, rstep=5) will generate radii/labels of 5,10,15 etc. I don't know if this the best way to achieve this (that is should this be part of WindroseAxes constructor or just passed around in kwargs?), it just worked for my use case.
  • Loading branch information
sspagnol committed Sep 16, 2021
1 parent 962dbf4 commit b12e291
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions windrose/windrose.py
Expand Up @@ -82,6 +82,7 @@ def __init__(self, *args, **kwargs):
PolarAxes.__init__(self, *args, **kwargs)
self.set_aspect("equal", adjustable="box", anchor="C")
self.radii_angle = 67.5
self.rstep = None
self.cla()

@staticmethod
Expand Down Expand Up @@ -137,8 +138,13 @@ def set_radii_angle(self, **kwargs):
if angle is None:
angle = self.radii_angle
self.radii_angle = angle
N = 5
rmax = self.get_rmax()
if self.rstep is not None:
rstep = self.rstep
N = np.int_(np.ceil(rmax/rstep))
rmax = N * rstep
else:
N = 5
radii = np.linspace(0, rmax, N + 1)
if rmax % N == 0:
fmt = "%d"
Expand Down Expand Up @@ -346,7 +352,9 @@ def _init_plot(self, direction, var, **kwargs):

normed = kwargs.pop("normed", False)
blowto = kwargs.pop("blowto", False)

rstep = kwargs.pop("rstep", None)
self.rstep = rstep

# Calm condition
calm_limit = kwargs.pop("calm_limit", None)
if calm_limit is not None:
Expand Down

0 comments on commit b12e291

Please sign in to comment.