matplotlib / matplotlib/pytest-mpl

Paramater `remove_text` in `mpl_image_compare` decorator does not remove axis labels

Open
#120 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
272
Forks
53
PR merge metrics
No merged PRs in 30d

Description

When choosing `remove_text=True` I would have assumed that the text for axis labels was removed along with the axis ticks and any titles. But it doesn't seem to do that.

The code uses `remove_ticks_and_titles` from matplotlib and that does not appear to remove the axis labels (See [matplotlib documentation](https://matplotlib.org/stable/_modules/matplotlib/testing/decorators.html)).

I'd propose updating the `remove_text` conditional as follows:

```python

if remove_text:
remove_ticks_and_titles(fig)
for ax in fig.get_axes():
ax.set_xlabel = ""
ax.set_ylabel = ""
```

If this seems reasonable, I can submit a PR.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the mpl_image_compare decorator and its remove_text conditional, then inspect how the existing remove_ticks_and_titles call affects axis labels. Verify the behavior with an image-comparison test and consider the proposed label-removal behavior done when remove_text=True excludes axis labels as well as ticks and titles.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.