Replying to myself...

Erik Cederstrand wrote:
> Hi!
> 
> I'm trying to make a clickable plot_date() plot (using the Pylons 
> framework). What I need is the pixel coordinates of the data points I 
> give to plot_date(), but the trans.seq_x_y() function doesn't like 
> Datetime:
> 
>    >>  xcoords, ycoords = trans.seq_x_y(x, y)
>    float() argument must be a string or a number
> 
> How can I get the pixel coordinates?
> 
> Here are the relevant parts of my code (x is Datetime, y is float):
> 
>         figure = pylab.figure(figsize=(6,4), dpi=100, frameon=False)
>         ax = figure.add_subplot(111)
> 
>         # quick simple scatter plot
>         ax.plot_date(x, y, 'ro')
> 
>         # Convert the data set points into screen space coordinates
>         trans = ax.get_transform()
>         xcoords, ycoords = trans.seq_x_y(x, y)

Thanks to the excellent documentation, I solved this by using 
dates.date2num():

        xcoords, ycoords = trans.seq_x_y(dates2num(x), y)

Erik

-------------------------------------------------------------------------
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-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to