SF.net SVN: matplotlib:[8402] trunk/matplotlib
Revision: 8402
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8402&view=rev
Author: efiring
Date: 2010-06-09 17:57:36 + (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.
--
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
___
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
SF.net SVN: matplotlib:[8403] trunk/matplotlib
Revision: 8403 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8403&view=rev Author: jdh2358 Date: 2010-06-09 22:05:09 + (Wed, 09 Jun 2010) Log Message: --- fix legend doc typos Modified Paths: -- trunk/matplotlib/CHANGELOG trunk/matplotlib/doc/users/legend_guide.rst Modified: trunk/matplotlib/CHANGELOG === --- trunk/matplotlib/CHANGELOG 2010-06-09 17:57:36 UTC (rev 8402) +++ trunk/matplotlib/CHANGELOG 2010-06-09 22:05:09 UTC (rev 8403) @@ -4,7 +4,7 @@ 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 + in sf bug 2949906 and 2123566. Note that volume is not adjusted because the Yahoo CSV does not distinguish between share split and dividend adjustments making it near impossible to get volume adjustement right (unless we want to guess based Modified: trunk/matplotlib/doc/users/legend_guide.rst === --- trunk/matplotlib/doc/users/legend_guide.rst 2010-06-09 17:57:36 UTC (rev 8402) +++ trunk/matplotlib/doc/users/legend_guide.rst 2010-06-09 22:05:09 UTC (rev 8403) @@ -12,14 +12,14 @@ The legend command has a following call signature:: - + legend(*args, **kwargs) - + If len(args) is 2, the first argument should be a list of artist to be labeled, and the second argument should a list of string labels. If len(args) is 0, it automatically generate the legend from label properties of the child artists by calling -:meth:`~matplotlib.axes.Axes.get_legend_handles_labels` method. +:meth:`~matplotlib.axes.Axes.get_legend_handles_labels` method. For example, *ax.legend()* is equivalent to:: handles, labels = ax.get_legend_handles_labels() @@ -44,7 +44,7 @@ * :class:`~matplotlib.patches.Patch` * :class:`~matplotlib.collections.LineCollection` * :class:`~matplotlib.collections.RegularPolyCollection` - + Unfortunately, there is no easy workaround when you need legend for an artist not in the above list (You may use one of the supported artist as a proxy. See below), or customize it beyond what is @@ -84,28 +84,28 @@ p1, = ax.plot([1,2,3], label="line 1") p2, = ax.plot([3,2,1], label="line 2") p3, = ax.plot([2,3,1], label="line 3") - + handles, labels = ax.get_legend_handles_labels() # reverse the order ax.legend(handles[::-1], labels[::-1]) - + # or sort them by labels import operator hl = sorted(zip(handles, labels), key=operator.itemgetter(1)) handles2, labels2 = zip(*hl) - + ax.legend(handles2, labels2) Using Proxy Artist -- -When you want to display legend for an artist not supported by the -matplotlib, you may use other supported artist as a proxy. For -example, you may creates an proxy artist without adding it to the axes -(so the proxy artist will not be drawn in the main axes) and feet it +When you want to display legend for an artist not supported by +matplotlib, you may use another artist as a proxy. For +example, you may create a proxy artist without adding it to the axes +(so the proxy artist will not be drawn in the main axes) and feed it to the legend function.:: p = Rectangle((0, 0), 1, 1, fc="r") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. -- ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo ___ Matplotlib-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
SF.net SVN: matplotlib:[8404] trunk/matplotlib/lib/matplotlib/figure.py
Revision: 8404 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8404&view=rev Author: jdh2358 Date: 2010-06-10 01:59:13 + (Thu, 10 Jun 2010) Log Message: --- added bbox_inches and pad_inches to savefig signature Modified Paths: -- trunk/matplotlib/lib/matplotlib/figure.py Modified: trunk/matplotlib/lib/matplotlib/figure.py === --- trunk/matplotlib/lib/matplotlib/figure.py 2010-06-09 22:05:09 UTC (rev 8403) +++ trunk/matplotlib/lib/matplotlib/figure.py 2010-06-10 01:59:13 UTC (rev 8404) @@ -992,7 +992,7 @@ savefig(fname, dpi=None, facecolor='w', edgecolor='w', orientation='portrait', papertype=None, format=None, - transparent=False): + transparent=False, bbox_inches=None, pad_inches=0.1): Save the current figure. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. -- ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo ___ Matplotlib-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
