Skip to content

Commit 834c874

Browse files
authored
ENH: Adding keywords to plot_barbs_from_u_v to better plot up the barbs (#848)
* ENH: Adding keywords to plot_barbs_from_u_v to better plot up the barbs * ENH: bug fix
1 parent 8ac845a commit 834c874

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

act/plotting/timeseriesdisplay.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,8 @@ def plot_barbs_from_u_v(
850850
invert_y_axis=True,
851851
num_barbs_x=20,
852852
num_barbs_y=20,
853+
barb_step_x=None,
854+
barb_step_y=None,
853855
use_var_for_y=None,
854856
**kwargs,
855857
):
@@ -883,6 +885,12 @@ def plot_barbs_from_u_v(
883885
The number of wind barbs to plot in the x axis.
884886
num_barbs_y : int
885887
The number of wind barbs to plot in the y axis.
888+
barb_step_x : int
889+
Step between each wind barb to plot. If set, will override
890+
values given for num_barbs_x
891+
barb_step_y : int
892+
Step between each wind barb to plot. If set, will override
893+
values given for num_barbs_y
886894
cmap : matplotlib.colors.LinearSegmentedColormap
887895
A color map to use with wind barbs. If this is set the plt.barbs
888896
routine will be passed the C parameter scaled as sqrt of sum of the
@@ -919,8 +927,9 @@ def plot_barbs_from_u_v(
919927
v = self._ds[dsname][v_field].values
920928
dim = list(self._ds[dsname][u_field].dims)
921929
xdata = self._ds[dsname][dim[0]].values
922-
num_x = xdata.shape[-1]
923-
barb_step_x = round(num_x / num_barbs_x)
930+
if barb_step_x is None:
931+
num_x = xdata.shape[-1]
932+
barb_step_x = round(num_x / num_barbs_x)
924933
if barb_step_x == 0:
925934
barb_step_x = 1
926935

@@ -937,8 +946,9 @@ def plot_barbs_from_u_v(
937946
else:
938947
units = ''
939948
ytitle = ''.join(['(', units, ')'])
940-
num_y = ydata.shape[0]
941-
barb_step_y = round(num_y / num_barbs_y)
949+
if barb_step_y is None:
950+
num_y = ydata.shape[0]
951+
barb_step_y = round(num_y / num_barbs_y)
942952
if barb_step_y == 0:
943953
barb_step_y = 1
944954

0 commit comments

Comments
 (0)