Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9208489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:37:44+00:00 2026-06-18T00:37:44+00:00

Given these numpy arrays x = [0 1 2 3 4 5 6 7

  • 0

Given these numpy arrays

x = [0 1 2 3 4 5 6 7 8 9]
y = [[ 0.        ]
     [-0.02083473]
     [ 0.08819923]
     [ 0.9454764 ]
     [ 0.80604627]
     [ 0.82189822]
     [ 0.73613942]
     [ 0.64519742]
     [ 0.56973868]
     [ 0.612912  ]]
c = [[ 0.          0.        ]
     [-0.09127286  0.04960341]
     [-0.00300709  0.17940555]
     [ 0.82319693  1.06775586]
     [ 0.74512774  0.8669648 ]
     [ 0.75177669  0.89201975]
     [ 0.63606087  0.83621797]
     [ 0.57786173  0.7125331 ]
     [ 0.46722312  0.67225423]
     [ 0.54951714  0.67630685]]

I want to plot the graph of x,y , with error bars using the values in c. I tried

plt.errorbar(x, y, yerr=c)

But the interpreter is giving me this error:

File "C:\Python\32\lib\site-packages\matplotlib\axes.py", line 3846, in vlines
  for thisx, (thisymin, thisymax) in zip(x,Y)]
File "C:\Python\32\lib\site-packages\matplotlib\axes.py", line 3846, in <listcomp>
  for thisx, (thisymin, thisymax) in zip(x,Y)]
ValueError: too many values to unpack (expected 2)

The value of x in zip is

[0 1 2 3 4 5 6 7 8 9]

and the value of Y in zip is

[[[ 0.          0.        ]
  [ 0.07043814 -0.11210759]
  [ 0.09120632  0.08519214]
  [ 0.12227947  1.76867333]
  [ 0.06091853  1.55117401]
  [ 0.07012153  1.57367491]
  [ 0.10007855  1.3722003 ]
  [ 0.06733568  1.22305915]
  [ 0.10251555  1.0369618 ]
  [ 0.06339486  1.16242914]]

 [[ 0.          0.        ]
  [-0.07043814  0.02876869]
  [-0.09120632  0.26760478]
  [-0.12227947  2.01323226]
  [-0.06091853  1.67301107]
  [-0.07012153  1.71391797]
  [-0.10007855  1.57235739]
  [-0.06733568  1.35773052]
  [-0.10251555  1.2419929 ]
  [-0.06339486  1.28921885]]]

I’ve read around and it looks like my code should be correct (a stupid assumption, but I can’t find evidence to the contrary… yet), but it looks like errorbar doesn’t like the 2d array. The documentation says that yerr can be a 2d array, with the first column being the min error and the second being the max.

What is it that I’m doing wrong here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T00:37:45+00:00Added an answer on June 18, 2026 at 12:37 am

    There were some problems with the code which I corrected below and so it works with no problem.

    import numpy
    import pylab
    
    arr = numpy.asarray
    
    x = arr([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])   # put comma between numbers
    y = arr([[ 0.        ],                   # make it vector
         [-0.02083473],
         [ 0.08819923],
         [ 0.9454764 ],
         [ 0.80604627],
         [ 0.82189822],
         [ 0.73613942],
         [ 0.64519742],
         [ 0.56973868],
         [ 0.612912  ]]).flatten()
    c = arr([[ 0.        ,  0.        ],
         [-0.09127286,  0.04960341],
         [-0.00300709,  0.17940555],
         [ 0.82319693,  1.06775586],
         [ 0.74512774,  0.8669648 ],
         [ 0.75177669,  0.89201975],
         [ 0.63606087,  0.83621797],
         [ 0.57786173,  0.7125331 ],
         [ 0.46722312,  0.67225423],
         [ 0.54951714,  0.67630685]]).T      # transpose
    pylab.errorbar(x, y, yerr=c)
    pylab.show()
    

    and the result:

    enter image description here

    Good luck.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given 2 2x2 Numpy arrays, each element having a value between 0 and 1,
Given these two queries: Select t1.id, t2.companyName from table1 t1 INNER JOIN table2 t2
Given these tables: create table Orders ( Id INT IDENTITY NOT NULL, primary key
I am learning Java and have been given these options: How can you implement
This is easier to explain with an example. Given these two classes: public class
i am using asynctask to fetch images from given url.these images are displaying in
can any one explain inter relation between these below given directives ; Do not
Given file names like these: /the/path/foo.txt bar.txt I hope to get: foo bar Why
Given a BehaviorSubject, what is the practical difference between calling all of these different
Given the Java code below, what's the closest you could represent these two static

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.