ScatterInspectorOverlay problem when using many renderers

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

ScatterInspectorOverlay problem when using many renderers

Jerzy Jalocha N
Hi, These are my first steps with Chaco and Traits.

I have a plot with several data series, all on the same x/y axes. Now,
I want to click and highlight individual points from any series with
the mouse. (In the future, I will have to "discard" these points, and
do calculations with the remaining ones.)

After reading many tutorials, and patching together many examples from
the Internet, I created an example with ScatterInspectorOverlay, that
reacts to user input with the mouse (source attached). Hovering with
the pointer over any point from any series correctly displays a
"halo".

The problem is, that on click, only the points from the last data
series (last renderer) are highlighted permanently. For all other
series, the mouse-click (or overlay) is just ignored.

Using OverlayPlotContainer instead of Plot gives the same result. When
I display several series side-by-side with HPlotContainer, the tool
reacts correctly to mouse clicks, but I need all data-points on the
same x/y area.

The question is, if I am doing an error in my approach, or if this is
a (known) limitation of ScatterInspectorOverlay, and I would have to
use some other approach, such as the one outlined by Robert Kern:
Creating a PlotRenderer by subclassing BaseXYPlot
(https://mail.enthought.com/pipermail/enthought-dev/2009-January/019544.html).

Regards,

Jerzy

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

InteractiveScatterPlot.py (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: ScatterInspectorOverlay problem when using many renderers

bryce hendrix-2
You're creating N inspector tools, when you click on the plot only the top most tool will get the click because the SelectTool.normal_left_down() sets the event.handled=True.

The simplest solution is to only use 1 renderer and just update its plot data. You could also subclass the ScatterInpsector and overload the normal_left_down to not set the event as handled, but you'll have to then listen for changes to each tool's selection.

There are even more options, like subclassing ScatterPlot to handle multiple data series, each with a different scatter marker, but that may a bit more, um, exotic than what need...

Bryce

On 04/23/2010 11:09 AM, Jerzy Jalocha N wrote:
Hi, These are my first steps with Chaco and Traits.

I have a plot with several data series, all on the same x/y axes. Now,
I want to click and highlight individual points from any series with
the mouse. (In the future, I will have to "discard" these points, and
do calculations with the remaining ones.)

After reading many tutorials, and patching together many examples from
the Internet, I created an example with ScatterInspectorOverlay, that
reacts to user input with the mouse (source attached). Hovering with
the pointer over any point from any series correctly displays a
"halo".

The problem is, that on click, only the points from the last data
series (last renderer) are highlighted permanently. For all other
series, the mouse-click (or overlay) is just ignored.

Using OverlayPlotContainer instead of Plot gives the same result. When
I display several series side-by-side with HPlotContainer, the tool
reacts correctly to mouse clicks, but I need all data-points on the
same x/y area.

The question is, if I am doing an error in my approach, or if this is
a (known) limitation of ScatterInspectorOverlay, and I would have to
use some other approach, such as the one outlined by Robert Kern:
Creating a PlotRenderer by subclassing BaseXYPlot
(https://mail.enthought.com/pipermail/enthought-dev/2009-January/019544.html).

Regards,

Jerzy
  
_______________________________________________ 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: ScatterInspectorOverlay problem when using many renderers

Jerzy Jalocha N
> On 04/23/2010 11:09 AM, Jerzy Jalocha N wrote:
>> I created an example with ScatterInspectorOverlay, that
>> reacts to user input with the mouse

>> The problem is, that on click, only the points from the last data
>> series (last renderer) are highlighted permanently. For all other
>> series, the mouse-click (or overlay) is just ignored.

On Fri, Apr 23, 2010 at 12:25 PM, bryce hendrix <[hidden email]> wrote:
> You're creating N inspector tools, when you click on the plot only the top
> most tool will get the click because the SelectTool.normal_left_down() sets
> the event.handled=True.

Thank you, Bryce, that explains it perfectly. You also put me back on
track with your suggestion to stick with just one renderer. Not only
was it easy to toggle/untoggle the data points on the screen using the
standard tools, but also the subsequent calculations of averages,
standard deviations and regression were easy enough to perform. The
best part, is that Chaco updates the plot automagically whenever I
change the plot data. I am really impressed about the power and how
easy these tools are to use!

For the record, I attached the code I am working on. In addition to
the original points, it plots the averages for each series, and based
on these, calculates and plots some least-squares regression model.
The user can toggle the original data-points, and everything gets
re-calculated on the fly. Maybe this is useful for someone out there.
Now, I will try to display useful information in some window.

Regards,
Jerzy

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

interactive-regression-plot.py (7K) Download Attachment