How to show errorbars behind symbols

Question:

I plot my error bars and data separately. How do I make the scatter plot data symbols overlay the error bars?

here is a simple working version of my problem

import numpy as np
import matplotlib.pyplot as plt
    
fig = plt.figure()
x = np.arange(10)
y = 2.5 * np.sin(x / 20 * np.pi)
yerr = np.linspace(0.05, 0.2, 10)

plt.errorbar(x, y , yerr=yerr,linestyle="None",c='black',elinewidth=0.1,capthick=0.3)
plt.scatter(x,y,marker='*')

Here is the output… I want the error bar lines to be behind the symbols.

enter image description here

ANSWER: Thanks to a comment by Paul H. the answer is use zorder to rank each overlay.

Asked By: Charlie Crown

||

Answers:

ANSWER: Thanks to a comment by Paul H. the answer is use zorder to rank each overlay.

Answered By: Charlie Crown
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.