Revision: 4772
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4772&view=rev
Author:   mdboom
Date:     2007-12-18 13:09:25 -0800 (Tue, 18 Dec 2007)

Log Message:
-----------
Better docstrings for set_x/yscale and friends.

Modified Paths:
--------------
    branches/transforms/lib/matplotlib/axes.py
    branches/transforms/lib/matplotlib/pyplot.py
    branches/transforms/lib/matplotlib/scale.py

Modified: branches/transforms/lib/matplotlib/axes.py
===================================================================
--- branches/transforms/lib/matplotlib/axes.py  2007-12-18 21:08:19 UTC (rev 
4771)
+++ branches/transforms/lib/matplotlib/axes.py  2007-12-18 21:09:25 UTC (rev 
4772)
@@ -1651,25 +1651,18 @@
             ", ".join(mscale.get_scale_names()))
        return self.xaxis.get_scale()
 
-    # MGDTODO: Update docstring
     def set_xscale(self, value, **kwargs):
         """
         SET_XSCALE(value)
 
-        Set the xscaling: %(scale)s
+        Set the scaling of the x-axis: %(scale)s
 
-        If value is 'log', the additional kwargs have the following meaning
-
-            * basex: base of the logarithm
-
-            * subsx: a sequence of the location of the minor ticks;
-              None defaults to autosubs, which depend on the number of
-              decades in the plot.  Eg for base 10, subsx=(1,2,5) will
-              put minor ticks on 1,2,5,11,12,15,21, ....To turn off
-              minor ticking, set subsx=[]
-
         ACCEPTS: [%(scale)s]
-        """ % {'scale': ' | '.join([repr(x) for x in 
mscale.get_scale_names()])}
+
+        Different kwargs are accepted, depending on the scale:
+        %(scale_docs)s
+        """ % {'scale': ' | '.join([repr(x) for x in 
mscale.get_scale_names()]),
+               'scale_docs': mscale.get_scale_docs().strip()}
         self.xaxis.set_scale(value, **kwargs)
         self.autoscale_view()
         self._update_transScale()
@@ -1815,22 +1808,16 @@
 
     def set_yscale(self, value, **kwargs):
         """
-        SET_YSCALE(value, basey=10, subsy=None)
+        SET_YSCALE(value)
 
-        Set the yscaling: %(scale)s
+        Set the scaling of the y-axis: %(scale)s
 
-        If value is 'log', the additional kwargs have the following meaning
+        ACCEPTS: [%(scale)s]
 
-            * basey: base of the logarithm
-
-            * subsy: a sequence of the location of the minor ticks;
-              None defaults to autosubs, which depend on the number of
-              decades in the plot.  Eg for base 10, subsy=(1,2,5) will
-              put minor ticks on 1,2,5,11,12,15, 21, ....To turn off
-              minor ticking, set subsy=[]
-
-        ACCEPTS: %(scale)s
-        """ % {'scale': ' | '.join([repr(x) for x in 
mscale.get_scale_names()])}
+        Different kwargs are accepted, depending on the scale:
+        %(scale_docs)s
+        """ % {'scale': ' | '.join([repr(x) for x in 
mscale.get_scale_names()]),
+               'scale_docs': mscale.get_scale_docs().strip()}
         self.yaxis.set_scale(value, **kwargs)
         self.autoscale_view()
         self._update_transScale()

Modified: branches/transforms/lib/matplotlib/pyplot.py
===================================================================
--- branches/transforms/lib/matplotlib/pyplot.py        2007-12-18 21:08:19 UTC 
(rev 4771)
+++ branches/transforms/lib/matplotlib/pyplot.py        2007-12-18 21:09:25 UTC 
(rev 4772)
@@ -12,7 +12,7 @@
 from matplotlib.axes import Axes
 from matplotlib.projections import PolarAxes
 from matplotlib import mlab  # for csv2rec in plotfile
-from matplotlib.scale import get_scale_names
+from matplotlib.scale import get_scale_docs, get_scale_names
 
 from matplotlib import cm
 from matplotlib.cm import get_cmap
@@ -727,26 +727,34 @@
     return ret
 
 
