From e48da7ee2e5f62d8e5461bed2512a610c30b756a Mon Sep 17 00:00:00 2001 From: Kyle Sunden Date: Mon, 28 Aug 2023 14:01:17 -0500 Subject: [PATCH] Backport PR #26598: FIX: array labelcolor for Tick --- lib/matplotlib/axis.py | 2 +- lib/matplotlib/tests/test_axis.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 lib/matplotlib/tests/test_axis.py diff --git a/lib/matplotlib/axis.py b/lib/matplotlib/axis.py index 0ace31916ca9..77bd34df69c5 100644 --- a/lib/matplotlib/axis.py +++ b/lib/matplotlib/axis.py @@ -129,7 +129,7 @@ def __init__( if labelcolor is None: labelcolor = mpl.rcParams[f"{name}.labelcolor"] - if labelcolor == 'inherit': + if cbook._str_equal(labelcolor, 'inherit'): # inherit from tick color labelcolor = mpl.rcParams[f"{name}.color"] diff --git a/lib/matplotlib/tests/test_axis.py b/lib/matplotlib/tests/test_axis.py new file mode 100644 index 000000000000..97b5f88dede1 --- /dev/null +++ b/lib/matplotlib/tests/test_axis.py @@ -0,0 +1,10 @@ +import numpy as np + +import matplotlib.pyplot as plt +from matplotlib.axis import XTick + + +def test_tick_labelcolor_array(): + # Smoke test that we can instantiate a Tick with labelcolor as array. + ax = plt.axes() + XTick(ax, 0, labelcolor=np.array([1, 0, 0, 1]))