Skip to content

Add test for remaining axis options #24668

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7280,6 +7280,24 @@ def test_secondary_repr():
assert repr(secax) == '<SecondaryAxis: >'


@image_comparison(['axis_options.png'], remove_text=True, style='mpl20')
def test_axis_options():
fig, axes = plt.subplots(2, 3)
for i, option in enumerate(('scaled', 'tight', 'image')):
# Draw a line and a circle fitting within the boundaries of the line
# The circle should look like a circle for 'scaled' and 'image'
# High/narrow aspect ratio
axes[0, i].plot((1, 2), (1, 3.2))
Copy link
Member

Choose a reason for hiding this comment

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

What's thd difference between the top and bottom tests?

Copy link
Member Author

Choose a reason for hiding this comment

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

Aspect ratio.

Copy link
Member

Choose a reason for hiding this comment

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

Is that a relevant parameter to test? I would have expected that the code paths are the same.

If it is, please add comments á la # aspect ratio > 1 to both parts.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure. I guess one can get weird behavior for one of the cases, but have not checked the code paths.

Copy link
Member

Choose a reason for hiding this comment

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

Is the aspect ratio coming from just the autoscaling on the line?

Testing both of these seems relevant, the Do What I Mean code tends to be full of (and grow) special cases so (low fidelity) fuzz testing is reasonable.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that is my impression. It will at least not consider a large circle.

axes[0, i].axis(option)
axes[0, i].add_artist(mpatches.Circle((1.5, 1.5), radius=0.5,
facecolor='none', edgecolor='k'))
# Low/wide aspect ratio
axes[1, i].plot((1, 2.25), (1, 1.75))
axes[1, i].axis(option)
axes[1, i].add_artist(mpatches.Circle((1.5, 1.25), radius=0.25,
facecolor='none', edgecolor='k'))


def color_boxes(fig, ax):
"""
Helper for the tests below that test the extents of various axes elements
Expand Down