0

I want to plot 2D data points with errors on each axis in python. I have used errorbar from matplotlib:

x=[393.995,394.87,422.965,423.84,437.49,438.360,466.965,467.84]
y=[1.2625,0.7575,1.2625,0.7575,1.2625,1.7675,2.2725,2.7775]
errors=[0.486731,0.00955756,0.111786,0.412761,0.240057,0.228817,0.222496  ,0.24288]
errorbar(x, y, xerr=errors, yerr=errors, ecolor='k', fmt='o', capthick=2)

But it shows only errors on y-axis. I have no idea why.

The plot:

The plot

1
  • Please add sample data. The values for x, y and errors. Post only a small sample of a few points. Commented May 13, 2019 at 9:30

1 Answer 1

1

There is nothing wrong with your code. The problem is the relative value of the errors and the x data. You are simply not able to see the bars. To understand the issue look at the following two examples:

Invert the x and y coordinates:

x=[393.995,394.87,422.965,423.84,437.49,438.360,466.965,467.84]
y=[1.2625,0.7575,1.2625,0.7575,1.2625,1.7675,2.2725,2.7775]
errors=[0.486731,0.00955756,0.111786,0.412761,0.240057,0.228817,0.222496  ,0.24288]
errorbar(y, x, xerr=errors, yerr=errors, ecolor='k', fmt='o', capthick=2) #invert x and y

enter image description here

Reduce the value of your x.

x=[3.93995,3.9487,4.22965,4.2384,4.3749,4.38360,4.66965,4.6784] #x=x/100
y=[1.2625,0.7575,1.2625,0.7575,1.2625,1.7675,2.2725,2.7775]
errors=[0.486731,0.00955756,0.111786,0.412761,0.240057,0.228817,0.222496  ,0.24288]
plt.errorbar(x,y, xerr=errors, yerr=errors, ecolor='k', fmt='o', capthick=2)

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very, that explains why

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.