Mike,When I eliminate the cuts from filled contour paths, I do find pathological cases where the filling works correctly with the cuts in place, but not without them. Attached are a data file and a script to plot it, illustrating the problem. Is this due to a known limitation of filled paths? In the example, the top two holes are connected to the lower hole, instead of being connected directly to the outer boundary of the filled region. Is this illegal? If so, I think we are stuck, because rearranging the paths that cntr makes to eliminate this type of case would likely be very difficult.
Eric
badpath.npz
Description: Binary data
import numpy as np import matplotlib.path as mpath import matplotlib.patches as mpatches import matplotlib.pyplot as plt # Badpath was generated by the contour algorithm on random data. d = np.load('badpath.npz') verts = d['verts'] codes = d['codes'] # Simplify it, while still showing the problem. mask = np.ones(codes.shape, bool) mask[45:55] = False mask[32:38] = False mask[40:42] = False verts = verts.compress(mask, axis=0) codes = codes.compress(mask) fig = plt.figure() ax1 = fig.add_subplot(1,2,1) path = mpath.Path(verts, codes) patch = mpatches.PathPatch(path, facecolor='g', edgecolor='k') ax1.add_patch(patch) ax1.axis(xmin=-1, xmax=6, ymin=-1, ymax=6) ax1.set_title('With MOVETO') ax2 = fig.add_subplot(1,2,2) codes = codes.copy() codes[1:] = 2 path = mpath.Path(verts, codes) patch = mpatches.PathPatch(path, facecolor='g', edgecolor='k', alpha=0.5) ax2.add_patch(patch) ax2.axis(xmin=-1, xmax=6, ymin=-1, ymax=6) ax2.set_title('With LINETO') npts = len(codes) mid1 = npts//3 mid2 = mid1 * 2 lslice = slice(None, mid1) mslice = slice(mid1, mid2) rslice = slice(mid2, None) c = np.arange(npts, dtype=float) imove = codes == 1 iline = codes == 2 # Mark the starting oint with a black asterisk, endpoint with red + plt.plot(verts[0,0], verts[0,1], 'k*', markersize=15, zorder=5) plt.plot(verts[-1,0], verts[-1,1], 'r+', markersize=20, zorder=6) # mark the path divided into thirds. plt.plot(verts[lslice,0], verts[lslice,1], 'k') plt.plot(verts[mslice,0], verts[mslice,1], 'c') plt.plot(verts[rslice,0], verts[rslice,1], 'r') # Use size and colors to show order of points. # This doesn't work as well as desired; in particular, the # slit downstrokes still obliterate the slit upstrokes. sz = 120*(codes-0.5) * (1 - 0.7 * c/npts) plt.scatter(verts[:,0], verts[:,1], s=sz, c=c, edgecolor='none', alpha=0.5) plt.spectral() plt.colorbar() plt.show()
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel