Hi, I have found minor graphical issues while using the spanselector, cursor and fill_between widgets, which I would like to share with you.
All of them, can be experienced in this code (which I took from the matplolib example) """ The SpanSelector is a mouse widget to select a xmin/xmax range and plot the detail view of the selected region in the lower axes """ import numpy as np import matplotlib.pyplot as plt from matplotlib.widgets import SpanSelector import matplotlib.widgets as widgets Fig = plt.figure(figsize=(8,6)) Fig.set_facecolor('w') Fig.set Ax = Fig.add_subplot(211) x = np.arange(0.0, 5.0, 0.01) y = np.sin(2*np.pi*x) + 0.5*np.random.randn(len(x)) Ax.plot(x, y, '-') Ax.set_ylim(-2,2) Ax.set_title('Press left mouse button and drag to test') RegionIndices = [] ax2 = Fig.add_subplot(212) line2, = ax2.plot(x, y, '-') def onselect(xmin, xmax): if len(RegionIndices) == 2: Ax.fill_between(x[:], 0.0, y[:],facecolor='White',alpha=1) del RegionIndices[:] indmin, indmax = np.searchsorted(x, (xmin, xmax)) indmax = min(len(x)-1, indmax) Ax.fill_between(x[indmin:indmax], 0.0, y[indmin:indmax],facecolor='Blue',alpha=0.30) thisx = x[indmin:indmax] thisy = y[indmin:indmax] line2.set_data(thisx, thisy) ax2.set_xlim(thisx[0], thisx[-1]) ax2.set_ylim(thisy.min(), thisy.max()) Fig.canvas.draw() RegionIndices.append(xmin) RegionIndices.append(xmax) # set useblit True on gtkagg for enhanced performance span = SpanSelector(Ax, onselect, 'horizontal', useblit = True,rectprops=dict(alpha=0.5, facecolor='purple') ) cursor = widgets.Cursor(Ax, color="red", linewidth = 1, useblit = True) plt.show() I wonder if there is some way to avoid these two small issues: 1) You can see that when you select a region the spanselector box (purple) glitches. In this code the effect is barely noticeable but on plots with many lines is quite annoying (I have tried all the trueblit combinations to not effect) 2) In this code when you select a region, the area in the upper plot between the line and the horizontal axis is filled in blue. When you select a new region the old area is filled in white (to clear it) and the new one is filled with blue again. However, when I do that the line plotted, as well as, the horizontal axis, become thicker... Is there a way to clear such a region (generated with fill_between) without this happening... Or is it necessary to replot the graph? Initially, I am against doing this since I have a well structured code and importing all the data again into the spanselector method seems a bit messy... Which is the right way in python to delete selected regions of a plot? Any advice would be most welcome -- View this message in context: http://matplotlib.1069221.n5.nabble.com/Graphics-issues-when-combining-matplotlib-widgets-Spanselector-cursor-fill-between-tp41212.html Sent from the matplotlib - users mailing list archive at Nabble.com. ------------------------------------------------------------------------------ How ServiceNow helps IT people transform IT departments: 1. A cloud service to automate IT design, transition and operations 2. Dashboards that offer high-level views of enterprise services 3. A single system of record for all IT processes http://p.sf.net/sfu/servicenow-d2d-j _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users