|
From: Julius L. <jul...@gm...> - 2006-02-20 23:01:14
|
On 2/15/06, John Hunter <jdh...@ac...> wrote: > >>>>> "Charlie" =3D=3D Charlie Moad <cw...@gm...> writes: > > Charlie> You could use html image maps to accomplish this. > Charlie> Obviously this would be in the context of a web page. I > Charlie> think frontpage or dreamweaver has some nice tools for > Charlie> creating these. Just google "html image maps" for more > Charlie> info. > > Andrew Dalke has a tutorial on creating html image maps with > matplotlib > > http://www.dalkescientific.com/writings/diary/archive/2005/04/24/interact= ive_html.html > > JDH > This tutorial was a start. I want to do a similar thing, but use rectangle objects for the image map, whose coordinates are derived from matplotlib polygon objects. I was wondering if anyone knew how to do this, or could point me to some documentation. Basically I have a simple figure: > from pylab import * clf() fig =3D figure(1,(4,4)) ax =3D axis() pl =3D plot(range(0,10),range(0,10),'b-') box =3D axvspan(3,5,fc=3D'm',alpha=3D0.5) #get vertices [(ul.x,ul.y),(lr.x,lr.y)] #ul =3D upper left #lr =3D lower right #have to multiply ul.y by the upper ylim since for axvspan, ul.y=3D1 spans the range b_verts =3D box.get_verts() verts =3D [(b_verts[1][0],b_verts[1][1]*ax.get_ylim()[1]),(b_verts[3][0],b_= verts[3][1])] > my question is what transform do I use to convert verts to pixel coordinate= s? ax.get_transform() does not work. Should I use pl.get_transform? Thanks for your help! Cheers, Julius |