Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #98747

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

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Laura Creighton <lac@openend.se>
Newsgroups comp.lang.python
Subject Re: Matplotlib error: Value Error: x and y must have same first dimension
Date Fri, 13 Nov 2015 16:43:54 +0100
Lines 37
Message-ID <mailman.292.1447429441.16136.python-list@python.org> (permalink)
References <40964e99-cd31-4daa-8f5f-069b09816b3d@googlegroups.com> <201511130834.tAD8YNra005833@fido.openend.se> <CAHVvXxQVs7O8K7cCiya7=yovwxHAdPoPZh6CQV4hsMEFroBYLA@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset="us-ascii"
Content-Transfer-Encoding quoted-printable
X-Trace news.uni-berlin.de vHc8ys21p85rhWQwkoWnBQhCsadAREZpUVbtdrYCwjnQ==
Return-Path <lac@openend.se>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'error:': 0.05; 'incompatible': 0.07; 'subject:Error': 0.07; 'valueerror:': 0.07; 'cc:addr:python-list': 0.09; 'benjamin': 0.09; 'creighton': 0.09; 'received:openend.se': 0.09; 'received:theraft.openend.se': 0.09; 'subject:same': 0.09; 'way:': 0.09; 'python': 0.10; 'subject:error': 0.11; 'thu,': 0.15; '>>>i': 0.16; '>on': 0.16; 'abhishek': 0.16; 'arrays.': 0.16; 'cc:addr:lac': 0.16; 'cc:addr:openend.se': 0.16; 'cc:name:laura creighton': 0.16; 'cc:name:python list': 0.16; 'code?': 0.16; 'dimension': 0.16; 'from:addr:lac': 0.16; 'from:addr:openend.se': 0.16; 'from:name:laura creighton': 0.16; 'message-id:@fido.openend.se': 0.16; 'numpy': 0.16; 'received:fido': 0.16; 'received:fido.openend.se': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'laura': 0.18; '>>>': 0.20; '2015': 0.20; 'cc:addr:python.org': 0.20; 'cc:2**2': 0.20; 'do.': 0.22; '(by': 0.22; 'arguments': 0.22; 'arrays': 0.22; 'converted': 0.22; 'trying': 0.22; 'cc:no real name:2**0': 0.22; 'skip:l 40': 0.23; '(most': 0.24; 'cc:addr:gmail.com': 0.24; 'command': 0.26; 'error': 0.27; 'fri,': 0.27; 'converting': 0.27; 'matplotlib': 0.29; 'received:se': 0.29; 'array': 0.29; 'convert': 0.29; 'too.': 0.30; 'code': 0.30; 'guess': 0.31; 'getting': 0.33; 'run': 0.33; 'traceback': 0.33; 'file': 0.34; 'lists': 0.34; 'list': 0.34; 'trouble': 0.35; 'nov': 0.35; 'skip:p 30': 0.35; 'too': 0.36; 'subject:: ': 0.37; 'skip:s 50': 0.37; 'charset:us- ascii': 0.37; 'list.': 0.37; 'thank': 0.38; 'sure': 0.39; 'some': 0.40; 'your': 0.60; 'header:Message-Id:1': 0.61; 'cast': 0.66; 'here': 0.66; 'subject:have': 0.80; '128,': 0.84; '>of': 0.84; 'header:In-reply-to:1': 0.84; 'oscar': 0.84; 'subject:Value': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=openend.se; s=default; t=1447429436; bh=bStqFmcI22oj0pq7zacp8AYHXtFA9l87UcRNx4MhUas=; h=To:cc:From:Subject:In-reply-to:References:Date:From; b=w+gdhqCPgbw1MkVeeY7rqqVOVS6YKvnpOKllm7OLYHx0ggODd/K00WhUpHqydH7rq Yhqr8oy/Cw6U2aD42JuCYcawN4BXYGqPdtQ0EPah4mZ4RW4ouqTtZ++zop88P202Ng PZYg+T61hEGql2adynR6+P5MTzkyCsZqeFjBm4g0=
In-reply-to <CAHVvXxQVs7O8K7cCiya7=yovwxHAdPoPZh6CQV4hsMEFroBYLA@mail.gmail.com>
Comments In-reply-to Oscar Benjamin <oscar.j.benjamin@gmail.com> message dated "Fri, 13 Nov 2015 14:04:01 +0000."
Content-ID <6537.1447429434.1@fido>
X-Greylist Sender IP whitelisted, not delayed by milter-greylist-4.3.9 (theraft.openend.se [82.96.5.2]); Fri, 13 Nov 2015 16:43:56 +0100 (CET)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:98747

Show key headers only | View raw


In a message of Fri, 13 Nov 2015 14:04:01 +0000, Oscar Benjamin writes:
>On 13 November 2015 at 08:34, Laura Creighton <lac@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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Matplotlib error: Value Error: x and y must have same first dimension Abhishek <abhishek.mallela@gmail.com> - 2015-11-12 17:54 -0800
  Re: Matplotlib error: Value Error: x and y must have same first dimension Laura Creighton <lac@openend.se> - 2015-11-13 09:34 +0100
  Re: Matplotlib error: Value Error: x and y must have same first dimension Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2015-11-13 14:04 +0000
  Re: Matplotlib error: Value Error: x and y must have same first dimension Laura Creighton <lac@openend.se> - 2015-11-13 16:43 +0100
  Re: Matplotlib error: Value Error: x and y must have same first dimension Abhishek Mallela <abhishek.mallela@gmail.com> - 2015-11-13 11:44 -0600

csiph-web