I need to plot the following error bars for my project. And I control the size of the marker using matplotlib.scatter as follows:
import matplotlib.pyplot as plt
import numpy as np
x=[1,2,3]
y=[1,2,3]
yerr=[2,3,1]
fig,(ax1)=plt.subplots(1,1)
ax1.errorbar(x,y,yerr=yerr, linestyle='-', capsize=3, ecolor='lightblue', elinewidth=2)
ax1.scatter(x, y, s=[20]*len(x), marker='o', color='#1f77b4')
plt.show()
The results are like the following:
The markers are plotted under the error bar, which is not nice. Any solutions?
CodePudding user response:
Try using zorder:
ax1.scatter(x, y, s=[20]*len(x), marker='o', color='#1f77b4', zorder=10)