[SciPy-User] conotur plot

Aronne Merrelli aronne.merrelli@gmail....
Wed Mar 28 22:20:58 CDT 2012


On Wed, Mar 28, 2012 at 3:22 PM, Sebastian <sebas0@gmail.com> wrote:
> TypeError: Length of x must be number of columns in z,
> and length of y must be number of rows."
> and I think this occurs because:
>
> In [788]: shape(x1),shape(y1),shape(z1)
> Out[788]: ((20,), (60,), (20, 60))
>


The shape of a 2-D array is (number_of_rows, number_of_columns).
For that z1 array, the x-array should be 60, and the y should be 20.
So you need to transpose z, or swap the x/y arrays to get the correct
dimensions. For example:

In [15]: x1.shape, y1.shape, z.shape
Out[15]: ((20,), (60,), (20, 60))

In [16]: contour(x1,y1,z.T)
Out[16]: <matplotlib.contour.QuadContourSet instance at 0x6242a80>

In [17]: contour(y1,x1,z)
Out[17]: <matplotlib.contour.QuadContourSet instance at 0x624ba30>

In [18]: contour(x1,y1,z)
TypeError: Length of x must be number of columns in z,
and length of y must be number of rows.


More information about the SciPy-User mailing list