plotting problem

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

plotting problem

Harold Mills
The script below demonstrates a problem I'm having with an ETS-based application that updates two plots (identical here to shorten the script) in response to changes to a single parameter. On my system (Windows Vista SP2, Python 2.7.2, ETS 4.0.0, wxPython 2.8.12.1), updates to the top plot in response to dragging the slider are snappy, but updates to the bottom plot and the text field are sluggish. Most of the time, the bottom plot and the text field do not not update during the drag, only at the end. Am I doing something wrong? What can I do to improve the responsiveness of the second plot and the text field?

Thanks,

    Harold Mills


from chaco.api import ArrayPlotData, DataRange1D, Plot
from enable.api import ComponentEditor
from traits.api import HasTraits, Instance, Range
from traitsui.api import Item, RangeEditor, VGroup, View
import numpy as np

TWO_PI = 2 * np.pi
N = 1000

class PlottingProblem(HasTraits):
    
    theta = Range(0., TWO_PI)
    plot_data = Instance(ArrayPlotData)
    plot_a = Instance(Plot)
    plot_b = Instance(Plot)
    
    traits_view = View(
        VGroup(
            Item('plot_a', editor = ComponentEditor(), show_label = False),
            Item('plot_b', editor = ComponentEditor(), show_label = False),
            Item('theta', label = 'Theta',
                 editor = RangeEditor(low = 0, high = TWO_PI))),
        title = 'Plotting Problem',
        width = 500,
        resizable = True)
    
    def __init__(self, *args, **kwargs):
        HasTraits.__init__(self, *args, **kwargs)
        self.plot_data = ArrayPlotData(x = TWO_PI * np.arange(N) / float(N))
        self._theta_changed()
        self.plot_a = self._create_plot()
        self.plot_b = self._create_plot()
        
    def _theta_changed(self):
        x = self.plot_data.get_data('x')
        self.plot_data.set_data('y', np.sin(x + self.theta))
        
    def _create_plot(self):
        plot = Plot(self.plot_data)
        plot.index_range = DataRange1D(low = 0, high = TWO_PI)
        plot.value_range = DataRange1D(low = -1, high = 1)
        plot.plot(('x', 'y'), type = 'line', name = 'sine')
        return plot
        
PlottingProblem().configure_traits()


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: plotting problem

Jaidev Deshpande
Hi,

On Fri, Mar 1, 2013 at 3:34 AM, Harold Mills <[hidden email]> wrote:

> The script below demonstrates a problem I'm having with an ETS-based
> application that updates two plots (identical here to shorten the script) in
> response to changes to a single parameter. On my system (Windows Vista SP2,
> Python 2.7.2, ETS 4.0.0, wxPython 2.8.12.1), updates to the top plot in
> response to dragging the slider are snappy, but updates to the bottom plot
> and the text field are sluggish. Most of the time, the bottom plot and the
> text field do not not update during the drag, only at the end. Am I doing
> something wrong? What can I do to improve the responsiveness of the second
> plot and the text field?
>
> Thanks,
>
>     Harold Mills
>
>
> from chaco.api import ArrayPlotData, DataRange1D, Plot
> from enable.api import ComponentEditor
> from traits.api import HasTraits, Instance, Range
> from traitsui.api import Item, RangeEditor, VGroup, View
> import numpy as np
>
> TWO_PI = 2 * np.pi
> N = 1000
>
> class PlottingProblem(HasTraits):
>
>     theta = Range(0., TWO_PI)
>     plot_data = Instance(ArrayPlotData)
>     plot_a = Instance(Plot)
>     plot_b = Instance(Plot)
>
>     traits_view = View(
>         VGroup(
>             Item('plot_a', editor = ComponentEditor(), show_label = False),
>             Item('plot_b', editor = ComponentEditor(), show_label = False),
>             Item('theta', label = 'Theta',
>                  editor = RangeEditor(low = 0, high = TWO_PI))),
>         title = 'Plotting Problem',
>         width = 500,
>         resizable = True)
>
>     def __init__(self, *args, **kwargs):
>         HasTraits.__init__(self, *args, **kwargs)
>         self.plot_data = ArrayPlotData(x = TWO_PI * np.arange(N) / float(N))
>         self._theta_changed()
>         self.plot_a = self._create_plot()
>         self.plot_b = self._create_plot()
>
>     def _theta_changed(self):
>         x = self.plot_data.get_data('x')
>         self.plot_data.set_data('y', np.sin(x + self.theta))
>
>     def _create_plot(self):
>         plot = Plot(self.plot_data)
>         plot.index_range = DataRange1D(low = 0, high = TWO_PI)
>         plot.value_range = DataRange1D(low = -1, high = 1)
>         plot.plot(('x', 'y'), type = 'line', name = 'sine')
>         return plot
>
> PlottingProblem().configure_traits()
>
>
> _______________________________________________
> Enthought-Dev mailing list
> [hidden email]
> https://mail.enthought.com/mailman/listinfo/enthought-dev
>

As far as I can tell the programme is correct. Have you tried changing
the backend to qt4? I tried it on both qt and wx and it works pretty
smoothly.

--
JD
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: plotting problem

Peter Wang-2
In reply to this post by Harold Mills
This code works fine on Mac and Qt.  Perhaps it's a Wx and Windows Vista problem?

-Peter


