@@ -2793,6 +2793,7 @@ def errorbar(self, x, y, yerr=None, xerr=None,
2793
2793
.. plot:: mpl_examples/statistics/errorbar_demo.py
2794
2794
2795
2795
"""
2796
+ kwargs .setdefault ('zorder' , 2 )
2796
2797
2797
2798
if errorevery < 1 :
2798
2799
raise ValueError (
@@ -2850,17 +2851,13 @@ def errorbar(self, x, y, yerr=None, xerr=None,
2850
2851
2851
2852
l0 = None
2852
2853
2853
- # Instead of using zorder, the line plot is being added
2854
- # either here, or after all the errorbar plot elements.
2855
- if barsabove and plot_line :
2856
- # in python3.5+ this can be simplified
2857
- eb_style = dict (base_style )
2858
- eb_style .update (** kwargs )
2859
- l0 = mlines .Line2D (x , y , ** eb_style )
2860
- self .add_line (l0 )
2861
2854
# make the style dict for the 'normal' plot line
2862
2855
plot_line_style = dict (base_style )
2863
2856
plot_line_style .update (** kwargs )
2857
+ if barsabove :
2858
+ plot_line_style ['zorder' ] = kwargs ['zorder' ] - .1
2859
+ else :
2860
+ plot_line_style ['zorder' ] = kwargs ['zorder' ] + .1
2864
2861
2865
2862
# make the style dict for the line collections (the bars)
2866
2863
eb_lines_style = dict (base_style )
@@ -2903,6 +2900,10 @@ def errorbar(self, x, y, yerr=None, xerr=None,
2903
2900
eb_cap_style [key ] = kwargs [key ]
2904
2901
eb_cap_style ['color' ] = ecolor
2905
2902
2903
+ if plot_line :
2904
+ l0 = mlines .Line2D (x , y , ** plot_line_style )
2905
+ self .add_line (l0 )
2906
+
2906
2907
barcols = []
2907
2908
caplines = []
2908
2909
@@ -3067,12 +3068,6 @@ def extract_err(err, data):
3067
3068
for l in caplines :
3068
3069
self .add_line (l )
3069
3070
3070
- if not barsabove and plot_line :
3071
- # in python3.5+ this can be simplified
3072
- eb_style = dict (base_style )
3073
- eb_style .update (** kwargs )
3074
- l0 = mlines .Line2D (x , y , ** eb_style )
3075
- self .add_line (l0 )
3076
3071
3077
3072
self .autoscale_view ()
3078
3073
self ._hold = holdstate
0 commit comments