Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d7b3364

Browse files
efiringtobias47n9e
authored andcommitted
errorbar: fmt kwarg default is ''; deprecate None, use 'none' instead
Closes #2366, replaces #2738.
1 parent 57f3fd9 commit d7b3364

File tree

4 files changed

+40
-13
lines changed

4 files changed

+40
-13
lines changed

CHANGELOG

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2014-06-01 Changed the fmt kwarg of errorbar to support the
2+
the mpl convention that "none" means "don't draw it",
3+
and to default to the empty string, so that plotting
4+
of data points is done with the plot() function
5+
defaults. Deprecated use of the None object in place
6+
"none".
7+
18
2014-05-22 Allow the linscale keyword parameter of symlog scale to be
29
smaller than one.
310

doc/api/api_changes.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ original location:
5454
the upper and lower limits (*lolims*, *uplims*, *xlolims*, *xuplims*) now
5555
point in the correct direction.
5656

57+
* The *fmt* kwarg for :func:`~matplotlib.pyplot.errorbar now supports
58+
the string 'none' to suppress drawing of a line and markers; use
59+
of the *None* object for this is deprecated. The default *fmt*
60+
value is changed to the empty string (''), so the line and markers
61+
are governed by the :func:`~matplotlib.pyplot.plot` defaults.
62+
5763
* A bug has been fixed in the path effects rendering of fonts, which now means
5864
that the font size is consistent with non-path effect fonts. See
5965
https://github.com/matplotlib/matplotlib/issues/2889 for more detail.

lib/matplotlib/axes/_axes.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
rcParams = matplotlib.rcParams
1616

1717
import matplotlib.cbook as cbook
18-
from matplotlib.cbook import _string_to_bool
18+
from matplotlib.cbook import _string_to_bool, mplDeprecation
1919
import matplotlib.collections as mcoll
2020
import matplotlib.colors as mcolors
2121
import matplotlib.contour as mcontour
@@ -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='', 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='', 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' | 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 '',
2559+
an empty plot format string; properties are
2560+
then identical to the defaults for :meth:`plot`.
25592561
25602562
*ecolor*: [ *None* | mpl color ]
25612563
A matplotlib color arg which gives the color the errorbar lines;
@@ -2635,6 +2637,15 @@ def errorbar(self, x, y, yerr=None, xerr=None,
26352637
holdstate = self._hold
26362638
self._hold = True
26372639

2640+
if fmt is None:
2641+
fmt = 'none'
2642+
msg = ('Use of None object as fmt keyword argument to '
2643+
+ 'suppress plotting of data values is deprecated '
2644+
+ 'since 1.4; use the string "none" instead.')
2645+
warnings.warn(msg, mplDeprecation, stacklevel=1)
2646+
2647+
plot_line = (fmt.lower() != 'none')
2648+
26382649
label = kwargs.pop("label", None)
26392650

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

26562667
l0 = None
26572668

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

26612674
barcols = []
@@ -2838,7 +2851,7 @@ def xywhere(xs, ys, mask):
28382851
xup, yup = xywhere(x, y, uplims & everymask)
28392852
caplines.extend(self.plot(xup, yup, 'k_', **plot_kw))
28402853

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

28442857
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='', 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)