From: Mark Bakker <markbak@gm...>  20051014 20:59:34

Hello all  I finally found time to fix the axis('scaled') feature. It is now consistent when zooming, as requested. In essence, it works the same as axis('equal'), but fixes the lowerlefthand corner rather than the center of the subplot. When using axis('scaled') the _autoscaleon is set to False, so that axis limits will be fixed when features are added to the figure. You can overwrite this by setting it the regular way (also works for axis('equal')) ax.set_autoscale_on(False). My last modification is a prototype implementation of zooming when two axes are linked. The idea behind this is that when an axis is 'equal' or 'scaled' and another axis is linked to this axis, that when you are zooming and changing the size of the subplot, then the size of the linkes axis should change accordingly. I use this when I am contouring 2D horizontal data and have a vertical crosssection linked to the xaxis of the horizontal plot. When I zoom in on the horizontal plot, the length of the linked axis now gets changes too! Works great, actually, but has been implemented for linked xaxis only for now. It works when zooming in the horizontal data (which has axis 'equal'), but not yet when zooming in the linked vertical crosssection. Still working on it. Anyway, I modified 3 files, which I submitted on the patches page. If anybody is interested, download these and let me know what you think. I presume they'll get implemented in CVS when John or others find the time to do so. Mark 
From: Helge Avlesen <helgea@gm...>  20051017 15:44:03
Attachments:
Message as HTML

On 10/14/05, Mark Bakker <markbak@...> wrote: > > Hello all  > > I finally found time to fix the axis('scaled') feature. > It is now consistent when zooming, as requested. > In essence, it works the same as axis('equal'), but fixes the > lowerlefthand corner rather than the center of the > subplot. When using axis('scaled') the _autoscaleon is > set to False, so that axis limits will be fixed when > features are added to the figure. You can overwrite this > by setting it the regular way (also works for axis('equal')) > ax.set_autoscale_on(False). > > My last modification is a prototype implementation of > zooming when two axes are linked. The idea behind this > is that when an axis is 'equal' or 'scaled' and another > axis is linked to this axis, that when you are zooming and > changing the size of the subplot, then the size of the > linkes axis should change accordingly. I use this when > I am contouring 2D horizontal data and have a vertical > crosssection linked to the xaxis of the horizontal plot. > When I zoom in on the horizontal plot, the length of the > linked axis now gets changes too! Works great, actually, > but has been implemented for linked xaxis only for now. > It works when zooming in the horizontal data (which > has axis 'equal'), but not yet when zooming in the > linked vertical crosssection. Still working on it. Hi, yes this is a step in the right direction! IMO it would also be nice with functionality for zooming in/out on single clicks with the left and right button, e.g. something like the below for backend_bases.py: (hope it is not wrapped to death...) Helge <pre> ... def release_zoom(...): ... # single click: 5 pixels is a threshold if abs(xlastx)<5 or abs(ylasty)<5: lastx, lasty =3D a.transData.inverse_xy_tup( (lastx, lasty) ) x, y =3D a.transData.inverse_xy_tup( (x, y) ) Xmin,Xmax=3Da.get_xlim() Ymin,Ymax=3Da.get_ylim() if self._button_pressed =3D=3D 1: # zoom in by 20%, make point clicked center dx=3D(XmaxXmin)*0.8*0.5 dy=3D(YmaxYmin)*0.8*0.5 a.set_xlim((xdx, x+dx)) a.set_ylim((ydy, y+dy)) elif self._button_pressed =3D=3D 3: # zoom out by 20%, make point clicked center dx=3D(XmaxXmin)*1.2*0.5 dy=3D(YmaxYmin)*1.2*0.5 a.set_xlim((xdx, x+dx)) a.set_ylim((ydy, y+dy)) self.draw() self._xypress =3D None self._button_pressed =3D=3D None self.push_current() self.release(event) return # zoom to rect ... </pre> 
From: Mark Bakker <markbak@gm...>  20051018 17:21:22

Helge and others  I really like Helge's idea to zoom by 20% in Toolbar2 if you click once onl= y. Will even try to center it near the click if possible. Will try to implement a version of her code this week. Incidentally, I found a bug and an inconsistency in my axis('scaled') implementation. The new pylab file on the patches page is fixed. Mark On 10/17/05, Helge Avlesen <helgea@...> wrote: > > > > On 10/14/05, Mark Bakker <markbak@...> wrote: > > Hello all  > > > > I finally found time to fix the axis('scaled') feature. > > It is now consistent when zooming, as requested. > > In essence, it works the same as axis('equal'), but fixes the > > lowerlefthand corner rather than the center of the > > subplot. When using axis('scaled') the _autoscaleon is > > set to False, so that axis limits will be fixed when > > features are added to the figure. You can overwrite this > > by setting it the regular way (also works for axis('equal')) > > ax.set_autoscale_on(False). > > > > My last modification is a prototype implementation of > > zooming when two axes are linked. The idea behind this > > is that when an axis is 'equal' or 'scaled' and another > > axis is linked to this axis, that when you are zooming and > > changing the size of the subplot, then the size of the > > linkes axis should change accordingly. I use this when > > I am contouring 2D horizontal data and have a vertical > > crosssection linked to the xaxis of the horizontal plot. > > When I zoom in on the horizontal plot, the length of the > > linked axis now gets changes too! Works great, actually, > > but has been implemented for linked xaxis only for now. > > It works when zooming in the horizontal data (which > > has axis 'equal'), but not yet when zooming in the > > linked vertical crosssection. Still working on it. > > > Hi, > yes this is a step in the right direction! IMO it would also be nice wit= h > functionality for > zooming in/out on single clicks with the left and right button, e.g. > something like the below for backend_bases.py: (hope it is not wrapped t= o > death...) > > Helge > > > <pre> > ... > def release_zoom(...): > ... > # single click: 5 pixels is a threshold > if abs(xlastx)<5 or abs(ylasty)<5: > > lastx, lasty =3D a.transData.inverse_xy_tup( (lastx, lasty) ) > x, y =3D a.transData.inverse_xy_tup ( (x, y) ) > Xmin,Xmax=3Da.get_xlim() > Ymin,Ymax=3Da.get_ylim() > > if self._button_pressed =3D=3D 1: > > # zoom in by 20%, make point clicked center > dx=3D(XmaxXmin)* 0.8*0.5 > dy=3D(YmaxYmin)*0.8*0.5 > a.set_xlim((xdx, x+dx)) > a.set_ylim((ydy, y+dy)) > > elif self._button_pressed =3D=3D 3: > > # zoom out by 20%, make point clicked center > dx=3D(XmaxXmin)*1.2*0.5 > dy=3D(YmaxYmin)*1.2*0.5 > a.set_xlim((xdx, x+dx)) > a.set_ylim ((ydy, y+dy)) > > self.draw() > self._xypress =3D None > self._button_pressed =3D=3D None > > self.push_current() > self.release(event) > return > > # zoom to rect > ... > </pre> > > > > 