8000 errorbar: handle fmt kwarg in a manner consistent with usual mpl prac… · efiring/matplotlib@b540b88 · GitHub
[go: up one dir, main page]

Skip to content

Commit b540b88

Browse files
committed
errorbar: handle fmt kwarg in a manner consistent with usual mpl practice
Closes matplotlib#2366, as an alternative to matplotlib#2738.
1 parent e2c5918 commit b540b88

File tree

4 files changed

+33
-13
lines changed

4 files changed

+33
-13
lines changed

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2014-06-01 Changed the fmt kwarg of errorbar to be consistent
2+
with the mpl convention that None is the default,
3+
governed by rcParams settings, and "none" means "don't draw it".
4+
15
2014-05-22 Allow the linscale keyword parameter of symlog scale to be
26
smaller than one.
37

doc/api/api_changes.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@ original location:
5252

5353
* The :func:`~matplotlib.pyplot.errorbar` method has been changed such that
5454
the upper and lower limits (*lolims*, *uplims*, *xlolims*, *xuplims*) now
55-
point in the correct direction.
55+
point in the correct direction. The *fmt* kwarg is now handled
56+
consistently with mpl conventions: *None* is the default, and
57+
causes the line and markers to be governed by the
58+
:func:`~matplotlib.pyplot.plot` defaults; the string 'none'
59+
suppresses drawing of a line and markers; and anything else
60+
is passed as a third positional argument to :meth:`~matplotlib.axes.Axes.plot`.
5661

5762
* A bug has been fixed in the path effects rendering of fonts, which now means
5863
that the font size is consistent with non-path effect fonts. See

lib/matplotlib/axes/_axes.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2062,7 +2062,7 @@ def make_iterable(x):
20622062

20632063
errorbar = self.errorbar(x, y,
20642064
yerr=yerr, xerr=xerr,
2065-
fmt=None, **error_kw)
2065+
fmt='none', **error_kw)
20662066
else:
20672067
errorbar = None
20682068

@@ -2520,7 +2520,7 @@ def pie(self, x, explode=None, labels=None, colors=None,
25202520

25212521
@docstring.dedent_interpd
25222522
def errorbar(self, x, y, yerr=None, xerr=None,
2523-
fmt='-', ecolor=None, elinewidth=None, capsize=3,
2523+
fmt=None, ecolor=None, elinewidth=None, capsize=3,
25242524
barsabove=False, lolims=False, uplims=False,
25252525
xlolims=False, xuplims=False, errorevery=1, capthick=None,
25262526
**kwargs):
@@ -2530,7 +2530,7 @@ def errorbar(self, x, y, yerr=None, xerr=None,
25302530
Call signature::
25312531
25322532
errorbar(x, y, yerr=None, xerr=None,
2533-
fmt='-', ecolor=None, elinewidth=None, capsize=3,
2533+
fmt=None, ecolor=None, elinewidth=None, capsize=3,
25342534
barsabove=False, lolims=False, uplims=False,
25352535
xlolims=False, xuplims=False, errorevery=1,
25362536
capthick=None)
@@ -2552,10 +2552,12 @@ def errorbar(self, x, y, yerr=None, xerr=None,
25522552
If a sequence of shape 2xN, errorbars are drawn at -row1
25532553
and +row2 relative to the data.
25542554
2555-
*fmt*: '-'
2556-
The plot format symbol. If *fmt* is *None*, only the
2557-
errorbars are plotted. This is used for adding
2558-
errorbars to a bar plot, for example.
2555+
*fmt*: [ *None* | 'none' | plot format string ]
2556+
The plot format symbol. If *fmt* is 'none' (case-insensitive),
2557+
only the errorbars are plotted. This is used for adding
2558+
errorbars to a bar plot, for example. Default is *None*,
2559+
equivalent to an empty plot format string; properties are
2560+
then identical to the defaults for :meth:`plot`.
25592561
25602562
*ecolor*: [ *None* | mpl color ]
2561< 8000 code>2563
A matplotlib color arg which gives the color the errorbar lines;
@@ -2635,6 +2637,12 @@ def errorbar(self, x, y, yerr=None, xerr=None,
26352637
holdstate = self._hold
26362638
self._hold = True
26372639

2640+
plot_line = True
2641+
if fmt is None:
2642+
fmt = "" # Plot points using plot method with rcParams defaults.
2643+
elif fmt.lower() == 'none':
2644+
plot_line = False # Don't plot the points at all.
2645+
26382646
label = kwargs.pop("label", None)
26392647

26402648
# make sure all the args are iterable; use lists not arrays to
@@ -2655,7 +2663,9 @@ def errorbar(self, x, y, yerr=None, xerr=None,
26552663

26562664
l0 = None
26572665

2658-
if barsabove and fmt is not None:
2666+
# Instead of using zorder, the line plot is being added
2667+
# either here, or after all the errorbar plot elements.
2668+
if barsabove and plot_line:
26592669
l0, = self.plot(x, y, fmt, label="_nolegend_", **kwargs)
26602670

26612671
barcols = []
@@ -2838,7 +2848,7 @@ def xywhere(xs, ys, mask):
28382848
xup, yup = xywhere(x, y, uplims & everymask)
28392849
caplines.extend(self.plot(xup, yup, 'k_', **plot_kw))
28402850

2841-
if not barsabove and fmt is not None:
2851+
if not barsabove and plot_line:
28422852
l0, = self.plot(x, y, fmt, **kwargs)
28432853

28442854
if ecolor is None:

lib/matplotlib/pyplot.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2603,7 +2603,8 @@ def boxplot(x, notch=False, sym='b+', vert=True, whis=1.5, positions=None,
26032603
widths=None, patch_artist=False, bootstrap=None, usermedians=None,
26042604
conf_intervals=None, meanline=False, showmeans=False, showcaps=True,
26052605
showbox=True, showfliers=True, boxprops=None, labels=None,
2606-
flierprops=None, medianprops=None, meanprops=None, hold=None):
2606+
flierprops=None, medianprops=None, meanprops=None,
2607+
manage_xticks=True, hold=None):
26072608
ax = gca()
26082609
# allow callers to override the hold state by passing hold=True|False
26092610
washold = ax.ishold()
@@ -2620,7 +2621,7 @@ def boxplot(x, notch=False, sym='b+', vert=True, whis=1.5, positions=None,
26202621
showbox=showbox, showfliers=showfliers,
26212622
boxprops=boxprops, labels=labels,
26222623
flierprops=flierprops, medianprops=medianprops,
2623-
meanprops=meanprops)
2624+
meanprops=meanprops, manage_xticks=manage_xticks)
26242625
draw_if_interactive()
26252626
finally:
26262627
ax.hold(washold)
@@ -2729,7 +2730,7 @@ def csd(x, y, NFFT=None, Fs=None, Fc=None, detrend=None, window=None,
27292730
# This function was autogenerated by boilerplate.py. Do not edit as
27302731
# changes will be lost
27312732
@_autogen_docstring(Axes.errorbar)
2732-
def errorbar(x, y, yerr=None, xerr=None, fmt='-', ecolor=None, elinewidth=None,
2733+
def errorbar(x, y, yerr=None, xerr=None, fmt=None, ecolor=None, elinewidth=None,
27332734
capsize=3, barsabove=False, lolims=False, uplims=False,
27342735
xlolims=False, xuplims=False, errorevery=1, capthick=None,
27352736
hold=None, **kwargs):

0 commit comments

Comments
 (0)
0