On Thu, Feb 28, 2013 at 4:04 PM, Harold Mills <[hidden email]> wrote:
The script below demonstrates a problem I'm having with an ETS-based application that updates two plots (identical here to shorten the script) in response to changes to a single parameter. On my system (Windows Vista SP2, Python 2.7.2, ETS 4.0.0, wxPython 2.8.12.1), updates to the top plot in response to dragging the slider are snappy, but updates to the bottom plot and the text field are sluggish. Most of the time, the bottom plot and the text field do not not update during the drag, only at the end. Am I doing something wrong? What can I do to improve the responsiveness of the second plot and the text field?

Thanks,

    Harold Mills


from chaco.api import ArrayPlotData, DataRange1D, Plot
from enable.api import ComponentEditor
from traits.api import HasTraits, Instance, Range
from traitsui.api import Item, RangeEditor, VGroup, View
import numpy as np

TWO_PI = 2 * np.pi
N = 1000

class PlottingProblem(HasTraits):
    
    theta = Range(0., TWO_PI)
    plot_data = Instance(ArrayPlotData)
    plot_a = Instance(Plot)
    plot_b = Instance(Plot)
    
    traits_view = View(
        VGroup(
            Item('plot_a', editor = ComponentEditor(), show_label = False),
            Item('plot_b', editor = ComponentEditor(), show_label = False),
            Item('theta', label = 'Theta',
                 editor = RangeEditor(low = 0, high = TWO_PI))),
        title = 'Plotting Problem',
        width = 500,
        resizable = True)
    
    def __init__(self, *args, **kwargs):
        HasTraits.__init__(self, *args, **kwargs)
        self.plot_data = ArrayPlotData(x = TWO_PI * np.arange(N) / float(N))
        self._theta_changed()
        self.plot_a = self._create_plot()
        self.plot_b = self._create_plot()
        
    def _theta_changed(self):
        x = self.plot_data.get_data('x')
        self.plot_data.set_data('y', np.sin(x + self.theta))
        
    def _create_plot(self):
        plot = Plot(self.plot_data)
        plot.index_range = DataRange1D(low = 0, high = TWO_PI)
        plot.value_range = DataRange1D(low = -1, high = 1)
        plot.plot(('x', 'y'), type = 'line', name = 'sine')
        return plot
        
PlottingProblem().configure_traits()


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev



_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: plotting problem

Jonathan Rocher
I just tested the code under Mac and Win 7 (both under qt and wx) and didn't have any issue either. 

Jonathan


On Mon, Mar 4, 2013 at 11:54 AM, Peter Wang <[hidden email]> wrote:
This code works fine on Mac and Qt.  Perhaps it's a Wx and Windows Vista problem?

-Peter


On Thu, Feb 28, 2013 at 4:04 PM, Harold Mills <[hidden email]> wrote:
The script below demonstrates a problem I'm having with an ETS-based application that updates two plots (identical here to shorten the script) in response to changes to a single parameter. On my system (Windows Vista SP2, Python 2.7.2, ETS 4.0.0, wxPython 2.8.12.1), updates to the top plot in response to dragging the slider are snappy, but updates to the bottom plot and the text field are sluggish. Most of the time, the bottom plot and the text field do not not update during the drag, only at the end. Am I doing something wrong? What can I do to improve the responsiveness of the second plot and the text field?

Thanks,

    Harold Mills


from chaco.api import ArrayPlotData, DataRange1D, Plot
from enable.api import ComponentEditor
from traits.api import HasTraits, Instance, Range
from traitsui.api import Item, RangeEditor, VGroup, View
import numpy as np

TWO_PI = 2 * np.pi
N = 1000

class PlottingProblem(HasTraits):
    
    theta = Range(0., TWO_PI)
    plot_data = Instance(ArrayPlotData)
    plot_a = Instance(Plot)
    plot_b = Instance(Plot)
    
    traits_view = View(
        VGroup(
            Item('plot_a', editor = ComponentEditor(), show_label = False),
            Item('plot_b', editor = ComponentEditor(), show_label = False),
            Item('theta', label = 'Theta',
                 editor = RangeEditor(low = 0, high = TWO_PI))),
        title = 'Plotting Problem',
        width = 500,
        resizable = True)
    
    def __init__(self, *args, **kwargs):
        HasTraits.__init__(self, *args, **kwargs)
        self.plot_data = ArrayPlotData(x = TWO_PI * np.arange(N) / float(N))
        self._theta_changed()
        self.plot_a = self._create_plot()
        self.plot_b = self._create_plot()
        
    def _theta_changed(self):
        x = self.plot_data.get_data('x')
        self.plot_data.set_data('y', np.sin(x + self.theta))
        
    def _create_plot(self):
        plot = Plot(self.plot_data)
        plot.index_range = DataRange1D(low = 0, high = TWO_PI)
        plot.value_range = DataRange1D(low = -1, high = 1)
        plot.plot(('x', 'y'), type = 'line', name = 'sine')
        return plot
        
PlottingProblem().configure_traits()


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev



_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev




--
Jonathan Rocher, PhD
Scientific software developer
Enthought, Inc.
[hidden email]
1-512-536-1057
http://www.enthought.com


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: plotting problem

Harold Mills
In reply to this post by Harold Mills
Thanks to all who responded to my message. I tried using QT (via PySide) on Vista and the sluggishness went away, and I also had no problem with wx on Mac OS X.

    Harold Mills


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev