Plot highlighting using alpha values

Oct 02 2008 Published by Bryce Hendrix under Chaco, Enthought Tool Suite

I recently added support for changing the alpha of a plot after it has been constructed. Combined with a selection tool you get a really nice highlight feature. In this example, when a plot is selected I double its width and set the alpha of the other plots to 1/3 of their normal value.

plot with alpha

    def _select(self, selected):
        """ Decorates a plot to indicate it is selected """
        for plot in reduce(operator.add, selected.container.plots.values()):
            if plot != selected:
                plot.alpha /= 3
            else:
                plot.line_width *= 2

        plot.request_redraw()

    def _deselect(self, selected):
        for plot in reduce(operator.add, selected.container.plots.values()):
            if plot != selected:
                plot.alpha *= 3
            else:
                plot.line_width /= 2

        plot.request_redraw()

One response so far

  • chris chris says:

    It looks great. I’m just getting started with the tool suite. Can you show a complete example using the _select code?

Leave a Reply

Featuring Advanced Search Functions plugin by YD