Skip to content

Commit

Permalink
Fix: use linewidth when plotting boxes and medians (#2287)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaozGelbart authored Oct 26, 2020
1 parent d348036 commit 8002b3d
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions seaborn/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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))))
Expand Down

0 comments on commit 8002b3d

Please sign in to comment.