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

Skip to content

Commit 45e1ca9

Browse files
authored
Merge pull request #16847 from igordertigor/ticks-are-not-markers
Ticks are not markers
2 parents 2f7a58d + 8ed9458 commit 45e1ca9

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

lib/matplotlib/axis.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,12 @@ def __init__(self, axes, loc, label=None,
148148
self.tick1line = mlines.Line2D(
149149
[], [],
150150
color=color, linestyle="none", zorder=zorder, visible=tick1On,
151-
markersize=size, markeredgewidth=width,
151+
markeredgecolor=color, markersize=size, markeredgewidth=width,
152152
)
153153
self.tick2line = mlines.Line2D(
154154
[], [],
155155
color=color, linestyle="none", zorder=zorder, visible=tick2On,
156-
markersize=size, markeredgewidth=width,
156+
markeredgecolor=color, markersize=size, markeredgewidth=width,
157157
)
158158
self.gridline = mlines.Line2D(
159159
[], [],
@@ -352,6 +352,8 @@ def _apply_params(self, **kw):
352352
trans = self._get_text2_transform()[0]
353353
self.label2.set_transform(trans)
354354
tick_kw = {k: v for k, v in kw.items() if k in ['color', 'zorder']}
355+
if 'color' in kw:
356+
tick_kw['markeredgecolor'] = kw['color']
355357
self.tick1line.set(**tick_kw)
356358
self.tick2line.set(**tick_kw)
357359
for k, v in tick_kw.items():

lib/matplotlib/tests/test_axes.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6129,3 +6129,19 @@ def test_invisible_axes():
61296129
assert fig.canvas.inaxes((200, 200)) is not None
61306130
ax.set_visible(False)
61316131
assert fig.canvas.inaxes((200, 200)) is None
6132+
6133+
6134+
def test_xtickcolor_is_not_markercolor():
6135+
plt.rcParams['lines.markeredgecolor'] = 'white'
6136+
ax = plt.axes()
6137+
ticks = ax.xaxis.get_major_ticks()
6138+
for tick in ticks:
6139+
assert tick.tick1line.get_markeredgecolor() != 'white'
6140+
6141+
6142+
def test_ytickcolor_is_not_markercolor():
6143+
plt.rcParams['lines.markeredgecolor'] = 'white'
6144+
ax = plt.axes()
6145+
ticks = ax.yaxis.get_major_ticks()
6146+
for tick in ticks:
6147+
assert tick.tick1line.get_markeredgecolor() != 'white'

0 commit comments

Comments
 (0)