diff --git a/doc/users/next_whats_new/rcparam-axes-aspect.rst b/doc/users/next_whats_new/rcparam-axes-aspect.rst new file mode 100644 index 000000000000..11700385c774 --- /dev/null +++ b/doc/users/next_whats_new/rcparam-axes-aspect.rst @@ -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. + diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index 2e519a74c18e..7bb382a98927 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -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 diff --git a/lib/matplotlib/rcsetup.py b/lib/matplotlib/rcsetup.py index 26d54f61d0c1..d1dae18b7d12 100644 --- a/lib/matplotlib/rcsetup.py +++ b/lib/matplotlib/rcsetup.py @@ -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): @@ -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 diff --git a/matplotlibrc.template b/matplotlibrc.template index 67761328dbdc..b3766c7026d9 100644 --- a/matplotlibrc.template +++ b/matplotlibrc.template @@ -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