Skip to content

fix(axis): respect offset text labelcolor (swev-id: matplotlib__matplotlib-25287)#56

Open
casey-brooks wants to merge 1 commit intomatplotlib__matplotlib-25287from
noa/issue-51
Open

fix(axis): respect offset text labelcolor (swev-id: matplotlib__matplotlib-25287)#56
casey-brooks wants to merge 1 commit intomatplotlib__matplotlib-25287from
noa/issue-51

Conversation

@casey-brooks
Copy link

@casey-brooks casey-brooks commented Dec 25, 2025

Summary

  • ensure XAxis/YAxis offset text inherits tick.labelcolor unless it is set to inherit
  • fall back to tick.color when label color is inherited
  • add regression tests covering rcParam overrides, inherit fallback, and tick_params(labelcolor=...)

Issue

Reproduction Steps

  1. Checkout matplotlib__matplotlib-25287
  2. Set up the test environment (venv + LD_LIBRARY_PATH as described in project docs)
  3. Run:
    MPLBACKEND=Agg \
    PYTHONPATH=$(pwd)/lib \
    LD_LIBRARY_PATH=/root/.nix-profile/lib:/nix/store/qipd93x9gjyiygqk673rd2ssnf8y7jj0-gcc-14.3.0-lib/lib:/nix/store/f8w1i7yisixb9hivzbk0l4ixmf67fjqr-gcc-14.3.0-libgcc/lib:/nix/store/n5lymg0y5x6i9wipkjrsi8aczv1nr4qc-zlib-1.3.1/lib \
    .venv/bin/pytest lib/matplotlib/tests/test_axes.py -k "offset_text_uses_labelcolor_from_rc or offset_text_inherits_tick_color_when_labelcolor_inherit or offset_text_follows_tick_params_labelcolor"

Failing Test Output (before fix)

============================= test session starts ==============================
platform linux -- Python 3.12.12, pytest-9.0.2, pluggy-1.6.0
rootdir: /workspace/matplotlib
configfile: pytest.ini
collected 855 items / 852 deselected / 3 selected

lib/matplotlib/tests/test_axes.py F..                                    [100%]

=================================== FAILURES ===================================
___________________ test_offset_text_uses_labelcolor_from_rc ___________________
>               assert mcolors.to_rgba(ax.xaxis.offsetText.get_color()) == \
                    mcolors.to_rgba('red')
E                   assert (0.0, 0.0, 0.0, 1.0) == (1.0, 0.0, 0.0, 1.0)
E                     At index 0 diff: 0.0 != 1.0
E                     Use -v to get more diff

lib/matplotlib/tests/test_axes.py:6093: AssertionError
=========================== short test summary info ============================
FAILED lib/matplotlib/tests/test_axes.py::test_offset_text_uses_labelcolor_from_rc
================= 1 failed, 2 passed, 852 deselected in 1.07s ==================

Testing

  • MPLBACKEND=Agg PYTHONPATH=$(pwd)/lib LD_LIBRARY_PATH=/root/.nix-profile/lib:/nix/store/qipd93x9gjyiygqk673rd2ssnf8y7jj0-gcc-14.3.0-lib/lib:/nix/store/f8w1i7yisixb9hivzbk0l4ixmf67fjqr-gcc-14.3.0-libgcc/lib:/nix/store/n5lymg0y5x6i9wipkjrsi8aczv1nr4qc-zlib-1.3.1/lib .venv/bin/pytest lib/matplotlib/tests/test_axes.py -k "offset_text_uses_labelcolor_from_rc or offset_text_inherits_tick_color_when_labelcolor_inherit or offset_text_follows_tick_params_labelcolor"
  • .venv/bin/flake8 lib/matplotlib/axis.py
  • .venv/bin/flake8 --extend-ignore=E721 lib/matplotlib/tests/test_axes.py

@casey-brooks casey-brooks requested a review from a team December 25, 2025 12:30
@casey-brooks casey-brooks changed the title Test fix(axis): respect offset text labelcolor (swev-id: matplotlib__matplotlib-25287) Dec 25, 2025
@casey-brooks
Copy link
Author

Test & Lint Summary

  • ============================= test session starts ==============================
    platform linux -- Python 3.12.12, pytest-9.0.2, pluggy-1.6.0
    rootdir: /workspace/matplotlib
    configfile: pytest.ini
    collected 855 items / 852 deselected / 3 selected

lib/matplotlib/tests/test_axes.py ... [100%]

====================== 3 passed, 852 deselected in 0.34s ======================= → 3 passed, 0 failed, 0 skipped

  • → no lint issues
  • → no lint issues

Copy link

@noa-lucent noa-lucent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants