On Sunday 18 April 2010 00:52:57 Gökhan Sever wrote:
> Hello,
>
> Let say we have a figure created by:
>
> plt.plot(range(100))
>
> On WX backend plt.grid(1) or key "G" responds finely for turning on/off the
> grid lines. However when I log-scale both axes then plt.grid(1 or 0) or "G"
> doesn't respond on minor grid lines.
>
> Is there a way to control this behavior?
>
> Thanks.

Hi Gökhan,

I can confirm your findings and I hope my attached patch (against current svn) 
solves this problem. In the axes.grid the boolean 'b' was set to 'True' if 
the kwarg 'which' was suplied, because it was part of the **kwargs and so 
always b was True in the axis (e.g. ax.xaxis).

Now I get a grid on the minor-ticks by calling:

ax.grid(True, which="majorminor")

and remove the the minortick-grid lines / all grid lines by calling

ax.grid(False, which="minor")
ax.grid(False, which="majorminor")

Kind regards,
Matthias
Index: lib/matplotlib/axes.py
===================================================================
--- lib/matplotlib/axes.py	(revision 8242)
+++ lib/matplotlib/axes.py	(working copy)
@@ -1839,19 +1839,20 @@
         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)
 
-        Set the axes grids on or off; *b* is a boolean
-
+        Set the axes grids on or off; *b* is a boolean. Use *which* =
+        'major' | 'minor' 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 that you want a grid and *b*
         is thus set to *True*
 
-        *kawrgs* are used to set the grid line properties, eg::
+        *kwargs* are used to set the grid line properties, eg::
 
           ax.grid(color='r', linestyle='-', linewidth=2)
 
@@ -1860,8 +1861,8 @@
         %(Line2D)s
         """
         if len(kwargs): b = True
-        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):
         """
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to