Plot highlighting using alpha values

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

[sourcecode language=”python”]
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()
[/sourcecode]

One thought on “Plot highlighting using alpha values

  1. avatarchris

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

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Please leave these two fields as-is:

Protected by Invisible Defender. Showed 403 to 102,396 bad guys.