From 8002b3d068698dfeecd821243cf576d0ded5c4bd Mon Sep 17 00:00:00 2001 From: Maoz Gelbart <13831112+MaozGelbart@users.noreply.github.com> Date: Tue, 27 Oct 2020 00:07:11 +0200 Subject: [PATCH] Fix: use linewidth when plotting boxes and medians (#2287) --- seaborn/categorical.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/seaborn/categorical.py b/seaborn/categorical.py index 5f5d21e0b5..3f0a38f929 100644 --- a/seaborn/categorical.py +++ b/seaborn/categorical.py @@ -1813,7 +1813,6 @@ def __init__(self, x, y, hue, data, order, hue_order, raise ValueError(msg) self.k_depth = k_depth - # TODO seems this member is only used to frame the legend artists if linewidth is None: linewidth = mpl.rcParams["lines.linewidth"] self.linewidth = linewidth @@ -1900,7 +1899,9 @@ def _lvplot(self, box_data, positions, # If we only have one data point, plot a line if len(box_data) == 1: - kws.update({'color': self.gray, 'linestyle': '-'}) + kws.update({ + 'color': self.gray, 'linestyle': '-', 'linewidth': self.linewidth + }) ys = [box_data[0], box_data[0]] xs = [x - widths / 2, x + widths / 2] if vert: @@ -1966,8 +1967,15 @@ def horz_perc_box(x, b, i, k, w): for i, b in enumerate(zip(box_ends, w_area))] # Plot the medians - ax.plot(xs_median, ys_median, c='.15', alpha=.45, - solid_capstyle="butt", **kws) + ax.plot( + xs_median, + ys_median, + c=".15", + alpha=0.45, + solid_capstyle="butt", + linewidth=self.linewidth, + **kws + ) # Plot outliers (if any) if len(outliers) > 0: @@ -1980,7 +1988,9 @@ def horz_perc_box(x, b, i, k, w): # Make sure that the last boxes contain hue and are not pure white rgb = [hex_color, cmap(.85)] cmap = mpl.colors.LinearSegmentedColormap.from_list('new_map', rgb) - collection = PatchCollection(boxes, cmap=cmap, edgecolor=self.gray) + collection = PatchCollection( + boxes, cmap=cmap, edgecolor=self.gray, linewidth=self.linewidth + ) # Set the color gradation, first box will have color=hex_color collection.set_array(np.array(np.linspace(1, 0, len(boxes))))