PolyCollection API

why doesn't this work?
xs=[0,0,8,8]
ys=[0,8,8,0]
verts=zip(xs,ys)
poly = PolyCollection(verts)

I tried
poly = PolyCollection([verts]) but that doesn't work either

-Mathew

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

···

On Tue, Jul 27, 2010 at 9:51 AM, Mathew Yeates <mat.yeates@...287...> wrote:

why doesn't this work?
xs=[0,0,8,8]
ys=[0,8,8,0]
verts=zip(xs,ys)
poly = PolyCollection(verts)

I tried
poly = PolyCollection([verts]) but that doesn't work either

-Mathew

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?

With 1.0:

In [8]: verts
Out[8]: [(0, 0), (0, 8), (8, 8), (8, 0)]

In [9]: p = PolyCollection([verts])

Eric

···

On 07/27/2010 08:14 AM, Mathew Yeates wrote:

-Mathew

On Tue, Jul 27, 2010 at 9:51 AM, Mathew Yeates<mat.yeates@...287...> wrote:

why doesn't this work?
xs=[0,0,8,8]
ys=[0,8,8,0]
verts=zip(xs,ys)
poly = PolyCollection(verts)

I tried
poly = PolyCollection([verts]) but that doesn't work either

-Mathew

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

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

···

On Jul 27, 2010, at 2:14 PM, Mathew Yeates wrote:

I still get the error
ValueError: arrays must have same number of dimensions
at line 587 in collections.py

This is on Windows.

···

On Tue, Jul 27, 2010 at 11:42 AM, Eric Firing <efiring@...202...> wrote:

On 07/27/2010 08:14 AM, 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?

With 1.0:

In [8]: verts
Out[8]: [(0, 0), (0, 8), (8, 8), (8, 0)]

In [9]: p = PolyCollection([verts])

Eric

-Mathew

On Tue, Jul 27, 2010 at 9:51 AM, Mathew Yeates<mat.yeates@...287...> wrote:

why doesn't this work?
xs=[0,0,8,8]
ys=[0,8,8,0]
verts=zip(xs,ys)
poly = PolyCollection(verts)

I tried
poly = PolyCollection([verts]) but that doesn't work either

-Mathew

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

I still get the error
ValueError: arrays must have same number of dimensions
at line 587 in collections.py

I think you are not actually doing what you think you are doing, and what was explained by Tony.

Try the attached script.

Eric

pctest.py (191 Bytes)

···

On 07/27/2010 08:55 AM, Mathew Yeates wrote:

This is on Windows.

On Tue, Jul 27, 2010 at 11:42 AM, Eric Firing<efiring@...202...> wrote:

On 07/27/2010 08:14 AM, 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?

With 1.0:

In [8]: verts
Out[8]: [(0, 0), (0, 8), (8, 8), (8, 0)]

In [9]: p = PolyCollection([verts])

Eric

-Mathew

On Tue, Jul 27, 2010 at 9:51 AM, Mathew Yeates<mat.yeates@...287...> wrote:

why doesn't this work?
xs=[0,0,8,8]
ys=[0,8,8,0]
verts=zip(xs,ys)
poly = PolyCollection(verts)

I tried
poly = PolyCollection([verts]) but that doesn't work either

-Mathew

I tried
xs=[0,0,8,8]
ys=[0,8,8,0]
verts=zip(xs,ys)
poly = PolyCollection([verts])

already but it doesn't work

on line 581 of collections.py

there is
for xy in verts:

but
verts=[[(0, 0), (0, 8), (8, 8), (8, 0)]] i.e. a list with a single element.
so the loop happens only once

-Mathew

···

On Tue, Jul 27, 2010 at 12:29 PM, Eric Firing <efiring@...202...> wrote:

On 07/27/2010 08:55 AM, Mathew Yeates wrote:

I still get the error
ValueError: arrays must have same number of dimensions
at line 587 in collections.py

