Skip to content

Commit 8cdf24c

Browse files
committed
Use pivot_table instead of pd.pivot
1 parent 85dd52b commit 8cdf24c

3 files changed

Lines changed: 74 additions & 174 deletions

File tree

dabest/plotter.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,9 @@ def EffectSizeDataFramePlotter(EffectSizeDataFrame, **plot_kwargs):
418418
pivot_values = [yvar]
419419
else:
420420
pivot_values = [yvar, color_col]
421-
pivoted_plot_data = pd.pivot(data=plot_data, index=dabest_obj.id_col,
422-
columns=xvar, values=pivot_values)
421+
# pivoted_plot_data = pd.pivot(data=plot_data, index=dabest_obj.id_col,
422+
# columns=xvar, values=pivot_values)
423+
pivoted_plot_data = plot_data.pivot_table(index=dabest_obj.id_col, columns=xvar, values=pivot_values)
423424
x_start = 0
424425
for ii, current_tuple in enumerate(temp_idx):
425426
current_pair = pivoted_plot_data.loc[:, pd.MultiIndex.from_product([pivot_values, current_tuple])].dropna()
@@ -436,6 +437,11 @@ def EffectSizeDataFramePlotter(EffectSizeDataFrame, **plot_kwargs):
436437
if isinstance(color_key, str) == True:
437438
slopegraph_kwargs['color'] = plot_palette_raw[color_key]
438439
slopegraph_kwargs['label'] = color_key
440+
else:
441+
color_key = str(color_key)
442+
slopegraph_kwargs['color'] = plot_palette_raw[color_key]
443+
slopegraph_kwargs['label'] = color_key
444+
439445

440446
rawdata_axes.plot(x_points, y_points, **slopegraph_kwargs)
441447
x_start = x_start + grp_count

0 commit comments

Comments
 (0)