Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added explicit 'zorder' kwarg to Colection and LineCollection. #1654

Merged
merged 2 commits into from Jan 14, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 12 additions & 3 deletions lib/matplotlib/collections.py
Expand Up @@ -49,6 +49,8 @@ class Collection(artist.Artist, cm.ScalarMappable):
* *cmap*: None (optional for * *cmap*: None (optional for
:class:`matplotlib.cm.ScalarMappable`) :class:`matplotlib.cm.ScalarMappable`)
* *hatch*: None * *hatch*: None
* *zorder*: 1



*offsets* and *transOffset* are used to translate the patch after *offsets* and *transOffset* are used to translate the patch after
rendering (default no offsets). If offset_position is 'screen' rendering (default no offsets). If offset_position is 'screen'
Expand All @@ -72,7 +74,7 @@ class Collection(artist.Artist, cm.ScalarMappable):
_transOffset = transforms.IdentityTransform() _transOffset = transforms.IdentityTransform()
_transforms = [] _transforms = []


zorder = 1


def __init__(self, def __init__(self,
edgecolors=None, edgecolors=None,
Expand All @@ -88,6 +90,7 @@ def __init__(self,
hatch=None, hatch=None,
urls=None, urls=None,
offset_position='screen', offset_position='screen',
zorder=1,
**kwargs **kwargs
): ):
""" """
Expand All @@ -107,7 +110,8 @@ def __init__(self,
self.set_urls(urls) self.set_urls(urls)
self.set_hatch(hatch) self.set_hatch(hatch)
self.set_offset_position(offset_position) self.set_offset_position(offset_position)

self.set_zorder(zorder)

self._uniform_offsets = None self._uniform_offsets = None
self._offsets = np.array([], np.float_) self._offsets = np.array([], np.float_)
# Force _offsets to be Nx2 # Force _offsets to be Nx2
Expand Down Expand Up @@ -897,7 +901,7 @@ class LineCollection(Collection):
i.e., the properties cycle if the ``len`` of props is less than the i.e., the properties cycle if the ``len`` of props is less than the
number of segments. number of segments.
""" """
zorder = 2


def __init__(self, segments, # Can be None. def __init__(self, segments, # Can be None.
linewidths=None, linewidths=None,
Expand All @@ -909,6 +913,7 @@ def __init__(self, segments, # Can be None.
norm=None, norm=None,
cmap=None, cmap=None,
pickradius=5, pickradius=5,
zorder=2,
**kwargs **kwargs
): ):
""" """
Expand Down Expand Up @@ -959,6 +964,9 @@ def __init__(self, segments, # Can be None.
*pickradius* is the tolerance for mouse clicks picking a line. *pickradius* is the tolerance for mouse clicks picking a line.
The default is 5 pt. The default is 5 pt.


*zorder*
The zorder of the LineCollection. Default is 2

The use of :class:`~matplotlib.cm.ScalarMappable` is optional. The use of :class:`~matplotlib.cm.ScalarMappable` is optional.
If the :class:`~matplotlib.cm.ScalarMappable` array If the :class:`~matplotlib.cm.ScalarMappable` array
:attr:`~matplotlib.cm.ScalarMappable._A` is not None (ie a call to :attr:`~matplotlib.cm.ScalarMappable._A` is not None (ie a call to
Expand Down Expand Up @@ -987,6 +995,7 @@ def __init__(self, segments, # Can be None.
norm=norm, norm=norm,
cmap=cmap, cmap=cmap,
pickradius=pickradius, pickradius=pickradius,
zorder=zorder,
**kwargs) **kwargs)


self.set_segments(segments) self.set_segments(segments)
Expand Down