简体   繁体   中英

Matplotlib Error Bars

If I run this code:

plt.scatter(n, y, marker ='^', s = 30, color = 'k')
plt.errorbar(n, y, yerr=yerror)
plt.ylim(ymin = 5, ymax = 20)

The resulting graph has a red line between the scatterplot. How do I prevent this line from appearing? Additionally, how might I add caps to the error bars?

I have tried

(_, caps, _) = plt.errorbar(n,y, yerr=yerror, capsize=5, elinewidth=3)

for cap in caps:
    cap.set_color('k')
    cap.set_markeredgewidth(3) 

and

plt.errorbar(n, y, yerr = yerror, ecolor = 'k', capsize = 5)

But neither has worked. There is clearly something fundamental I am missing about errorbars.

在此处输入图片说明

After further searching (almost immediately after I posted the question) I have found that adding

ls = 'none' 

within

plt.errorbar(n, y, yerr=yerror, ls = 'none')

will solve the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM