Unfortunately, Sage doesn't *yet* have this capability. It will in
the near future.
William
> It will in the near future.
Are you thinking of the matplotlib html5 canvas backend that is being
developed? Or is there something else that you are doing?
Jason
I'm going to do *something*. I think there are numerous ways to solve
this problem if one tries hard. First I would do something with
javascript and png's for complete compatibility with our existing
infrastructure, but of course that's just one thing.
William
Well, then just for reference, here is a recent matplotlib thread from
someone working on an html5 canvas backend to matplotlib:
They might be interested in collaborating, or motivated if they saw
their work being used immediately.
Of course, this doesn't address moderately old or dysfunctional browsers
that don't have html5 canvas.
Jason
It's not finished. Here is a demo of what gnuplot can do with an html5
canvas backend:
http://gnuplot.sourceforge.net/demo_canvas/
(notice the coordinates at the bottom of the plot).
Jason
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.
William
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
Here's an example of the matplotlib canvas backend:
http://dl.getdropbox.com/u/178748/mpl/test.html
(it doesn't have the coordinate tracking feature implemented, I think).
Jason
--
Jason Grout
You can't use "show". Use "savefig", as in:
savefig('test.png')
The sage notebook automatically displays any graphic file you generate
in a cell. That's why we need to save the figure to a graphics file,
like test.png. Then the notebook comes along, sees that the cell
generated a graphic file, and displays it.
>
> *However, the code in cell 4, is where I really need the help. The
> code in cell 4 is suppose to display the xy data at a certain location
> on the line plot. I have looked at this for a while, but I am
> confused as to why it doesn't work. This code was also taken from the
> mathplotlib website. Any help on this in particular would be neat.
> In my spare time, I will continue to work on this.
Just change the last line to "plt.savefig..." just like the first cell.
It's not "savefile", it's "savefig" :).
Thanks,
Jason