>>>>> "Stephen" == Stephen George <[EMAIL PROTECTED]> writes:
Stephen> Have a lot of data, and when looking at full view I'd Stephen> like no markers, but when zoom in to see individual Stephen> points I'd like to place markers on the graph. Planing Stephen> on attaching some code to events to toggle markers on my Stephen> line. Is there a way to change the markers a line uses Stephen> after it has been plotted, or do I have to clear the plot Stephen> and replot? Here is some example code that changes the marker style based on zoom level. I wrote the example initially to show how to clip data from a line based on zoom, but it also changes the marker style based on number of points in the view window """ Clip a line according to the current xlimits, and change the marker style when zoomed in """ from matplotlib.lines import Line2D import matplotlib.numerix as nx from pylab import figure, show class ClippedLine(Line2D): """ Clip the xlimits to the axes view limits -- this example assumes x is sorted """ def __init__(self, ax, *args, **kwargs): Line2D.__init__(self, *args, **kwargs) self.ax = ax def set_data(self, *args, **kwargs): Line2D.set_data(self, *args, **kwargs) self.xorig = nx.array(self._x) self.yorig = nx.array(self._y) def draw(self, renderer): xlim = self.ax.get_xlim() ind0, ind1 = nx.searchsorted(self.xorig, xlim) self._x = self.xorig[ind0:ind1] self._y = self.yorig[ind0:ind1] N = len(self._x) if N<1000: self._marker = 's' self._linestyle = '-' else: self._marker = None self._linestyle = '-' Line2D.draw(self, renderer) fig = figure() ax = fig.add_subplot(111, autoscale_on=False) t = nx.arange(0.0, 100.0, 0.01) s = nx.sin(2*nx.pi*t) line = ClippedLine(ax, t, s, color='g', ls='-', lw=2) ax.add_line(line) ax.set_xlim(10,30) ax.set_ylim(-1.1,1.1) show() ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users