8000 Merge pull request #13984 from dstansby/3d-tick-color · vm-asd2015/matplotlib@e8c0b5e · GitHub
[go: up one dir, main page]

Skip to content

Commit e8c0b5e

Browse files
authored
Merge pull request matplotlib#13984 from dstansby/3d-tick-color
ENH: Allow setting tick colour on 3D axes
2 parents a7b0fe9 + 382dcba commit e8c0b5e

File tree

2 files changed

+20
-9
lines changed
  • lib/mpl_toolkits
    • < 10000 div id=":R1dtddab:" class="PRIVATE_TreeView-item-content prc-TreeView-TreeViewItemContent-f0r0b">mplot3d
  • tests
  • 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
    @@ -923,3 +923,20 @@ def test_proj3d_deprecated():
    923923

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

    0 commit comments

    Comments
     (0)
    0