I think you are not actually doing what you think you are doing, and what
was explained by Tony.

Try the attached script.

Eric

This is on Windows.

On Tue, Jul 27, 2010 at 11:42 AM, Eric Firing<efiring@...202...> wrote:

On 07/27/2010 08:14 AM, 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?

With 1.0:

In [8]: verts
Out[8]: [(0, 0), (0, 8), (8, 8), (8, 0)]

In [9]: p = PolyCollection([verts])

Eric

-Mathew

On Tue, Jul 27, 2010 at 9:51 AM, Mathew Yeates<mat.yeates@...287...> >>>> wrote:

why doesn't this work?
xs=[0,0,8,8]
ys=[0,8,8,0]
verts=zip(xs,ys)
poly = PolyCollection(verts)

I tried
poly = PolyCollection([verts]) but that doesn't work either

-Mathew

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

I tried
xs=[0,0,8,8]
ys=[0,8,8,0]
verts=zip(xs,ys)
poly = PolyCollection([verts])

already but it doesn't work

Yes, I saw you say that, but---did you actually try running the script I attached?

Please run it from the command line ("python pctest.py"), and if it fails, send the traceback.

Eric

···

On 07/27/2010 09:43 AM, Mathew Yeates wrote:

on line 581 of collections.py

there is
for xy in verts:

but
verts=[[(0, 0), (0, 8), (8, 8), (8, 0)]] i.e. a list with a single element.
so the loop happens only once

-Mathew

On Tue, Jul 27, 2010 at 12:29 PM, Eric Firing<efiring@...202...> wrote:

On 07/27/2010 08:55 AM, Mathew Yeates wrote:

I still get the error
ValueError: arrays must have same number of dimensions
at line 587 in collections.py

I think you are not actually doing what you think you are doing, and what
was explained by Tony.

Try the attached script.

Eric

This is on Windows.

On Tue, Jul 27, 2010 at 11:42 AM, Eric Firing<efiring@...202...> wrote:

On 07/27/2010 08:14 AM, 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?

With 1.0:

In [8]: verts
Out[8]: [(0, 0), (0, 8), (8, 8), (8, 0)]

In [9]: p = PolyCollection([verts])

Eric

-Mathew

On Tue, Jul 27, 2010 at 9:51 AM, Mathew Yeates<mat.yeates@...287...> >>>>> wrote:

why doesn't this work?
xs=[0,0,8,8]
ys=[0,8,8,0]
verts=zip(xs,ys)
poly = PolyCollection(verts)

I tried
poly = PolyCollection([verts]) but that doesn't work either

-Mathew

The reason Eric suggests running it from the command line is because
if you are running a persistent python session with a current
figure/axes, the old, bad collection may still be residing in your
axes. Running from the command line will insure a clean environment.
To test whether this explanation is correct, run plt.close('all')
before rerunning your code. But do take Eric's suggestion to run from
the shell and post output.

···

On Tue, Jul 27, 2010 at 2:50 PM, Eric Firing <efiring@...202...> wrote:

On 07/27/2010 09:43 AM, Mathew Yeates wrote:

I tried
xs=[0,0,8,8]
ys=[0,8,8,0]
verts=zip(xs,ys)
poly = PolyCollection([verts])

already but it doesn't work

Yes, I saw you say that, but---did you actually try running the script I
attached?

Please run it from the command line ("python pctest.py"), and if it
fails, send the traceback.

your code works fine. But I thought it wasnt working because when I do
zs=[0,0.1,0.2,0.3]
#pdb.set_trace()
poly = PolyCollection([verts])
ax.add_collection3d(poly,zs=zs)

I just get a flat plane.

···

On Tue, Jul 27, 2010 at 12:50 PM, Eric Firing <efiring@...202...> wrote:

On 07/27/2010 09:43 AM, Mathew Yeates wrote:

I tried
xs=[0,0,8,8]
ys=[0,8,8,0]
verts=zip(xs,ys)
poly = PolyCollection([verts])

