Thanks for that, the canvas.draw() function redraws the graph. I had to add
the "autoscale_on=False" to the add_subplot() to stop the graph from
autoscaling. 
 
One issue that I find now is that the removed marker is not redrawn as
removed, in other words, all the original markers remain drawn whether or
not the datapoints exist in the array. How can I remove the marker I don't
want anymore withought doing a clf() call because I can have over 300,000
datapoints and the redraw will take ages
 
Thanks for the link to the clipping code, that will come in handy. Much
appreciated


John Hunter-4 wrote:
> 
> On Mon, May 26, 2008 at 10:08 AM, John Hunter <[EMAIL PROTECTED]> wrote:
>> On Mon, May 26, 2008 at 7:01 AM, New2Python <[EMAIL PROTECTED]>
>> wrote:
>>
>>> I hope someone can give me a simple solution to my problem. I have a
>>> line
>>> plotted and I need to be able to mark selected data points on the line.
>>> I am
>>
>> If you are frequently changing the zoom level, as it looks like you
>> are, the copy background/restore region/blit idiom is probably not the
>> right one for you, since the background is assumed fixed.  You can
>> simply force a draw at any time by doing fig.canvas.draw() w/o having
>> to zoom out or resize to trigger a draw.  So after doing the
>> self.marker.set_data call, I would do fig.canvas.draw
> 
> I thought this would be a generally useful thing to do (maintain a
> list of toggleable selected vertices) so I added some support. Here is
> some example code to highlight the selected markers:
> 
> """
> The matplotlib.lines.VertexSelector maintains a list of selected line
> vertices using the line picker property. If an unselected vertex is
> clicked, it is selected, and if a selected vertex is clicked, it is
> unselectedit.
> 
> Classes which inherit from the VertexSelector should override the
> process_selected method to do something with the selected vertex. This
> example just highlights them with red markers.  If you don't have
> access to svn, I can send you a free-standing example.
> 
> 
> """
> The matplotlib.lines.VertexSelector maintains a list of selected line
> vertices using the line picker property. If an unselected vertex is
> clicked, it is selected, and if a selected vertex is clicked, it is
> unselectedit.
> 
> Classes which inherit from the VertexSelector should override the
> process_selected method to do something with the selected vertex. This
> example just highlights them with red markers.
> 
> """
> 
> import numpy as np
> import matplotlib.pyplot as plt
> import matplotlib.lines as lines
> 
> class HighlightSelected(lines.VertexSelector):
>     """
>     Highlight the selected vertices with a marker plot
>     """
>     def __init__(self, line, fmt='ro', **kwargs):
>         """
>         highlight the selected vertices of line with a marker plot.
>         The plot format string are given by fmt and the kwargs are
> additional
>         line properties
>         """
>         lines.VertexSelector.__init__(self, line)
>         self.markers, = self.axes.plot([], [], fmt, **kwargs)
> 
>     def process_selected(self, ind, xs, ys):
>         """
>         ind are the indices of the selected vertices.  xs and ys are
>         the coordinates of the selected vertices.
>         """
>         self.markers.set_data(xs, ys)
>         self.canvas.draw()
> 
> fig = plt.figure()
> ax = fig.add_subplot(111)
> x, y = np.random.rand(2, 30)
> line, = ax.plot(x, y, 'bs-', picker=5)
> 
> selector = HighlightSelected(line)
> plt.show()
> 
> -------------------------------------------------------------------------
> 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
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Plotting-single-marker-point-at-zoomed-level-tp17470649p17511209.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


-------------------------------------------------------------------------
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
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to