On Tue, Jun 1, 2010 at 6:17 PM, Fernando Perez <[email protected]> wrote:
> Hi all,
>
> I just spent some time digging through the matplotlib code, and I see
> that the errorbar line width argument isn't passed through to the
> underlying call. In axis.bar, we have this code:
>
> if xerr is not None or yerr is not None:
> if orientation == 'vertical':
> # using list comps rather than arrays to preserve unit info
> x = [l+0.5*w for l, w in zip(left, width)]
> y = [b+h for b,h in zip(bottom, height)]
>
> elif orientation == 'horizontal':
> # using list comps rather than arrays to preserve unit info
> x = [l+w for l,w in zip(left, width)]
> y = [b+0.5*h for b,h in zip(bottom, height)]
>
> self.errorbar(
> x, y,
> yerr=yerr, xerr=xerr,
> fmt=None, ecolor=ecolor, capsize=capsize)
>
> while errorbar has this signature:
>
> def errorbar(self, x, y, yerr=None, xerr=None,
> fmt='-', ecolor=None, elinewidth=None, capsize=3,
> barsabove=False, lolims=False, uplims=False,
> xlolims=False, xuplims=False, **kwargs):
>
> For a poster, we wanted thicker errorbars drawn and had to resort to:
>
> plt.rcParams['lines.markeredgewidth'] = 2
> plt.rcParams['lines.linewidth'] = 2
>
> and reverting back to normal width after making the errorbar calls.
> Should I file a ticket about this, or are such fine-tuning tasks
> considered as fair game for rcParams manipulations?
>
> I'm happy to file the ticket, I just don't want to create unnecessary
> noise if the rcparams is meant to be 'the way' to do it.
While this is certainly a bug that needs to be fixed (and Eric is
right that these functions are heavily overworked and hairy), there is
a better workaround than the one you tried. From the errorbar
docstring:
Return value is a length 3 tuple. The first element is the
:class:`~matplotlib.lines.Line2D` instance for the *y* symbol
lines. The second element is a list of error bar cap lines,
the third element is a list of
:class:`~matplotlib.collections.LineCollection` instances for
the horizontal and vertical error ranges.
So you can call the appropriate methods on the return objects. Eg
ylines, caplines, vlines = ax.errorbar(...)
if you want to set the vertical line thickness, it is a LineCollection
instance so you can call
vlines.set_linewidth(2.0)
Since it is a Collection instance, you can also vary the vertical
linewidths by passing in a sequuence of linewidths.
Hope this helps,
JDH
------------------------------------------------------------------------------
_______________________________________________
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel