From 61f141afdcec2338cebaea0647279329ba9fdebf Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Mon, 15 Apr 2013 21:19:50 -0500 Subject: [PATCH 1/4] added rcParam for x and y margin Addresses issue #1766 --- lib/matplotlib/axes.py | 6 +++--- lib/matplotlib/rcsetup.py | 6 ++++++ matplotlibrc.template | 4 +++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/axes.py b/lib/matplotlib/axes.py index 2c06ff86f8c0..2762dd102064 100644 --- a/lib/matplotlib/axes.py +++ b/lib/matplotlib/axes.py @@ -901,8 +901,8 @@ def cla(self): self._autoscaleXon = True self._autoscaleYon = True - self._xmargin = 0 - self._ymargin = 0 + self._xmargin = rcParams['axes.xmargin'] + self._ymargin = rcParams['axes.ymargin'] self._tight = False self._update_transScale() # needed? @@ -9076,7 +9076,7 @@ def matshow(self, Z, **kwargs): return im def get_default_bbox_extra_artists(self): - return [artist for artist in self.get_children() + return [artist for artist in self.get_children() if artist.get_visible()] def get_tightbbox(self, renderer, call_axes_locator=True): diff --git a/lib/matplotlib/rcsetup.py b/lib/matplotlib/rcsetup.py index 721f10bcf5d9..bea9e7eea098 100644 --- a/lib/matplotlib/rcsetup.py +++ b/lib/matplotlib/rcsetup.py @@ -579,6 +579,12 @@ def __call__(self, s): 'axes.color_cycle': [['b', 'g', 'r', 'c', 'm', 'y', 'k'], validate_colorlist], # cycle of plot # line colors + 'axes.xmargin': [0, ValidateInterval(0, 1, + closedmin=True, + closedmax=True)], # margin added to xaxis + 'axes.ymargin': [0, ValidateInterval(0, 1, + closedmin=True, + closedmax=True)],# margin added to yaxis 'polaraxes.grid': [True, validate_bool], # display polar grid or # not diff --git a/matplotlibrc.template b/matplotlibrc.template index 0509fae4a81d..459ea215b876 100644 --- a/matplotlibrc.template +++ b/matplotlibrc.template @@ -250,6 +250,8 @@ text.hinting_factor : 8 # Specifies the amount of softness for hinting in the # as list of string colorspecs: # single letter, long name, or # web-style hex +#axes.xmargin : 0 # x margin. See `axes.Axes.margins` +#axes.ymargin : 0 # y margin See `axes.Axes.margins` #polaraxes.grid : True # display grid on polar axes #axes3d.grid : True # display grid on 3d axes @@ -451,7 +453,7 @@ text.hinting_factor : 8 # Specifies the amount of softness for hinting in the #animation.avconv_path: 'avconv' # Path to avconv binary. Without full path # $PATH is searched #animation.avconv_args: '' # Additional arguments to pass to avconv -#animation.mencoder_path: 'mencoder' +#animation.mencoder_path: 'mencoder' # Path to mencoder binary. Without full path # $PATH is searched #animation.mencoder_args: '' # Additional arguments to pass to mencoder From 7c2688c63fcb851ae65c7441c4d62b28cbf1b9ed Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Tue, 16 Apr 2013 08:50:14 -0500 Subject: [PATCH 2/4] updated docs + changelog --- CHANGELOG | 3 +++ doc/users/whats_new.rst | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index b266df9123d0..4b98063602e7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +2013-04-15 Added 'axes.xmargin' and 'axes.ymargin' to rpParams to set default + margins on auto-scaleing. - TAC + 2013-03-19 Added support for passing `linestyle` kwarg to `step` so all `plot` kwargs are passed to the underlying `plot` call. -TAC diff --git a/doc/users/whats_new.rst b/doc/users/whats_new.rst index d0c3584563bf..01a15dbc8247 100644 --- a/doc/users/whats_new.rst +++ b/doc/users/whats_new.rst @@ -21,6 +21,12 @@ revision, see the :ref:`github-stats`. new in matplotlib-1.3 ===================== +`axes.xmargin` and `axes.ymargin` added to rcParams +--------------------------------------------------- +rcParam values were added to configure the default margins +used. Previously they were hard-coded to default to 0, default +value of both rcParam values is 0. + New eventplot plot type ------------------------------------- From 0ccbc9b2d8d049d8e19d4f0455f4fcfac54cf611 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Wed, 17 Apr 2013 14:38:54 -0500 Subject: [PATCH 3/4] tweaked formatting/text in whats_new --- doc/users/whats_new.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/users/whats_new.rst b/doc/users/whats_new.rst index 01a15dbc8247..2f2c55552357 100644 --- a/doc/users/whats_new.rst +++ b/doc/users/whats_new.rst @@ -21,11 +21,11 @@ revision, see the :ref:`github-stats`. new in matplotlib-1.3 ===================== -`axes.xmargin` and `axes.ymargin` added to rcParams +``axes.xmargin`` and ``axes.ymargin`` added to rcParams --------------------------------------------------- -rcParam values were added to configure the default margins -used. Previously they were hard-coded to default to 0, default -value of both rcParam values is 0. +``rcParam`` values (``axes.xmargin`` and ``axes.ymargin``) were added +to configure the default margins used. Previously they were +hard-coded to default to 0, default value of both rcParam values is 0. New eventplot plot type From fea9f9b7ae0157b2474fe241800fa2ed0290467b Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Wed, 17 Apr 2013 14:41:34 -0500 Subject: [PATCH 4/4] fixing minor formatting errors introduce by the last fix of formatting errors. --- doc/users/whats_new.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/users/whats_new.rst b/doc/users/whats_new.rst index 2f2c55552357..ecf4e2b179f0 100644 --- a/doc/users/whats_new.rst +++ b/doc/users/whats_new.rst @@ -22,7 +22,7 @@ revision, see the :ref:`github-stats`. new in matplotlib-1.3 ===================== ``axes.xmargin`` and ``axes.ymargin`` added to rcParams ---------------------------------------------------- +------------------------------------------------------- ``rcParam`` values (``axes.xmargin`` and ``axes.ymargin``) were added to configure the default margins used. Previously they were hard-coded to default to 0, default value of both rcParam values is 0.