diff --git a/seaborn/_marks/area.py b/seaborn/_marks/area.py index 0157faed5b..4c932f0244 100644 --- a/seaborn/_marks/area.py +++ b/seaborn/_marks/area.py @@ -31,16 +31,16 @@ def _plot(self, split_gen, scales, orient): verts = self._get_verts(data, orient) ax.update_datalim(verts) - # TODO fill= is not working here properly - # We could hack a fix, but would be better to handle fill in resolve_color + # TODO should really move this logic into resolve_color + fc = resolve_color(self, keys, "", scales) + if not resolved["fill"]: + fc = mpl.colors.to_rgba(fc, 0) - kws["facecolor"] = resolve_color(self, keys, "", scales) + kws["facecolor"] = fc kws["edgecolor"] = resolve_color(self, keys, "edge", scales) kws["linewidth"] = resolved["edgewidth"] kws["linestyle"] = resolved["edgestyle"] - # path = mpl.path.Path(verts) # TODO, closed=True) - # patches[ax].append(mpl.patches.PathPatch(path, **kws)) patches[ax].append(mpl.patches.Polygon(verts, **kws)) for ax, ax_patches in patches.items(): @@ -72,8 +72,12 @@ def _legend_artist(self, variables, value, scales): keys = {v: value for v in variables} resolved = resolve_properties(self, keys, scales) + fc = resolve_color(self, keys, "", scales) + if not resolved["fill"]: + fc = mpl.colors.to_rgba(fc, 0) + return mpl.patches.Patch( - facecolor=resolve_color(self, keys, "", scales), + facecolor=fc, edgecolor=resolve_color(self, keys, "edge", scales), linewidth=resolved["edgewidth"], linestyle=resolved["edgestyle"], diff --git a/tests/_marks/test_area.py b/tests/_marks/test_area.py index 0b884d351a..dcc3f5a859 100644 --- a/tests/_marks/test_area.py +++ b/tests/_marks/test_area.py @@ -86,6 +86,14 @@ def test_mapped(self): lws = [p.get_linewidth() for p in ax.patches] assert lws[0] > lws[1] + def test_unfilled(self): + + x, y = [1, 2, 3], [1, 2, 1] + p = Plot(x=x, y=y).add(Area(fill=False)).plot() + ax = p._figure.axes[0] + poly = ax.patches[0] + assert poly.get_facecolor() == to_rgba("C0", 0) + def test_ribbon(self): x, ymin, ymax = [1, 2, 4], [2, 1, 4], [3, 3, 5]