Skip to content

Conversation

tonysyu
Copy link
Contributor

@tonysyu tonysyu commented Oct 30, 2013

Vertical image plots don't interact with the zoom tool correctly. Run the example below and use the scroll wheel to zoom out. As you zoom back in, the image jumps back and forth.

from scipy.misc import lena

from enable.api import Component, ComponentEditor
from traits.api import HasTraits, Instance
from traitsui.api import UItem, View
from chaco.api import ArrayPlotData, Plot
from chaco.tools.api import PanTool, ZoomTool


class Demo(HasTraits):
    plot = Instance(Component)

    traits_view = View(
        UItem('plot', editor=ComponentEditor(size=(600, 600))),
        resizable=True
    )

    def _plot_default(self):
        pd = ArrayPlotData(imagedata=lena())
        plot = Plot(pd, orientation='v')
        plot.img_plot("imagedata")

        plot.tools.append(PanTool(plot, constrain_key="shift"))
        plot.overlays.append(ZoomTool(component=plot, always_on=False))
        return plot


if __name__ == "__main__":
    demo = Demo()
    demo.configure_traits()

@jwiggins
Copy link
Member

This certainly fixes the zooming issue, but it needs to be tested against lots of existing code before merging.

When running my current consulting project with this change, panning of image plots is a little wonky. That's likely due to some stupidity on my end (you're familiar with the code...), but it wasn't something I was expecting.

@tonysyu
Copy link
Contributor Author

tonysyu commented Oct 30, 2013

I just reverted changes to image_plot and left the changes to the zoom tool. The changes to image_plot were related to other issues anyway.

@tonysyu
Copy link
Contributor Author

tonysyu commented Oct 30, 2013

Just for reference, the "other issue" occurs when you replace the Plot call in the example with

plot = Plot(pd, default_origin='top left', orientation='v')

The change in origin causes zooming to slow down drastically at high zoom levels.

@tonysyu tonysyu mentioned this pull request Jun 4, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants