On Tuesday 12 February 2008 12:07:21 Michael Frauens wrote:
> I am using span selector to identify an area and then highlight in in
> green. I want the user to be able to validate this (or not) and then
> select another area (or not). However, when the user selects the alternate
> area I want the previous instance of axvspan to be deleted/removed. How do
> I remove this instance? of do I have to delete the whole plot and replot?
>
> Removing the instance is strongly preferred becauase the user may of
> altered the display using the canvas widgets.
Michael,
I have more or less the same issue: I need to be able to highlight one
particular curve among many. I have implemented a special subclass of Axes
for my particular problem. This subclass has a method "highlight"
Here's a rough draft of what I do:
def __init__(self,*args,**kwargs)
Subplot.__init__(self,*args,**kwargs)
sefl.highlightedfreq = None
def highlight(bandwidth, **options):
if (self.highlightedfreq is not None) and \
(self.highlightedfreq != bandwidth):
del self.lines[self.highlightedline]
self.highlightedfreq = bandwidth
self.plot(current._dates-shift, current._series, lw=lw, ls=ls, c=c,
scalex=False, scaley=False)
self.highlightedline = len(self.lines)-1 #
return self.highlightedline
As you see, I have an extra attribute (highlightedfreq) that stores the index
of the highlighted line: when I need to deselect the highlighted curve, I
just delete the corresponding element of the lines list.
HIH
P.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users