Inconsistent marker/line zorder in errorbar legend

Hello,

I have run across an inconsistency in the zorder of markers and lines
in the legend for an errorbar as opposed to a plot in matplotlib
v1.1.0. After some considerable amount of time reading
legend_handler.py and the information at
http://matplotlib.sourceforge.net/users/legend_guide.html I was unable
to figure out how to make the errorbar markers sit 'on top' of the
lines in a legend.

For example the following code:

import pylab as pl
import numpy as np

x = pl.arange(-2,2,0.1)
y = x**2
dy = np.random.random(len(x))

pl.figure(1)
pl.plot(x,y, color='k', linewidth=0.5, linestyle='-', marker='o',
        markerfacecolor='lime', markeredgecolor='k', markeredgewidth=0.5,
label='line1', markersize=10)
pl.legend(loc='best', frameon=False)

pl.figure(2)
pl.errorbar(x,y,yerr=dy, color='k', linewidth=0.5, linestyle='-', marker='o',
        markerfacecolor='lime', markeredgecolor='k', markeredgewidth=0.5,
        label='line1', markersize=10, ecolor='lime', capsize=10)
pl.legend(loc='best', frameon=False)

pl.show()

produces a legend for the plot (figure(1)) with the markers on top of
the lines, but the legend for the errorbar (figure(2)) has this
reversed.

Any ideas/suggestions would be greatly appreciated.

Best,
  Adrian.

I just pushed a change that I believe fixes this problem

Required change is very minor, so you may apply the patch by yourself.
If you need a workaround, let me know.
Regards,

-JJ

···

On Tue, Dec 6, 2011 at 11:46 AM, Adrian Del Maestro <agdelma@...287...> wrote:

Hello,

I have run across an inconsistency in the zorder of markers and lines
in the legend for an errorbar as opposed to a plot in matplotlib
v1.1.0. After some considerable amount of time reading
legend_handler.py and the information at
http://matplotlib.sourceforge.net/users/legend_guide.html I was unable
to figure out how to make the errorbar markers sit 'on top' of the
lines in a legend.

For example the following code:

import pylab as pl
import numpy as np

x = pl.arange(-2,2,0.1)
y = x**2
dy = np.random.random(len(x))

pl.figure(1)
pl.plot(x,y, color='k', linewidth=0.5, linestyle='-', marker='o',
markerfacecolor='lime', markeredgecolor='k', markeredgewidth=0.5,
label='line1', markersize=10)
pl.legend(loc='best', frameon=False)

pl.figure(2)
pl.errorbar(x,y,yerr=dy, color='k', linewidth=0.5, linestyle='-', marker='o',
markerfacecolor='lime', markeredgecolor='k', markeredgewidth=0.5,
label='line1', markersize=10, ecolor='lime', capsize=10)
pl.legend(loc='best', frameon=False)

pl.show()

produces a legend for the plot (figure(1)) with the markers on top of
the lines, but the legend for the errorbar (figure(2)) has this
reversed.

Any ideas/suggestions would be greatly appreciated.

Best,
Adrian.

------------------------------------------------------------------------------
Cloud Services Checklist: Pricing and Packaging Optimization
This white paper is intended to serve as a reference, checklist and point of
discussion for anyone considering optimizing the pricing and packaging model
of a cloud services business. Read Now!
http://www.accelacomm.com/jaw/sfnl/114/51491232/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Thank you very much! I was trying to do something like this in
legend_handler.py but this is such a simple fix!

Best,
  Adrian.

···

On Wed, Dec 7, 2011 at 9:11 AM, Jae-Joon Lee <lee.j.joon@...287...> wrote:

I just pushed a change that I believe fixes this problem

fix the drawing order of lines and markers of the Errorbar legend_han… · matplotlib/matplotlib@96caca8 · GitHub

Required change is very minor, so you may apply the patch by yourself.
If you need a workaround, let me know.
Regards,

-JJ

On Tue, Dec 6, 2011 at 11:46 AM, Adrian Del Maestro <agdelma@...287...> wrote:

Hello,

I have run across an inconsistency in the zorder of markers and lines
in the legend for an errorbar as opposed to a plot in matplotlib
v1.1.0. After some considerable amount of time reading
legend_handler.py and the information at
http://matplotlib.sourceforge.net/users/legend_guide.html I was unable
to figure out how to make the errorbar markers sit 'on top' of the
lines in a legend.

For example the following code:

import pylab as pl
import numpy as np

x = pl.arange(-2,2,0.1)
y = x**2
dy = np.random.random(len(x))

pl.figure(1)
pl.plot(x,y, color='k', linewidth=0.5, linestyle='-', marker='o',
markerfacecolor='lime', markeredgecolor='k', markeredgewidth=0.5,
label='line1', markersize=10)
pl.legend(loc='best', frameon=False)

pl.figure(2)
pl.errorbar(x,y,yerr=dy, color='k', linewidth=0.5, linestyle='-', marker='o',
markerfacecolor='lime', markeredgecolor='k', markeredgewidth=0.5,
label='line1', markersize=10, ecolor='lime', capsize=10)
pl.legend(loc='best', frameon=False)

pl.show()

produces a legend for the plot (figure(1)) with the markers on top of
the lines, but the legend for the errorbar (figure(2)) has this
reversed.

Any ideas/suggestions would be greatly appreciated.

Best,
Adrian.

------------------------------------------------------------------------------
Cloud Services Checklist: Pricing and Packaging Optimization
This white paper is intended to serve as a reference, checklist and point of
discussion for anyone considering optimizing the pricing and packaging model
of a cloud services business. Read Now!
http://www.accelacomm.com/jaw/sfnl/114/51491232/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options