|
From: Tony S Yu <ts...@gm...> - 2010-07-27 18:45:19
|
On Jul 27, 2010, at 2:14 PM, Mathew Yeates wrote: > I installed matplotlib 1.0 and now I get a different error > s=[0,0,8,8] > ys=[0,8,8,0] > verts=zip(xs,ys) > poly = PolyCollection(verts) > > fails at line 587 in collections because > xy = array([0, 0]) # xy.shape = (2,) > and line 587 says xy = np.concatenate([xy, np.zeros((1,2))]) > > What do I do? > > -Mathew > I don't really use PolyCollection, but the docstring suggests you need to put your "verts" inside of a list: > *verts* is a sequence of ( *verts0*, *verts1*, ...) where > *verts_i* is a sequence of *xy* tuples of vertices, or an > equivalent :mod:`numpy` array of shape (*nv*, 2). It's a bit confusing, but the first argument, "verts", is actually a sequence, of a sequence, of vertices (the repetition is intentional). For example: square = [(0, 0), (0, 4), (4, 4), (4, 0)] triangle = [(0, 4), (0, 7), (4, 4)] verts = [square, triangle] In other words, the "verts" you created in your description describes a single polygon, where as verts should be a list of polygons. -Tony |