Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

## matplotlib-users

 [Matplotlib-users] Pixel coordinates and plot_date() From: Erik Cederstrand - 2008-01-10 22:07:42 ```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, Erik ```
 Re: [Matplotlib-users] Pixel coordinates and plot_date() From: Erik Cederstrand - 2008-01-11 09:10:12 ```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 ```