|
From: <ef...@us...> - 2010-06-09 17:57:46
|
Revision: 8402
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8402&view=rev
Author: efiring
Date: 2010-06-09 17:57:36 +0000 (Wed, 09 Jun 2010)
Log Message:
-----------
Axes.grid controls minor and/or major lines; axis.grid allows 'both'
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/axes.py
trunk/matplotlib/lib/matplotlib/axis.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2010-06-09 03:04:53 UTC (rev 8401)
+++ trunk/matplotlib/CHANGELOG 2010-06-09 17:57:36 UTC (rev 8402)
@@ -1,3 +1,7 @@
+2010-06-09 Allow Axes.grid to control minor gridlines; allow
+ Axes.grid and Axis.grid to control major and minor
+ gridlines in the same method call. - EF
+
2010-06-06 Change the way we do split/dividend adjustments in
finance.py to handle dividends and fix the zero division bug reported
in sf bug 2949906. Note that volume is not adjusted
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2010-06-09 03:04:53 UTC (rev 8401)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2010-06-09 17:57:36 UTC (rev 8402)
@@ -1957,19 +1957,22 @@
self._axisbelow = b
@docstring.dedent_interpd
- def grid(self, b=None, **kwargs):
+ def grid(self, b=None, which='major', **kwargs):
"""
call signature::
- grid(self, b=None, **kwargs)
+ grid(self, b=None, which='major', **kwargs)
Set the axes grids on or off; *b* is a boolean. (For Matlab
compatibility, *b* may also be a string, 'on' or 'off'.)
If *b* is *None* and ``len(kwargs)==0``, toggle the grid state. If
*kwargs* are supplied, it is assumed that you want a grid and *b*
- is thus set to *True*
+ is thus set to *True*.
+ *which* can be 'major' (default), 'minor', or 'both' to control
+ whether major tick grids, minor tick grids, or both are affected.
+
*kawrgs* are used to set the grid line properties, eg::
ax.grid(color='r', linestyle='-', linewidth=2)
@@ -1981,8 +1984,8 @@
if len(kwargs):
b = True
b = _string_to_bool(b)
- self.xaxis.grid(b, **kwargs)
- self.yaxis.grid(b, **kwargs)
+ self.xaxis.grid(b, which=which, **kwargs)
+ self.yaxis.grid(b, which=which, **kwargs)
def ticklabel_format(self, **kwargs):
"""
Modified: trunk/matplotlib/lib/matplotlib/axis.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axis.py 2010-06-09 03:04:53 UTC (rev 8401)
+++ trunk/matplotlib/lib/matplotlib/axis.py 2010-06-09 17:57:36 UTC (rev 8402)
@@ -1002,7 +1002,7 @@
def grid(self, b=None, which='major', **kwargs):
"""
Set the axis grid on or off; b is a boolean. Use *which* =
- 'major' | 'minor' to set the grid for major or minor ticks.
+ 'major' | 'minor' | 'both' to set the grid for major or minor ticks.
If *b* is *None* and len(kwargs)==0, toggle the grid state. If
*kwargs* are supplied, it is assumed you want the grid on and *b*
@@ -1013,14 +1013,15 @@
xax.grid(color='r', linestyle='-', linewidth=2)
"""
if len(kwargs): b = True
- if which.lower().find('minor')>=0:
+ which = which.lower()
+ if which in ['minor', 'both']:
if b is None: self._gridOnMinor = not self._gridOnMinor
else: self._gridOnMinor = b
for tick in self.minorTicks: # don't use get_ticks here!
if tick is None: continue
tick.gridOn = self._gridOnMinor
if len(kwargs): artist.setp(tick.gridline,**kwargs)
- if which.lower().find('major')>=0:
+ if which in ['major', 'both']:
if b is None: self._gridOnMajor = not self._gridOnMajor
else: self._gridOnMajor = b
for tick in self.majorTicks: # don't use get_ticks here!
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|