From 4cc0d81dfaa488e6ef35d666b39f5c9ca7f59387 Mon Sep 17 00:00:00 2001 From: PierreGtch <25532709+PierreGtch@users.noreply.github.com> Date: Tue, 17 Oct 2023 17:05:04 +0200 Subject: [PATCH] Fix pointplot dodge parameter Closes #43 --- ptitprince/PtitPrince.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ptitprince/PtitPrince.py b/ptitprince/PtitPrince.py index 6a3b4ef..64a1253 100644 --- a/ptitprince/PtitPrince.py +++ b/ptitprince/PtitPrince.py @@ -767,9 +767,10 @@ def RainCloud(x = None, y = None, hue = None, data = None, if pointplot: n_plots = 4 if not hue is None: + n_cat = len(np.unique(data[hue])) sns.pointplot(x = x, y = y, hue = hue, data = data, orient = orient, order = order, hue_order = hue_order, - dodge = width_box/2., palette = palette, ax = ax, **kwpoint) + dodge = width_box * (1 - 1 / n_cat), palette = palette, ax = ax, **kwpoint) else: sns.pointplot(x = x, y = y, hue = hue, data = data, color = linecolor, orient = orient, order = order, hue_order = hue_order,