On 05/05/2010 08:46 AM, Chloe Lewis wrote:
> I got curious and looked for the grid command in matplotlib/axes.py.
> Looks like an inherited-from-Matlab thing. In the cla (clear axis)
> function of the Axes class:
>
>           self._gridOn = rcParams['axes.grid']
>           #...
>           self.grid(self._gridOn)
>
> and grid() passes its argument on to the xaxis.grid and yaxis.grid.
>
> I haven't found the code that checks any of those settings to decide
> whether the gridline objects are to be drawn or not (??) but I think
> we can rule out Harry Potter. Not magic: adaptation. (Or, if you will,
> not mystification: legacy code.)

Exactly.

The decision on whether to draw the gridlines is made in the draw() 
method of each Tick object; even if the gridlines exist, they may not be 
drawn.
There is no API for retrieving the grid state, and the grid() API, both 
at the Axes and the Axis level, is a bit complicated.  Although you 
can't retrieve the grid state (except by reading private attributes), 
you can set the grid to a known state, and you can toggle the state.

If there is a substantial need to read the grid state, we could expose 
it via a suitable API at the Axis level.  But is this important?

Eric

>
> &C
>
>
> On May 4, 2010, at 3:27 PM, Nico Schlömer wrote:
>
>> This is weird:
>>
>> When plotting something very simple, e.g.,
>>
>>         t = arange( 0.0, 2.0, 0.01 )
>>         s = sin( 2*pi*t )
>>         plot( t, s, ":" )
>>
>> I thought I can check weather the grid is on or off by
>>
>>    gca().get_xgridlines()
>>
>> -- but this *always* returns
>>
>> <a list of 5 Line2D xgridline objects>
>>
>> with *always* the same lines
>>
>> Line2D((0,0),(0,1))
>> Line2D((0,0),(0,1))
>> Line2D((0,0),(0,1))
>> Line2D((0,0),(0,1))
>> Line2D((0,0),(0,1))
>>
>> That's really independent of whether the grid is on or off.
>>
>> Is there any explanation for it that does not have to do with Harry
>> Potter or the Jedi? ;)
>>
>> --Nico
>>
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> Matplotlib-users mailing list
>> Matplotlib-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users



------------------------------------------------------------------------------
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to