Repository: mwaskom/seaborn

Issue:
unfilled kdeplot ignores alpha=
It pulls `alpha` out of the kwargs and does some special handling for filled densities, but forgets to pass it back in in the unfilled case.

Discussion:
codecov[bot]: # [Codecov](https://codecov.io/gh/mwaskom/seaborn/pull/2460?src=pr&el=h1) Report
> Merging [#2460](https://codecov.io/gh/mwaskom/seaborn/pull/2460?src=pr&el=desc) (2236060) into [master](https://codecov.io/gh/mwaskom/seaborn/commit/136b462b30194f6579fd761d639118d0ceb66f55?el=desc) (136b462) will **decrease** coverage by `5.92%`.
> The diff coverage is `96.00%`.

[![Impacted file tree graph](https://codecov.io/gh/mwaskom/seaborn/pull/2460/graphs/tree.svg?width=650&height=150&src=pr&token=SLuzHnA9Bl)](https://codecov.io/gh/mwaskom/seaborn/pull/2460?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master    #2460      +/-   ##
==========================================
- Coverage   97.45%   91.53%   -5.93%     
==========================================
  Files          17       17              
  Lines        6290     6307      +17     
==========================================
- Hits         6130     5773     -357     
- Misses        160      534     +374     
```


| [Impacted Files](https://codecov.io/gh/mwaskom/seaborn/pull/2460?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [seaborn/\_statistics.py](https://codecov.io/gh/mwaskom/seaborn/pull/2460/diff?src=pr&el=tree#diff-c2VhYm9ybi9fc3RhdGlzdGljcy5weQ==) | `96.41% <ø> (-3.59%)` | :arrow_down: |
| [seaborn/\_testing.py](https://codecov.io/gh/mwaskom/seaborn/pull/2460/diff?src=pr&el=tree#diff-c2VhYm9ybi9fdGVzdGluZy5weQ==) | `92.30% <92.30%> (ø)` | |
| [seaborn/distributions.py](https://codecov.io/gh/mwaskom/seaborn/pull/2460/diff?src=pr&el=tree#diff-c2VhYm9ybi9kaXN0cmlidXRpb25zLnB5) | `96.00% <100.00%> (-0.32%)` | :arrow_down: |
| [seaborn/matrix.py](https://codecov.io/gh/mwaskom/seaborn/pull/2460/diff?src=pr&el=tree#diff-c2VhYm9ybi9tYXRyaXgucHk=) | `42.44% <0.00%> (-53.42%)` | :arrow_down: |
| [seaborn/algorithms.py](https://codecov.io/gh/mwaskom/seaborn/pull/2460/diff?src=pr&el=tree#diff-c2VhYm9ybi9hbGdvcml0aG1zLnB5) | `87.50% <0.00%> (-12.50%)` | :arrow_down: |
| [seaborn/regression.py](https://codecov.io/gh/mwaskom/seaborn/pull/2460/diff?src=pr&el=tree#diff-c2VhYm9ybi9yZWdyZXNzaW9uLnB5) | `85.53% <0.00%> (-12.27%)` | :arrow_down: |
| [seaborn/\_docstrings.py](https://codecov.io/gh/mwaskom/seaborn/pull/2460/diff?src=pr&el=tree#diff-c2VhYm9ybi9fZG9jc3RyaW5ncy5weQ==) | `97.22% <0.00%> (-2.78%)` | :arrow_down: |
| [seaborn/utils.py](https://codecov.io/gh/mwaskom/seaborn/pull/2460/diff?src=pr&el=tree#diff-c2VhYm9ybi91dGlscy5weQ==) | `91.83% <0.00%> (-2.73%)` | :arrow_down: |
| [seaborn/\_core.py](https://codecov.io/gh/mwaskom/seaborn/pull/2460/diff?src=pr&el=tree#diff-c2VhYm9ybi9fY29yZS5weQ==) | `98.06% <0.00%> (-0.56%)` | :arrow_down: |
| ... and [2 more](https://codecov.io/gh/mwaskom/seaborn/pull/2460/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/mwaskom/seaborn/pull/2460?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/mwaskom/seaborn/pull/2460?src=pr&el=footer). Last update [136b462...2236060](https://codecov.io/gh/mwaskom/seaborn/pull/2460?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/doc/releases/v0.12.0.txt b/doc/releases/v0.12.0.txt
index 96944872..86415a74 100644
--- a/doc/releases/v0.12.0.txt
+++ b/doc/releases/v0.12.0.txt
@@ -20,6 +20,8 @@ v0.12.0 (Unreleased)
 
 - |Fix| In :func:`rugplot`, fixed a bug that prevented the use of datetime data (:pr:`2458`).
 
+- |Fix| In :func:`histplot` and :func:`kdeplot`, fixed a bug where the `alpha` parameter was ignored when `fill=False` (:pr:`2460`).
+
 - |Fix| |Enhancement| Improved integration with the matplotlib color cycle in most axes-level functions (:pr:`2449`).
 
 - Made `scipy` an optional dependency and added `pip install seaborn[all]` as a method for ensuring the availability of compatible `scipy` and `statsmodels` libraries at install time. This has a few minor implications for existing code, which are explained in the Github pull request (:pr:`2398`).
diff --git a/seaborn/_statistics.py b/seaborn/_statistics.py
index b00983d3..32a03363 100644
--- a/seaborn/_statistics.py
+++ b/seaborn/_statistics.py
@@ -65,7 +65,7 @@ class KDE:
             Factor, multiplied by the smoothing bandwidth, that determines how
             far the evaluation grid extends past the extreme datapoints. When
             set to 0, truncate the curve at the data limits.
-        clip : pair of numbers None, or a pair of such pairs
+        clip : pair of numbers or None, or a pair of such pairs
             Do not evaluate the density outside of these limits.
         cumulative : bool, optional
             If True, estimate a cumulative distribution function. Requires scipy.
diff --git a/seaborn/distributions.py b/seaborn/distributions.py
index 95ca6dcf..65d86277 100644
--- a/seaborn/distributions.py
+++ b/seaborn/distributions.py
@@ -185,9 +185,9 @@ class _DistributionPlotter(VectorPlotter):
                 kws.setdefault("edgecolor", to_rgba(color, 1))
         elif element == "bars":
             kws["facecolor"] = "none"
-            kws["edgecolor"] = to_rgba(color, 1)
+            kws["edgecolor"] = to_rgba(color, alpha)
         else:
-            kws["color"] = color
+            kws["color"] = to_rgba(color, alpha)
         return kws
 
     def _quantile_to_level(self, data, quantile):
@@ -502,12 +502,15 @@ class _DistributionPlotter(VectorPlotter):
         # Note: default linewidth is determined after plotting
 
         # Default alpha should depend on other parameters
-        if multiple == "layer":
-            default_alpha = .5 if element == "bars" else .25
-        elif kde:
-            default_alpha = .5
+        if fill:
+            if multiple == "layer":
+                default_alpha = .5 if element == "bars" else .25
+            elif kde:
+                default_alpha = .5
+            else:
+                default_alpha = .75
         else:
-            default_alpha = .75
+            default_alpha = 1
         alpha = plot_kws.pop("alpha", default_alpha)  # TODO make parameter?
 
         hist_artists = []
@@ -914,7 +917,10 @@ class _DistributionPlotter(VectorPlotter):
             sticky_support = []
 
         # XXX unfilled kdeplot is ignoring
-        default_alpha = .25 if multiple == "layer" else .75
+        if fill:
+            default_alpha = .25 if multiple == "layer" else .75
+        else:
+            default_alpha = 1
         alpha = plot_kws.pop("alpha", default_alpha)  # TODO make parameter?
 
         # Now iterate through the subsets and draw the densities


Test patch:
diff --git a/seaborn/_testing.py b/seaborn/_testing.py
index 138bdd88..c6f821cb 100644
--- a/seaborn/_testing.py
+++ b/seaborn/_testing.py
@@ -1,5 +1,6 @@
 import numpy as np
 import matplotlib as mpl
+from matplotlib.colors import to_rgb, to_rgba
 from numpy.testing import assert_array_equal
 
 
@@ -69,3 +70,21 @@ def assert_plots_equal(ax1, ax2, labels=True):
     if labels:
         assert ax1.get_xlabel() == ax2.get_xlabel()
         assert ax1.get_ylabel() == ax2.get_ylabel()
+
+
+def assert_colors_equal(a, b, check_alpha=True):
+
+    def handle_array(x):
+
+        if isinstance(x, np.ndarray):
+            if x.ndim > 1:
+                x = np.unique(x, axis=0).squeeze()
+            if x.ndim > 1:
+                raise ValueError("Color arrays must be 1 dimensional")
+        return x
+
+    a = handle_array(a)
+    b = handle_array(b)
+
+    f = to_rgba if check_alpha else to_rgb
+    assert f(a) == f(b)
diff --git a/seaborn/tests/test_axisgrid.py b/seaborn/tests/test_axisgrid.py
index b643b5bf..e17fc158 100644
--- a/seaborn/tests/test_axisgrid.py
+++ b/seaborn/tests/test_axisgrid.py
@@ -20,6 +20,7 @@ from ..categorical import pointplot
 from .. import axisgrid as ag
 from .._testing import (
     assert_plots_equal,
+    assert_colors_equal,
 )
 
 rs = np.random.RandomState(0)
@@ -224,7 +225,7 @@ class TestFacetGrid:
         assert len(lines) == len(a_levels)
 
         for line, hue in zip(lines, palette):
-            assert line.get_color() == hue
+            assert_colors_equal(line.get_color(), hue)
 
         labels = g._legend.get_texts()
         assert len(labels) == len(a_levels)
@@ -249,7 +250,7 @@ class TestFacetGrid:
         assert len(lines) == len(a_levels)
 
         for line, hue in zip(lines, palette):
-            assert line.get_color() == hue
+            assert_colors_equal(line.get_color(), hue)
 
         labels = g._legend.get_texts()
         assert len(labels) == 4
@@ -273,7 +274,7 @@ class TestFacetGrid:
         assert len(lines) == len(b_levels)
 
         for line, hue in zip(lines, palette):
-            assert line.get_color() == hue
+            assert_colors_equal(line.get_color(), hue)
 
         labels = g._legend.get_texts()
         assert len(labels) == len(b_levels)
@@ -941,21 +942,20 @@ class TestPairGrid:
     def test_map_diag_color(self):
 
         color = "red"
-        rgb_color = mpl.colors.colorConverter.to_rgba(color)
 
         g1 = ag.PairGrid(self.df)
         g1.map_diag(plt.hist, color=color)
 
         for ax in g1.diag_axes:
             for patch in ax.patches:
-                assert patch.get_facecolor() == rgb_color
+                assert_colors_equal(patch.get_facecolor(), color)
 
         g2 = ag.PairGrid(self.df)
         g2.map_diag(kdeplot, color='red')
 
         for ax in g2.diag_axes:
             for line in ax.lines:
-                assert line.get_color() == color
+                assert_colors_equal(line.get_color(), color)
 
     def test_map_diag_palette(self):
 
@@ -966,7 +966,7 @@ class TestPairGrid:
 
         for ax in g.diag_axes:
             for line, color in zip(ax.lines[::-1], pal):
-                assert line.get_color() == color
+                assert_colors_equal(line.get_color(), color)
 
     def test_map_diag_and_offdiag(self):
 
@@ -1656,12 +1656,11 @@ class TestJointPlot:
 
         g = ag.jointplot(x="x", y="y", data=self.data, color="purple")
 
-        purple = mpl.colors.colorConverter.to_rgb("purple")
-        scatter_color = g.ax_joint.collections[0].get_facecolor()[0, :3]
-        assert tuple(scatter_color) == purple
+        scatter_color = g.ax_joint.collections[0].get_facecolor()
+        assert_colors_equal(scatter_color, "purple")
 
         hist_color = g.ax_marg_x.patches[0].get_facecolor()[:3]
-        assert hist_color == purple
+        assert_colors_equal(hist_color, "purple")
 
     def test_palette(self, long_df):
 
diff --git a/seaborn/tests/test_distributions.py b/seaborn/tests/test_distributions.py
index 858ac439..50e7c1e0 100644
--- a/seaborn/tests/test_distributions.py
+++ b/seaborn/tests/test_distributions.py
@@ -35,6 +35,7 @@ from ..axisgrid import FacetGrid
 from .._testing import (
     assert_plots_equal,
     assert_legends_equal,
+    assert_colors_equal,
 )
 
 
@@ -123,16 +124,16 @@ class SharedAxesLevelTests:
 
         ax = plt.figure().subplots()
         self.func(data=long_df, x="y", ax=ax, **kwargs)
-        assert self.get_last_color(ax, **kwargs) == to_rgb("C0")
+        assert_colors_equal(self.get_last_color(ax, **kwargs), "C0", check_alpha=False)
 
         ax = plt.figure().subplots()
         self.func(data=long_df, x="y", ax=ax, **kwargs)
         self.func(data=long_df, x="y", ax=ax, **kwargs)
-        assert self.get_last_color(ax, **kwargs) == to_rgb("C1")
+        assert_colors_equal(self.get_last_color(ax, **kwargs), "C1", check_alpha=False)
 
         ax = plt.figure().subplots()
         self.func(data=long_df, x="y", color="C2", ax=ax, **kwargs)
-        assert self.get_last_color(ax, **kwargs) == to_rgb("C2")
+        assert_colors_equal(self.get_last_color(ax, **kwargs), "C2", check_alpha=False)
 
 
 class TestRugPlot(SharedAxesLevelTests):
@@ -141,7 +142,7 @@ class TestRugPlot(SharedAxesLevelTests):
 
     def get_last_color(self, ax, **kwargs):
 
-        return to_rgb(ax.collections[-1].get_color()[0])
+        return ax.collections[-1].get_color()
 
     def assert_rug_equal(self, a, b):
 
@@ -302,9 +303,9 @@ class TestKDEPlotUnivariate(SharedAxesLevelTests):
     def get_last_color(self, ax, fill=True):
 
         if fill:
-            return to_rgb(ax.collections[-1].get_facecolor()[0])
+            return ax.collections[-1].get_facecolor()
         else:
-            return to_rgb(ax.lines[-1].get_color())
+            return ax.lines[-1].get_color()
 
     @pytest.mark.parametrize("fill", [True, False])
     def test_color(self, long_df, fill):
@@ -315,11 +316,11 @@ class TestKDEPlotUnivariate(SharedAxesLevelTests):
 
             ax = plt.figure().subplots()
             self.func(data=long_df, x="y", facecolor="C3", fill=True, ax=ax)
-            assert self.get_last_color(ax) == to_rgb("C3")
+            assert_colors_equal(self.get_last_color(ax), "C3", check_alpha=False)
 
             ax = plt.figure().subplots()
             self.func(data=long_df, x="y", fc="C4", fill=True, ax=ax)
-            assert self.get_last_color(ax) == to_rgb("C4")
+            assert_colors_equal(self.get_last_color(ax), "C4", check_alpha=False)
 
     @pytest.mark.parametrize(
         "variable", ["x", "y"],
@@ -442,8 +443,8 @@ class TestKDEPlotUnivariate(SharedAxesLevelTests):
         palette = color_palette()
 
         for line, fill, color in zip(lines, fills, palette):
-            assert line.get_color() == color
-            assert tuple(fill.get_facecolor().squeeze()) == color + (.25,)
+            assert_colors_equal(line.get_color(), color)
+            assert_colors_equal(fill.get_facecolor(), to_rgba(color, .25))
 
     def test_hue_stacking(self, long_df):
 
@@ -516,55 +517,50 @@ class TestKDEPlotUnivariate(SharedAxesLevelTests):
     def test_color_cycle_interaction(self, flat_series):
 
         color = (.2, 1, .6)
-        C0, C1 = to_rgb("C0"), to_rgb("C1")
 
         f, ax = plt.subplots()
         kdeplot(flat_series)
         kdeplot(flat_series)
-        assert to_rgb(ax.lines[0].get_color()) == C0
-        assert to_rgb(ax.lines[1].get_color()) == C1
+        assert_colors_equal(ax.lines[0].get_color(), "C0")
+        assert_colors_equal(ax.lines[1].get_color(), "C1")
         plt.close(f)
 
         f, ax = plt.subplots()
         kdeplot(flat_series, color=color)
         kdeplot(flat_series)
-        assert ax.lines[0].get_color() == color
-        assert to_rgb(ax.lines[1].get_color()) == C0
+        assert_colors_equal(ax.lines[0].get_color(), color)
+        assert_colors_equal(ax.lines[1].get_color(), "C0")
         plt.close(f)
 
         f, ax = plt.subplots()
         kdeplot(flat_series, fill=True)
         kdeplot(flat_series, fill=True)
-        assert (
-            to_rgba(ax.collections[0].get_facecolor().squeeze())
-            == to_rgba(C0, .25)
-        )
-        assert (
-            to_rgba(ax.collections[1].get_facecolor().squeeze())
-            == to_rgba(C1, .25)
-        )
+        assert_colors_equal(ax.collections[0].get_facecolor(), to_rgba("C0", .25))
+        assert_colors_equal(ax.collections[1].get_facecolor(), to_rgba("C1", .25))
         plt.close(f)
 
-    def test_color_fill(self, long_df):
+    @pytest.mark.parametrize("fill", [True, False])
+    def test_artist_color(self, long_df, fill):
 
         color = (.2, 1, .6)
         alpha = .5
 
         f, ax = plt.subplots()
 
-        kdeplot(long_df["x"], fill=True, color=color)
-        c = ax.collections[-1]
-        assert (
-            to_rgba(c.get_facecolor().squeeze())
-            == to_rgba(color, .25)
-        )
+        kdeplot(long_df["x"], fill=fill, color=color)
+        if fill:
+            artist_color = ax.collections[-1].get_facecolor().squeeze()
+        else:
+            artist_color = ax.lines[-1].get_color()
+        default_alpha = .25 if fill else 1
+        assert_colors_equal(artist_color, to_rgba(color, default_alpha))
 
-        kdeplot(long_df["x"], fill=True, color=color, alpha=alpha)
-        c = ax.collections[-1]
-        assert (
-            to_rgba(c.get_facecolor().squeeze())
-            == to_rgba(color, alpha)
-        )
+        kdeplot(long_df["x"], fill=fill, color=color, alpha=alpha)
+        if fill:
+            artist_color = ax.collections[-1].get_facecolor().squeeze()
+        else:
+            artist_color = ax.lines[-1].get_color()
+        assert_colors_equal(artist_color, to_rgba(color, alpha))
 
     def test_datetime_scale(self, long_df):
 
@@ -806,7 +802,7 @@ class TestKDEPlotUnivariate(SharedAxesLevelTests):
         ax = kdeplot(x=flat_array, linewidth=lw, color=color)
         line, = ax.lines
         assert line.get_linewidth() == lw
-        assert line.get_color() == color
+        assert_colors_equal(line.get_color(), color)
 
     def test_input_checking(self, long_df):
 
@@ -840,7 +836,7 @@ class TestKDEPlotUnivariate(SharedAxesLevelTests):
         legend_artists = ax.legend_.findobj(mpl.lines.Line2D)[::2]
         palette = color_palette()
         for artist, color in zip(legend_artists, palette):
-            assert artist.get_color() == color
+            assert_colors_equal(artist.get_color(), color)
 
         ax.clear()
 
@@ -972,8 +968,7 @@ class TestKDEPlotBivariate:
         with pytest.warns(UserWarning, match="cmap parameter ignored"):
             ax = kdeplot(data=long_df, x="x", y="y", hue="c", cmap="viridis")
 
-        color = tuple(ax.collections[0].get_color().squeeze())
-        assert color == mpl.colors.colorConverter.to_rgba("C0")
+        assert_colors_equal(ax.collections[0].get_color(), "C0")
 
     def test_contour_line_colors(self, long_df):
 
@@ -981,7 +976,7 @@ class TestKDEPlotBivariate:
         ax = kdeplot(data=long_df, x="x", y="y", color=color)
 
         for c in ax.collections:
-            assert tuple(c.get_color().squeeze()) == color
+            assert_colors_equal(c.get_color(), color)
 
     def test_contour_fill_colors(self, long_df):
 
@@ -1052,17 +1047,18 @@ class TestHistPlotUnivariate(SharedAxesLevelTests):
 
         if element == "bars":
             if fill:
-                return to_rgb(ax.patches[-1].get_facecolor())
+                return ax.patches[-1].get_facecolor()
             else:
-                return to_rgb(ax.patches[-1].get_edgecolor())
+                return ax.patches[-1].get_edgecolor()
         else:
             if fill:
-                facecolor = to_rgb(ax.collections[-1].get_facecolor()[0])
-                edgecolor = to_rgb(ax.collections[-1].get_edgecolor()[0])
-                assert facecolor == edgecolor
+                artist = ax.collections[-1]
+                facecolor = artist.get_facecolor()
+                edgecolor = artist.get_edgecolor()
+                assert_colors_equal(facecolor, edgecolor, check_alpha=False)
                 return facecolor
             else:
-                return to_rgb(ax.lines[-1].get_color())
+                return ax.lines[-1].get_color()
 
     @pytest.mark.parametrize(
         "element,fill",
@@ -1152,10 +1148,10 @@ class TestHistPlotUnivariate(SharedAxesLevelTests):
             a = .75
 
         for bar, color in zip(ax.patches[::-1], palette):
-            assert bar.get_facecolor() == to_rgba(color, a)
+            assert_colors_equal(bar.get_facecolor(), to_rgba(color, a))
 
         for poly, color in zip(ax.collections[::-1], palette):
-            assert tuple(poly.get_facecolor().squeeze()) == to_rgba(color, a)
+            assert_colors_equal(poly.get_facecolor(), to_rgba(color, a))
 
     def test_hue_stack(self, long_df):
 
@@ -1428,7 +1424,9 @@ class TestHistPlotUnivariate(SharedAxesLevelTests):
         ax = histplot(data=long_df, x="x", hue="a", kde=True, bins=n)
 
         for bar, line in zip(ax.patches[::n], ax.lines):
-            assert to_rgba(bar.get_facecolor(), 1) == line.get_color()
+            assert_colors_equal(
+                bar.get_facecolor(), line.get_color(), check_alpha=False
+            )
 
     def test_kde_yaxis(self, flat_series):
 
@@ -1470,9 +1468,11 @@ class TestHistPlotUnivariate(SharedAxesLevelTests):
 
     def test_bars_no_fill(self, flat_series):
 
-        ax = histplot(flat_series, element="bars", fill=False)
+        alpha = .5
+        ax = histplot(flat_series, element="bars", fill=False, alpha=alpha)
         for bar in ax.patches:
             assert bar.get_facecolor() == (0, 0, 0, 0)
+            assert bar.get_edgecolor()[-1] == alpha
 
     def test_step_fill(self, flat_series):
 
@@ -1639,7 +1639,7 @@ class TestHistPlotUnivariate(SharedAxesLevelTests):
         ec = (1, .2, .9, .5)
         ax = histplot(flat_series, binwidth=1, ec=ec, lw=lw)
         for bar in ax.patches:
-            assert bar.get_edgecolor() == ec
+            assert_colors_equal(bar.get_edgecolor(), ec)
             assert bar.get_linewidth() == lw
 
     def test_step_fill_kwargs(self, flat_series):
@@ -1648,7 +1648,7 @@ class TestHistPlotUnivariate(SharedAxesLevelTests):
         ec = (1, .2, .9, .5)
         ax = histplot(flat_series, element="step", ec=ec, lw=lw)
         poly = ax.collections[0]
-        assert tuple(poly.get_edgecolor().squeeze()) == ec
+        assert_colors_equal(poly.get_edgecolor(), ec)
         assert poly.get_linewidth() == lw
 
     def test_step_line_kwargs(self, flat_series):
@@ -1948,7 +1948,7 @@ class TestECDFPlotUnivariate(SharedAxesLevelTests):
         ax = ecdfplot(long_df, x="x", hue="a")
 
         for line, color in zip(ax.lines[::-1], color_palette()):
-            assert line.get_color() == color
+            assert_colors_equal(line.get_color(), color)
 
     def test_line_kwargs(self, long_df):
 
@@ -1958,7 +1958,7 @@ class TestECDFPlotUnivariate(SharedAxesLevelTests):
         ax = ecdfplot(long_df, x="x", color=color, ls=ls, lw=lw)
 
         for line in ax.lines:
-            assert to_rgb(line.get_color()) == to_rgb(color)
+            assert_colors_equal(line.get_color(), color)
             assert line.get_linestyle() == ls
             assert line.get_linewidth() == lw