Skip to content

Commit 3888174

Browse files
committed
Suport datetime64 bars with multiple columns
1 parent 0499e32 commit 3888174

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

proplot/wrappers.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,14 +1828,16 @@ def cycle_changer(
18281828
# Step size for grouped bar plots
18291829
# WARNING: This will fail for non-numeric non-datetime64 singleton
18301830
# datatypes but this is good enough for vast majority of most cases.
1831-
x_step = np.atleast_1d(_to_ndarray(x))
1832-
if len(x_step) >= 2:
1833-
x_step = x_step[1:] - x_step[:-1]
1831+
x_test = np.atleast_1d(_to_ndarray(x))
1832+
if len(x_test) >= 2:
1833+
x_step = x_test[1:] - x_test[:-1]
18341834
x_step = np.concatenate((x_step, x_step[-1:]))
1835-
elif x_step.dtype == np.datetime64:
1835+
elif x_test.dtype == np.datetime64:
18361836
x_step = np.timedelta64(1, 'D')
18371837
else:
1838-
x_step = 0.5
1838+
x_step = np.array(0.5)
1839+
if np.issubdtype(x_test.dtype, np.datetime64):
1840+
x_step = x_step.astype('timedelta64[ns]') # avoid int timedelta truncation
18391841

18401842
# Get x coordinates for bar plot
18411843
x_col, y_first = x, ys[0] # samples

0 commit comments

Comments
 (0)