Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5a8c418

Browse files
authored
Merge pull request #20198 from anntzer/ca
Fix validation of Line2D color.
2 parents 674d670 + 2cdcc03 commit 5a8c418

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

lib/matplotlib/lines.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,8 +1027,7 @@ def set_color(self, color):
10271027
----------
10281028
color : color
10291029
"""
1030-
if not cbook._str_equal(color, 'auto'):
1031-
mcolors._check_color_like(color=color)
1030+
mcolors._check_color_like(color=color)
10321031
self._color = color
10331032
self.stale = True
10341033

lib/mpl_toolkits/axisartist/axis_artist.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@
7575

7676
import numpy as np
7777

78-
from matplotlib import _api, rcParams
78+
from matplotlib import _api, cbook, rcParams
7979
import matplotlib.artist as martist
80+
import matplotlib.colors as mcolors
8081
import matplotlib.text as mtext
81-
8282
from matplotlib.collections import LineCollection
8383
from matplotlib.lines import Line2D
8484
from matplotlib.patches import PathPatch
@@ -134,6 +134,14 @@ def get_ref_artist(self):
134134
# docstring inherited
135135
return self._axis.majorTicks[0].tick1line
136136

137+
def set_color(self, color):
138+
# docstring inherited
139+
# Unlike the base Line2D.set_color, this also supports "auto".
140+
if not cbook._str_equal(color, "auto"):
141+
mcolors._check_color_like(color=color)
142+
self._color = color
143+
self.stale = True
144+
137145
def get_color(self):
138146
return self.get_attribute_from_ref_artist("color")
139147

0 commit comments

Comments
 (0)