Skip to content

Loading…

added rcParam for x and y margin #1908

Merged
merged 4 commits into from

2 participants

@tacaswell
Matplotlib Developers member

Addresses issue #1766

I get 3 test failures on my machine related to matplotlib.tests.test_text.test_font_styles.test, but I also get the same failure on current master, so I at least don't make it worse.

@pelson
Matplotlib Developers member

:+1: once there is an item in the what's new section.
Nice addition @tacaswell

@pelson pelson commented on an outdated diff
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
+---------------------------------------------------
@pelson Matplotlib Developers member
pelson added a note

I think these fonts on github are monospace, in which case, would you mind making the underlining >= the length of the line being underlined?

@tacaswell Matplotlib Developers member

The lengths look equal in my browser (and in emacs which I know is monospace)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@pelson pelson commented on an outdated diff
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
@pelson Matplotlib Developers member
pelson added a note

We may as well mention them here. Perhaps:

``rcParam`` values (``axes.xmargin`` and ``axes.ymargin``) were ...
@tacaswell Matplotlib Developers member

done.

As a side note, what is the difference between '`' and '``' in sphinx?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@pelson pelson commented on the diff
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,
@pelson Matplotlib Developers member
pelson added a note

Given the method is axes.margins (http://matplotlib.org/api/axes_api.html#matplotlib.axes.Axes.margins), I'm tempted to suggest having an rcParam of axes.margins which has the same semantics as the method (i.e. (None, 0.1) is a valid margin setting).

Any thoughts?

@tacaswell Matplotlib Developers member

axes.margins is a dispatcher/convince function to set_xmargin and set_ymargin (which do not accept None as a valid input) and then calling autoscale_view to make sure everything updates. I think the rcParam should match the lower level.

Adding a third parameter axes.margins will allow the user to set it up to be inconsistent and we would need to sort out precedence which can only lead to confusion.

Looking at margins again, I think it might need a bit of work as axes.margins(.1, xmargin=.2) will set both margins to .1, which is not what I would expect. OTOH, this isn't really a documented call signature, but it will raise no errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@pelson pelson merged commit 44e3790 into matplotlib:master

1 check passed

Details default The Travis build passed
@tacaswell tacaswell deleted the tacaswell:margins_rcParam branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 16, 2013
  1. @tacaswell

    added rcParam for x and y margin

    tacaswell committed
    Addresses issue #1766
  2. @tacaswell

    updated docs + changelog

    tacaswell committed
Commits on Apr 17, 2013
  1. @tacaswell
  2. @tacaswell
Showing with 21 additions and 4 deletions.
  1. +3 −0 CHANGELOG
  2. +6 −0 doc/users/whats_new.rst
  3. +3 −3 lib/matplotlib/axes.py
  4. +6 −0 lib/matplotlib/rcsetup.py
  5. +3 −1 matplotlibrc.template
View
3 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
View
6 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 (``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
-------------------------------------
View
6 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):
View
6 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,
@pelson Matplotlib Developers member
pelson added a note

Given the method is axes.margins (http://matplotlib.org/api/axes_api.html#matplotlib.axes.Axes.margins), I'm tempted to suggest having an rcParam of axes.margins which has the same semantics as the method (i.e. (None, 0.1) is a valid margin setting).

Any thoughts?

@tacaswell Matplotlib Developers member

axes.margins is a dispatcher/convince function to set_xmargin and set_ymargin (which do not accept None as a valid input) and then calling autoscale_view to make sure everything updates. I think the rcParam should match the lower level.

Adding a third parameter axes.margins will allow the user to set it up to be inconsistent and we would need to sort out precedence which can only lead to confusion.

Looking at margins again, I think it might need a bit of work as axes.margins(.1, xmargin=.2) will set both margins to .1, which is not what I would expect. OTOH, this isn't really a documented call signature, but it will raise no errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ 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
View
4 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
Something went wrong with that request. Please try again.