TypeError: Dimensions of C (645, 536) are incompatible with X (538) and/or Y (646); see help(pcolormesh)

Hello,

I am getting this error when I try calling pcolormesh this way:

pcolormesh(x, y, data.T,
cmap=cmap,
vmin=0,
vmax=100)

I am doing the transpose of data so I don’t know what could be causing this. By the way, it does work with some images. Any suggestions?

Thanks in advance

It looks like your X data is one element larger than it needs to be. I know pcolor() accepts grids that are (N+1,M+1), and I think pcolormesh does the same. It will also accept grids that are (N,M) as well, but will drop the last row and collumn.

Given your statement that it sometimes works, I suspect you have a bug in your code somewhere that is causing your Xs and Ys to not always be exactly the length you’d expect them to be.

I hope that helps!

Ben Root

···

On Mon, Jun 29, 2015 at 2:06 PM, Ronquillo, Edgar Nahum <eronquillo@…652…> wrote:

Hello,

I am getting this error when I try calling pcolormesh this way:

pcolormesh(x, y, data.T,
cmap=cmap,
vmin=0,
vmax=100)

I am doing the transpose of data so I don’t know what could be causing this. By the way, it does work with some images. Any suggestions?

Thanks in advance


Don’t Limit Your Business. Reach for the Cloud.

GigeNET’s Cloud Solutions provide you with the tools and support that

you need to offload your IT needs and focus on growing your business.

Configured For All Businesses. Start Your Cloud Today.

https://www.gigenetcloud.com/


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Yes, pcolormesh and pcolor use the same argument parsing and checking. They actually *want* N+1, M+1; the *acceptance* of N, M is a matlab-ism that is convenient for quick looks, but is also a potential source of error.

The OP has an X dimension of M+2, which indicates an error earlier in the OP's code.

Eric

···

On 2015/06/30 6:41 AM, Benjamin Root wrote:

It looks like your X data is one element larger than it needs to be. I
know pcolor() accepts grids that are (N+1,M+1), and I *think* pcolormesh
does the same. It will also accept grids that are (N,M) as well, but
will drop the last row and collumn.

Yeah it makes sense. I still can't find the bug, which it most likely is. I will keep looking and see what i find.

Thanks for the help

···

-----Original Message-----
From: Eric Firing [mailto:efiring@…202…]
Sent: Tuesday, June 30, 2015 1:11 PM
To: matplotlib-users@lists.sourceforge.net
Subject: Re: [Matplotlib-users] TypeError: Dimensions of C (645, 536) are incompatible with X (538) and/or Y (646); see help(pcolormesh)

On 2015/06/30 6:41 AM, Benjamin Root wrote:

It looks like your X data is one element larger than it needs to be. I
know pcolor() accepts grids that are (N+1,M+1), and I *think*
pcolormesh does the same. It will also accept grids that are (N,M) as
well, but will drop the last row and collumn.

Yes, pcolormesh and pcolor use the same argument parsing and checking.
They actually *want* N+1, M+1; the *acceptance* of N, M is a matlab-ism that is convenient for quick looks, but is also a potential source of error.

The OP has an X dimension of M+2, which indicates an error earlier in the OP's code.

Eric

------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users