Rich Shepard wrote:
> On Tue, 27 Nov 2007, Michael Droettboom wrote:
> 
>> Yes.  You can do
>>
>>      from pylab import *
>>      ...
>>      axes().grid(True) # For both axes
>>      axes().xaxis.grid(True) # Just x
>>      axes().yaxis.grid(True) # Just y
>>
>> Rather than just an on/off boolean, you can also provide line styles:
>>
>>      axes().grid(color='r', linestyle='-', linewidth=2)
> 
> Mike,
> 
>    Ah, now I see the syntax for using axes(). However, if I'm embedding the
> plots in a wxPython panel, I'm not using pylab. In this environment I also
> haven't yet figured out how to add axis labels or specify the range of each
> axis. Within pylab on stand-alone test apps it works fine.

You can get the axes through the Figure instance.  (I don't know how you 
have your embedding set up, but if it's something like 
embedding_in_wx.py, there's the line "self.fig = Figure((9, 8), 75)", so 
self.fig is a Figure instance).

   self.fig.gca() # gets the current axes
   self.fig.axes  # is a Python list of axes -- useful if you have more 
than one and you need to access a particular one of them

So, to do stuff with the grid:

   self.fig.gca().grid(True)

To answer your other questions:

   axes = self.fig.gca()
   axes.set_xlabel("This is the x-axis label")
   axes.set_ylabel("This is the y-axis label")
   axes.set_xlim((-1.25, 1.25))
   axes.set_ylim((-2.0, 2.0))

Cheers,
Mike

-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to