diff --git a/doc/users/whats_new/streamplot_zorder.rst b/doc/users/whats_new/streamplot_zorder.rst new file mode 100644 index 000000000000..ac8e15f3aee8 --- /dev/null +++ b/doc/users/whats_new/streamplot_zorder.rst @@ -0,0 +1,7 @@ +Streamplot Zorder Keyword Argument Changes +------------------------------------------ + +The ``zorder`` parameter for :func:`streamplot` now has default +value of ``None`` instead of ``2``. If ``None`` is given as ``zorder``, +:func:`streamplot` has a default ``zorder`` of +``matplotlib.lines.Line2D.zorder``. diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 0d87c5566829..74d90a21f709 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -4613,7 +4613,8 @@ def stackplot(self, x, *args, **kwargs): label_namer=None) def streamplot(self, x, y, u, v, density=1, linewidth=None, color=None, cmap=None, norm=None, arrowsize=1, arrowstyle='-|>', - minlength=0.1, transform=None, zorder=2, start_points=None): + minlength=0.1, transform=None, zorder=None, + start_points=None): if not self._hold: self.cla() stream_container = mstream.streamplot(self, x, y, u, v, diff --git a/lib/matplotlib/streamplot.py b/lib/matplotlib/streamplot.py index f46e3d66ed58..cbc413b2312e 100644 --- a/lib/matplotlib/streamplot.py +++ b/lib/matplotlib/streamplot.py @@ -13,6 +13,7 @@ import matplotlib.cm as cm import matplotlib.colors as mcolors import matplotlib.collections as mcollections +import matplotlib.lines as mlines import matplotlib.patches as patches @@ -21,7 +22,7 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None, cmap=None, norm=None, arrowsize=1, arrowstyle='-|>', - minlength=0.1, transform=None, zorder=2, start_points=None): + minlength=0.1, transform=None, zorder=None, start_points=None): """Draws streamlines of a vector flow. *x*, *y* : 1d arrays @@ -78,6 +79,9 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None, mask = StreamMask(density) dmap = DomainMap(grid, mask) + if zorder is None: + zorder = mlines.Line2D.zorder + # default to data coordinates if transform is None: transform = axes.transData