In a message of Fri, 13 Nov 2015 14:04:01 +0000, Oscar Benjamin writes:
>On 13 November 2015 at 08:34, Laura Creighton <l...@openend.se> wrote:
>> 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.
>
>Actually the plot command is perfectly happy converting lists or lists
>of lists etc. to arrays (by calling np.array internally) so you don't
>need to convert any of your inputs. By the way: np.arange(1, N/2+2)
>would be the usual way to create a numpy array that is a range.
>
>The error here comes because (after both arguments are converted to
>arrays) they have incompatible sizes. In other words:
>
>    len(range(1,N/2+2)) != len(Splot[alpha][iii,val]/utot[iii,val])
>
>I'm not sure what the solution is as the code is too complex for me to
>spend time trying to guess what it's trying to do.
>
>--
>Oscar

I am sorry for the bad information.  Thank you Oscar.

Laura
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to