From f08355c93f3e262fdec808a88279c91a60aa2c1b Mon Sep 17 00:00:00 2001 From: Benjamin Congdon Date: Tue, 27 Sep 2016 06:32:26 -0500 Subject: [PATCH 1/2] Remove hard-coded streamplot zorder and let `mlinesLine2D.zorder` to be the default --- lib/matplotlib/axes/_axes.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 0d87c5566829..af090281f602 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -4613,9 +4613,12 @@ 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() + if zorder is None: + zorder = mlines.Line2D.zorder stream_container = mstream.streamplot(self, x, y, u, v, density=density, linewidth=linewidth, From 55ce3802325ec6f5da36daf23316669dbee18871 Mon Sep 17 00:00:00 2001 From: Benjamin Congdon Date: Wed, 28 Sep 2016 09:28:04 -0500 Subject: [PATCH 2/2] Moved streamplot zorder changes to stream plot module; added whats new entry --- doc/users/whats_new/streamplot_zorder.rst | 7 +++++++ lib/matplotlib/axes/_axes.py | 2 -- lib/matplotlib/streamplot.py | 6 +++++- 3 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 doc/users/whats_new/streamplot_zorder.rst 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 af090281f602..74d90a21f709 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -4617,8 +4617,6 @@ def streamplot(self, x, y, u, v, density=1, linewidth=None, color=None, start_points=None): if not self._hold: self.cla() - if zorder is None: - zorder = mlines.Line2D.zorder stream_container = mstream.streamplot(self, x, y, u, v, density=density, linewidth=linewidth, 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