Skip to content

Add axes.aspect as an option to rcParams #15001

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

Closed
wants to merge 2 commits into from
Closed
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
9 changes: 9 additions & 0 deletions doc/users/next_whats_new/rcparam-axes-aspect.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
rcParams for default axes aspect
--------------------------------------------------

One new rcParams have been added: ``axes.aspect`` for the default axes.aspect specification

Valid values for ``axes.aspect`` remain: 'auto', 'equal' or a float.

Default behviour is unchanged.

2 changes: 1 addition & 1 deletion lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ def __init__(self, fig, rect,
raise ValueError('Width and height specified must be non-negative')
self._originalPosition = self._position.frozen()
self.axes = self
self._aspect = 'auto'
self._aspect = rcParams['axes.aspect']
self._adjustable = 'box'
self._anchor = 'C'
self._stale_viewlim_x = False
Expand Down
8 changes: 6 additions & 2 deletions lib/matplotlib/rcsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,12 +369,15 @@ def validate_color(s):


def validate_aspect(s):
if s in ('auto', 'equal'):
aspect_specifications = ['auto', 'equal']
if s in aspect_specifications:
return s
try:
return float(s)
except ValueError:
raise ValueError('not a valid aspect specification')
raise ValueError(
"%s is not a valid aspect specification. Valid aspect "
"specifications are %s." % (s, ", ".join(aspect_specifications)))


def validate_fontsize_None(s):
Expand Down Expand Up @@ -1175,6 +1178,7 @@ def _validate_linestyle(ls):
'axes.autolimit_mode': [
'data',
ValidateInStrings('autolimit_mode', ['data', 'round_numbers'])],
'axes.aspect': ['auto', validate_aspect],
'axes.xmargin': [0.05, ValidateInterval(0, 1,
closedmin=True,
closedmax=True)], # margin added to xaxis
Expand Down
1 change: 1 addition & 0 deletions matplotlibrc.template
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@
#axes.autolimit_mode : data ## How to scale axes limits to the data. By using:
## - "data" to use data limits, plus some margin
## - "round_numbers" move to the nearest "round" number
#axes.aspect : 'auto' ## axes aspect, options: 'auto', 'equal' or float
#axes.xmargin : .05 ## x margin. See `axes.Axes.margins`
#axes.ymargin : .05 ## y margin. See `axes.Axes.margins`
#polaraxes.grid : True ## display grid on polar axes
Expand Down