already but it doesn't work

Yes, I saw you say that, but---did you actually try running the script I
attached?

Please run it from the command line ("python pctest.py"), and if it
fails, send the traceback.

Eric

on line 581 of collections.py

there is
for xy in verts:

but
verts=[[(0, 0), (0, 8), (8, 8), (8, 0)]] i.e. a list with a single element.
so the loop happens only once

-Mathew

On Tue, Jul 27, 2010 at 12:29 PM, Eric Firing<efiring@...202...> wrote:

On 07/27/2010 08:55 AM, Mathew Yeates wrote:

I still get the error
ValueError: arrays must have same number of dimensions
at line 587 in collections.py

I think you are not actually doing what you think you are doing, and what
was explained by Tony.

Try the attached script.

Eric

This is on Windows.

On Tue, Jul 27, 2010 at 11:42 AM, Eric Firing<efiring@...202...> wrote:

On 07/27/2010 08:14 AM, 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?

With 1.0:

In [8]: verts
Out[8]: [(0, 0), (0, 8), (8, 8), (8, 0)]

In [9]: p = PolyCollection([verts])

Eric

-Mathew

On Tue, Jul 27, 2010 at 9:51 AM, Mathew Yeates<mat.yeates@...287...> >>>>>> wrote:

why doesn't this work?
xs=[0,0,8,8]
ys=[0,8,8,0]
verts=zip(xs,ys)
poly = PolyCollection(verts)

I tried
poly = PolyCollection([verts]) but that doesn't work either

-Mathew

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

My bad. Since I wanted to draw a plane, I thought I wanted to use a
polygon. Instead, using plot_surface I get what I want.

-Mathew

···

On Tue, Jul 27, 2010 at 1:40 PM, Mathew Yeates <mat.yeates@...287...> wrote:

your code works fine. But I thought it wasnt working because when I do
zs=[0,0.1,0.2,0.3]
#pdb.set_trace()
poly = PolyCollection([verts])
ax.add_collection3d(poly,zs=zs)

I just get a flat plane.

On Tue, Jul 27, 2010 at 12:50 PM, Eric Firing <efiring@...202...> wrote:

On 07/27/2010 09:43 AM, Mathew Yeates wrote:

I tried
xs=[0,0,8,8]
ys=[0,8,8,0]
verts=zip(xs,ys)
poly = PolyCollection([verts])

already but it doesn't work

Yes, I saw you say that, but---did you actually try running the script I
attached?

Please run it from the command line ("python pctest.py"), and if it
fails, send the traceback.

Eric

on line 581 of collections.py

there is
for xy in verts:

but
verts=[[(0, 0), (0, 8), (8, 8), (8, 0)]] i.e. a list with a single element.
so the loop happens only once

-Mathew

On Tue, Jul 27, 2010 at 12:29 PM, Eric Firing<efiring@...202...> wrote:

On 07/27/2010 08:55 AM, Mathew Yeates wrote:

I still get the error
ValueError: arrays must have same number of dimensions
at line 587 in collections.py

I think you are not actually doing what you think you are doing, and what
was explained by Tony.

Try the attached script.

Eric

This is on Windows.

On Tue, Jul 27, 2010 at 11:42 AM, Eric Firing<efiring@...202...> wrote:

On 07/27/2010 08:14 AM, 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?

With 1.0:

In [8]: verts
Out[8]: [(0, 0), (0, 8), (8, 8), (8, 0)]

In [9]: p = PolyCollection([verts])

Eric

-Mathew

On Tue, Jul 27, 2010 at 9:51 AM, Mathew Yeates<mat.yeates@...287...> >>>>>>> wrote:

why doesn't this work?
xs=[0,0,8,8]
ys=[0,8,8,0]
verts=zip(xs,ys)
poly = PolyCollection(verts)

I tried
poly = PolyCollection([verts]) but that doesn't work either

-Mathew

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options