William Stein wrote: > On Mon, Sep 14, 2009 at 1:26 PM, Eric Jackson <[email protected]> wrote: >> I'm not thinking of matplotlib html5. However, I am fairly new to >> working with Sage. I will do some research to see what matplotlib >> html5 is about. >> >> As far as what I'm doing, I've created a plot of a function, say sin >> (t) that is evaluated from t, -2*pi,2*pi. As I am viewing the plot, >> I would like to move my cursor along the sin(t) curve and in real time >> see what the xy coordinates are at various locations on the curve. >> >> Eric > > I think the easiest way to do this would be with javascript, and a > careful knowledge of how matplotlib coordinates correspond to png > image coordinates. >
You can get the transform that describes the display pixel -> data coordinates straight from matplotlib. We could ship that to the browser with the plot, then the browser could do the matrix multiplication on its own. See http://matplotlib.sourceforge.net/users/transforms_tutorial.html In particular, "You can use the inverted() method to create a transform which will take you from display to data coordinates: In [41]: inv = ax.transData.inverted() In [42]: type(inv) Out[42]: <class 'matplotlib.transforms.CompositeGenericTransform'> In [43]: inv.transform((335.175, 247.)) Out[43]: array([ 5., 0.]) It would also be useful to peruse the definition of the transformation pipeline: http://matplotlib.sourceforge.net/users/transforms_tutorial.html#the-transformation-pipeline Jason -- Jason Grout --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---
