Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Allow setting of aspect ratio for Axes in rcParams - Draft PR #30017

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
Loading
from

Conversation

ebubekir-pulat
Copy link

** DRAFT PR **

closes #8088

Implementing feature that allows the setting of a default aspect ratio for axes, not just images. New features involves the addition of the rcParam: axes.aspect.

Below is a screenshot showing the feature in action (before the last couple of recent upstream commits were merged into the branch):
image

@ebubekir-pulat
Copy link
Author

ebubekir-pulat commented May 20, 2025

I made a simple and basic implementation for this feature, before realising there was another draft request (#25642 ) open. Should I try to build off that Draft PR, or is my simple fix and ok starting point?

Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

I'm only +0.1 on this. There's low need for it. A fixed aspect can never be part of a style because it only works reasonably when you know your data is in a similar aspect. I concede though, that it may be helpful on helper functions for custom plot types.

This should be introduced together with axes.adjustable.

This needs a "what's new entry - https://matplotlib.org/devdocs/users/next_whats_new/README.html

@@ -680,7 +680,7 @@ def __init__(self, fig,
raise ValueError('Width and height specified must be non-negative')
self._originalPosition = self._position.frozen()
self.axes = self
self._aspect = 'auto'
self._aspect = None
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
self._aspect = None
self._aspect = mpl.rcParams['axes.aspect']

Resolution should happen at initialization.

Comment on lines -1659 to +1664
This is either "auto" or a float giving the ratio of y/x-scale.
This is either "auto", "equal" or a float giving the ratio of y/x-scale.
"""
return self._aspect
if self._aspect:
return self._aspect
aspect = mpl.rcParams['axes.aspect']
return aspect if aspect != 'equal' else 1
Copy link
Member

Choose a reason for hiding this comment

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

Let's not change anything here. rcParams lookup should be in __init__. Normalization "equal" -> 1 can be done in validate_aspect, so that "equal" is only public API but never internal state.

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

Successfully merging this pull request may close these issues.

rcParams for plt.axis('equal') not working?
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.