Matplotlib error: Value Error: x and y must have same first dimension

Laura Creighton lac at openend.se
Fri Nov 13 03:34:23 EST 2015


In a message of Thu, 12 Nov 2015 17:54:28 -0800, Abhishek writes:
>I am trying to run some Python code for the last few hours. How can I achieve the effect of "dot divide" from Matlab, in the following code? I am having trouble working with list comprehension and numpy arrays and getting the following error:
>
>    Traceback (most recent call last):
>      File "Thurs.py", line 128, in <module>
>        plt.plot(np.array(range(1,N/2+2)), Splot[alpha][iii,val]/utot[iii,val],color=cmap(iii/50))
>
>    ValueError: x and y must have same first dimension

Splot is a list.  matplotlib wants 2 numpy arrays.  You have to cast
it with np.array() too.

no guarantees that the rest of the code works -- it is not plotting for
me -- but that gets rid of that error at any rate.

Laura



More information about the Python-list mailing list