On 9/26/07, JeanMichel FRANCOIS <[EMAIL PROTECTED]> wrote:
> Hi there!
>  I m trying to make a figure , adding a subplot in it, and then specify the X
> axis with date. I don't have anything to plot at the moment, i just want to
> generate a subplot with axes X and Y up and ready.
>
> All tutorials i have read directly plot sth on the subplot directly, but i
> don't want this in my software.
>
> here is an extract from my code
>
>   visitor.figure = pylab.figure(1)
>   visitor.figure.clear()
>   visitor.figure.set_dpi(self.context.getDPI())
>   visitor.figure.set_edgecolor(self.context.getEdgeColor())
>   visitor.figure.set_facecolor(self.context.getFaceColor())
>   visitor.figure.set_figheight(self.context.getSizeHeight())
>   visitor.figure.set_figwidth(self.context.getSizeWidth())
>   visitor.subplot = visitor.figure.add_subplot(111)
>   visitor.subplot.set_title(self.context.title)
>
> Then the user add his xaxis with parameters like xmin, xmax, step, ...
> But here i don't find how to setup this with pylab.
>
>   xaxis = subplot.get_xaxis()

xaxis = subplot.xaxis

> here i don't know how to proceed to set my array of values.
> I have an array of date.

You can plot your array of dates with :

  import matplotlib.dates as mdates
  l = ax.plot_date(mdates.date2num(mydates), y, 'k-')

Later you can modify the xlimits:

  subplot.set_xlim(mdates.date2num(datetime.date(2007,1,1)),
                          mdates.date2num(datetime.date(2007,7,1)))

or your plot data

  l.set_data(newdates, newy)

With recent versions of matplotlib, you can pas dates in directory to
plot and set_xlim and friends ( you don't need to convert them with
date2num).  Eg, with

  ax.plot(mydates, y)
  ax.set_xlim(datetime.date(2007,1,1), datetime.date(2007,7,1))
  fig.autofmt_xdate()

JDH

-------------------------------------------------------------------------
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