Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: Laura Creighton Newsgroups: comp.lang.python Subject: Re: Matplotlib error: Value Error: x and y must have same first dimension Date: Fri, 13 Nov 2015 09:34:23 +0100 Lines: 20 Message-ID: References: <40964e99-cd31-4daa-8f5f-069b09816b3d@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de BtF3cRpNgGZe4NUZDZMVQwKJ8LUnuFVufV5aiE4lRTLw== Return-Path: 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; 'subject:Error': 0.07; 'valueerror:': 0.07; 'cc:addr:python-list': 0.09; 'received:openend.se': 0.09; 'received:theraft.openend.se': 0.09; 'subject:same': 0.09; 'python': 0.10; 'subject:error': 0.11; 'thu,': 0.15; 'abhishek': 0.16; 'arrays.': 0.16; 'cc:addr:lac': 0.16; 'cc:addr:openend.se': 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; 'laura': 0.18; '2015': 0.20; 'cc:addr:python.org': 0.20; 'cc:2**1': 0.22; 'arrays': 0.22; 'rid': 0.22; 'trying': 0.22; '(most': 0.24; 'rest': 0.26; 'error': 0.27; 'guarantees': 0.29; 'matplotlib': 0.29; 'received:se': 0.29; 'cc:no real name:2**1': 0.29; 'too.': 0.30; 'code': 0.30; 'getting': 0.33; 'run': 0.33; 'rate.': 0.33; 'traceback': 0.33; 'file': 0.34; 'list': 0.34; 'gets': 0.35; 'trouble': 0.35; 'nov': 0.35; 'skip:p 30': 0.35; 'but': 0.36; 'subject:: ': 0.37; 'skip:s 50': 0.37; 'charset:us-ascii': 0.37; 'list.': 0.37; 'some': 0.40; 'header:Message-Id:1': 0.61; 'cast': 0.66; 'subject:have': 0.80; '128,': 0.84; 'header:In-reply-to:1': 0.84; 'subject:Value': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openend.se; s=default; t=1447403666; bh=2NjdpSJ0GF68MtwMJ6IUhvDnaNzo+wFy84nuT1peFEc=; h=To:cc:From:Subject:In-reply-to:References:Date:From; b=Gh7g+dPIxbTIuyCuNqSQyudoIliCsYjmTBu4qk80WZohrSi42/5DsAzY/U+VHN9sk 3EQWj3xrk2fLjcPrVbsIOhGzQthi4oU5R5jYoqgDfuWf2YhqrCm/nyYz1SXUWw7s0m HRjdozP6MpulIiYFeRSrIqknOmo+c68d+QClht0w= In-reply-to: <40964e99-cd31-4daa-8f5f-069b09816b3d@googlegroups.com> Comments: In-reply-to Abhishek message dated "Thu, 12 Nov 2015 17:54:28 -0800." Content-ID: <5831.1447403663.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 09:34:26 +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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:98731 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 ach= ieve the effect of "dot divide" from Matlab, in the following code? I am h= aving trouble working with list comprehension and numpy arrays and getting= the following error: > > Traceback (most recent call last): > File "Thurs.py", line 128, in > plt.plot(np.array(range(1,N/2+2)), Splot[alpha][iii,val]/utot[iii= ,val],color=3Dcmap(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