-# MGDTODO: Update docstring
 def xscale(*args, **kwargs):
     """
     SET_XSCALE(value)
 
-    Set the xscaling: %(scale)s
-    """ % {'scale': ' | '.join([repr(x) for x in get_scale_names()])}
+    Set the scaling for the x-axis: %(scale)s
+
+    Different keywords may be accepted, depending on the scale:
+
+    %(scale_docs)s
+    """ % {'scale': ' | '.join([repr(x) for x in get_scale_names()]),
+           'scale_docs': get_scale_docs()}
     ax = gca()
     ret = ax.set_xscale(*args, **kwargs)
     draw_if_interactive()
     return ret
 
 
-# MGDTODO: Update docstring
 def yscale(*args, **kwargs):
     """
     SET_YSCALE(value)
 
-    Set the yscaling: %(scale)s
-    """ % {'scale': ' | '.join([repr(x) for x in get_scale_names()])}
+    Set the scaling for the y-axis: %(scale)s
+
+    Different keywords may be accepted, depending on the scale:
+
+    %(scale_docs)s
+    """ % {'scale': ' | '.join([repr(x) for x in get_scale_names()]),
+           'scale_docs': get_scale_docs()}
     ax = gca()
     ret = ax.set_yscale(*args, **kwargs)
     draw_if_interactive()

Modified: branches/transforms/lib/matplotlib/scale.py
===================================================================
--- branches/transforms/lib/matplotlib/scale.py 2007-12-18 21:08:19 UTC (rev 
4771)
+++ branches/transforms/lib/matplotlib/scale.py 2007-12-18 21:09:25 UTC (rev 
4772)
@@ -1,3 +1,4 @@
+import textwrap
 import numpy as npy
 from matplotlib.numerix import npyma as ma
 MaskedArray = ma.MaskedArray
@@ -2,2 +3,3 @@
 
+from cbook import dedent
 from ticker import NullFormatter, ScalarFormatter, LogFormatterMathtext, 
Formatter
@@ -30,6 +32,8 @@
     name = 'linear'
 
     def __init__(self, axis, **kwargs):
+        """
+        """
         pass
 
     def set_default_locators_and_formatters(self, axis):
@@ -167,6 +171,12 @@
 
 
     def __init__(self, axis, **kwargs):
+        """
+        basex/basey: The base of the logarithm
+
+        subsx/subsy: The number of subticks to draw between each major
+        tick
+        """
         if axis.axis_name == 'x':
             base = kwargs.pop('basex', 10.0)
             subs = kwargs.pop('subsx', None)
@@ -262,6 +272,16 @@
             return SymmetricalLogScale.SymmetricalLogTransform(self.base)
 
     def __init__(self, axis, **kwargs):
+        """
+        basex/basey: The base of the logarithm
+
+        linthreshx/linthreshy: The range (-x, x) within which the plot
+        is linear (to avoid having the plot go to infinity around
+        zero).
+
+        subsx/subsy: The number of subticks to render between each
+        major tick.
+        """
         if axis.axis_name == 'x':
             base = kwargs.pop('basex', 10.0)
             linthresh = kwargs.pop('linthreshx', 2.0)
@@ -342,6 +362,9 @@
             return MercatorLatitudeScale.MercatorLatitudeTransform(self.thresh)
 
     def __init__(self, axis, **kwargs):
+        """
+        thresh: The degree above which to crop the data.
+        """
         thresh = kwargs.pop("thresh", (85 / 180.0) * npy.pi)
         if thresh >= npy.pi / 2.0:
             raise ValueError("thresh must be less than pi/2")
@@ -393,3 +416,16 @@
     names = _scale_mapping.keys()
     names.sort()
     return names
+
+def get_scale_docs():
+    docs = []
+    for name in get_scale_names():
+        scale_class = _scale_mapping[name]
+        docs.append("    '%s'" % name)
+        docs.append("")
+        class_docs = textwrap.wrap(
+            dedent(scale_class.__init__.__doc__), initial_indent=" " * 8,
+            subsequent_indent = " " * 8)
+        docs.extend(class_docs)
+        docs.append("")
+    return "\n".join(docs)


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to