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

Skip to content

Commit 382dcba

Browse files
committed
Allow setting tick colour on 3D axes
1 parent 76db501 commit 382dcba

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

lib/mpl_toolkits/mplot3d/axis3d.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ def __init__(self, adir, v_intervalx, d_intervalx, axes, *args,
8181
'ha': 'center'},
8282
'tick': {'inward_factor': 0.2,
8383
'outward_factor': 0.1,
84-
'linewidth': rcParams['lines.linewidth'],
85-
'color': 'k'},
84+
'linewidth': rcParams['lines.linewidth']},
8685
'axisline': {'linewidth': 0.75,
8786
'color': (0, 0, 0, 1)},
8887
'grid': {'color': (0.9, 0.9, 0.9, 1),
@@ -97,10 +96,7 @@ def __init__(self, adir, v_intervalx, d_intervalx, axes, *args,
9796
'outward_factor': 0.1,
9897
'linewidth': rcParams.get(
9998
adir + 'tick.major.width',
100-
rcParams['xtick.major.width']),
101-
'color': rcParams.get(
102-
adir + 'tick.color',
103-
rcParams['xtick.color'])},
99+
rcParams['xtick.major.width'])},
104100
'axisline': {'linewidth': rcParams['axes.linewidth'],
105101
'color': rcParams['axes.edgecolor']},
106102
'grid': {'color': rcParams['grid.color'],
@@ -265,7 +261,7 @@ def draw(self, renderer):
265261
dx, dy = (self.axes.transAxes.transform([peparray[0:2, 1]]) -
266262
self.axes.transAxes.transform([peparray[0:2, 0]]))[0]
267263

268-
lxyz = 0.5*(edgep1 + edgep2)
264+
lxyz = 0.5 * (edgep1 + edgep2)
269265

270266
# A rough estimate; points are ambiguous since 3D plots rotate
271267
ax_scale = self.axes.bbox.size / self.figure.bbox.size
@@ -391,7 +387,6 @@ def draw(self, renderer):
391387
ticksign = -1
392388

393389
for tick in ticks:
394-
395390
# Get tick line positions
396391
pos = copy.copy(edgep1)
397392
pos[index] = tick.get_loc()
@@ -420,7 +415,6 @@ def draw(self, renderer):
420415

421416
tick_update_position(tick, (x1, x2), (y1, y2), (lx, ly))
422417
tick.tick1line.set_linewidth(info['tick']['linewidth'])
423-
tick.tick1line.set_color(info['tick']['color'])
424418
tick.draw(renderer)
425419

426420
renderer.close_group('axis3d')

lib/mpl_toolkits/tests/test_mplot3d.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -924,3 +924,20 @@ def test_proj3d_deprecated():
924924

925925
with pytest.warns(MatplotlibDeprecationWarning):
926926
proj3d.proj_trans_clip_points(np.ones((4, 3)), M)
927+
928+
929+
def test_ax3d_tickcolour():
930+
fig = plt.figure()
931+
ax = Axes3D(fig)
932+
933+
ax.tick_params(axis='x', colors='red')
934+
ax.tick_params(axis='y', colors='red')
935+
ax.tick_params(axis='z', colors='red')
936+
fig.canvas.draw()
937+
938+
for tick in ax.xaxis.get_major_ticks():
939+
assert tick.tick1line._color == 'red'
940+
for tick in ax.yaxis.get_major_ticks():
941+
assert tick.tick1line._color == 'red'
942+
for tick in ax.zaxis.get_major_ticks():
943+
assert tick.tick1line._color == 'red'

0 commit comments

Comments
 (0)