Skip to content

Commit 06d7f9c

Browse files
committed
Merge pull request #1654 from tacaswell/collection_zorder_kwarg
added explicit 'zorder' kwarg to `Colection` and `LineCollection`.
2 parents e02c375 + bd097a7 commit 06d7f9c

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lib/matplotlib/collections.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ class Collection(artist.Artist, cm.ScalarMappable):
4949
* *cmap*: None (optional for
5050
:class:`matplotlib.cm.ScalarMappable`)
5151
* *hatch*: None
52+
* *zorder*: 1
53+
5254
5355
*offsets* and *transOffset* are used to translate the patch after
5456
rendering (default no offsets). If offset_position is 'screen'
@@ -72,7 +74,7 @@ class Collection(artist.Artist, cm.ScalarMappable):
7274
_transOffset = transforms.IdentityTransform()
7375
_transforms = []
7476

75-
zorder = 1
77+
7678

7779
def __init__(self,
7880
edgecolors=None,
@@ -88,6 +90,7 @@ def __init__(self,
8890
hatch=None,
8991
urls=None,
9092
offset_position='screen',
93+
zorder=1,
9194
**kwargs
9295
):
9396
"""
@@ -107,7 +110,8 @@ def __init__(self,
107110
self.set_urls(urls)
108111
self.set_hatch(hatch)
109112
self.set_offset_position(offset_position)
110-
113+
self.set_zorder(zorder)
114+
111115
self._uniform_offsets = None
112116
self._offsets = np.array([], np.float_)
113117
# Force _offsets to be Nx2
@@ -897,7 +901,7 @@ class LineCollection(Collection):
897901
i.e., the properties cycle if the ``len`` of props is less than the
898902
number of segments.
899903
"""
900-
zorder = 2
904+
901905

902906
def __init__(self, segments, # Can be None.
903907
linewidths=None,
@@ -909,6 +913,7 @@ def __init__(self, segments, # Can be None.
909913
norm=None,
910914
cmap=None,
911915
pickradius=5,
916+
zorder=2,
912917
**kwargs
913918
):
914919
"""
@@ -959,6 +964,9 @@ def __init__(self, segments, # Can be None.
959964
*pickradius* is the tolerance for mouse clicks picking a line.
960965
The default is 5 pt.
961966
967+
*zorder*
968+
The zorder of the LineCollection. Default is 2
969+
962970
The use of :class:`~matplotlib.cm.ScalarMappable` is optional.
963971
If the :class:`~matplotlib.cm.ScalarMappable` array
964972
:attr:`~matplotlib.cm.ScalarMappable._A` is not None (ie a call to
@@ -987,6 +995,7 @@ def __init__(self, segments, # Can be None.
987995
norm=norm,
988996
cmap=cmap,
989997
pickradius=pickradius,
998+
zorder=zorder,
990999
**kwargs)
9911000

9921001
self.set_segments(segments)

0 commit comments

Comments
 (0)