From b3dafb9abca9d5d589930802cdf9e582970cf2d1 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell <“tcaswell@gmail.com”> Date: Mon, 31 Dec 2012 00:34:45 -0600 Subject: [PATCH 1/2] added explicit 'zorder' kwarg to `Colection` and `LineCollection`. removed class level zorder assignment. It is not strictly necessary for LineCollection to take zorder as a kwarg, but added to keep the default zorder the same --- lib/matplotlib/collections.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/collections.py b/lib/matplotlib/collections.py index 1a0410be7ebb..5487bab8b5b4 100644 --- a/lib/matplotlib/collections.py +++ b/lib/matplotlib/collections.py @@ -49,6 +49,8 @@ class Collection(artist.Artist, cm.ScalarMappable): * *cmap*: None (optional for :class:`matplotlib.cm.ScalarMappable`) * *hatch*: None + * *zorder*: 1 + *offsets* and *transOffset* are used to translate the patch after rendering (default no offsets). If offset_position is 'screen' @@ -72,7 +74,7 @@ class Collection(artist.Artist, cm.ScalarMappable): _transOffset = transforms.IdentityTransform() _transforms = [] - zorder = 1 + def __init__(self, edgecolors=None, @@ -88,6 +90,7 @@ def __init__(self, hatch=None, urls=None, offset_position='screen', + zorder=1, **kwargs ): """ @@ -107,7 +110,8 @@ def __init__(self, self.set_urls(urls) self.set_hatch(hatch) self.set_offset_position(offset_position) - + self.set_zorder(zorder) + self._uniform_offsets = None self._offsets = np.array([], np.float_) # Force _offsets to be Nx2 @@ -897,7 +901,7 @@ class LineCollection(Collection): i.e., the properties cycle if the ``len`` of props is less than the number of segments. """ - zorder = 2 + def __init__(self, segments, # Can be None. linewidths=None, @@ -909,6 +913,7 @@ def __init__(self, segments, # Can be None. norm=None, cmap=None, pickradius=5, + zorder=2, **kwargs ): """ @@ -959,6 +964,9 @@ def __init__(self, segments, # Can be None. *pickradius* is the tolerance for mouse clicks picking a line. The default is 5 pt. + *zorder* + 2 the zorder of the LineCollection + The use of :class:`~matplotlib.cm.ScalarMappable` is optional. If the :class:`~matplotlib.cm.ScalarMappable` array :attr:`~matplotlib.cm.ScalarMappable._A` is not None (ie a call to @@ -987,6 +995,7 @@ def __init__(self, segments, # Can be None. norm=norm, cmap=cmap, pickradius=pickradius, + zorder=zorder, **kwargs) self.set_segments(segments) From bd097a7c08da7dc88d3aa51c5a2a54bb303b260c Mon Sep 17 00:00:00 2001 From: Thomas A Caswell <“tcaswell@gmail.com”> Date: Mon, 14 Jan 2013 09:07:27 -0600 Subject: [PATCH 2/2] documentation tweak --- lib/matplotlib/collections.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/collections.py b/lib/matplotlib/collections.py index 5487bab8b5b4..bbea0a2eaf0e 100644 --- a/lib/matplotlib/collections.py +++ b/lib/matplotlib/collections.py @@ -965,7 +965,7 @@ def __init__(self, segments, # Can be None. The default is 5 pt. *zorder* - 2 the zorder of the LineCollection + The zorder of the LineCollection. Default is 2 The use of :class:`~matplotlib.cm.ScalarMappable` is optional. If the :class:`~matplotlib.cm.ScalarMappable` array