Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Merged
merged 2 commits into from

3 participants

@tacaswell
Owner

Vaguely related to issue #1622. Changed the location of the default zorder of Collection and LineCollection from a class level-member, to explicitly being a keyword argument.

I think this makes it clearer, but isn't strictly necessary, because if zorder is included as a kwarg, it will get set by the self.update anyway.

Thomas A Caswell 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
b3dafb9
lib/matplotlib/collections.py
@@ -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
@pelson Collaborator
pelson added a note

This line should probably be more along the lines of:

```The zorder of the LineCollection. Default is 2."""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@pelson
Collaborator

Good stuff @tacaswell - I'm amazed we have come so far without zorder for Collections!

Thomas A Caswell documentation tweak bd097a7
@dmcdougall
Collaborator

Thanks @tacaswell, merging.

@dmcdougall
Collaborator

(The Travis failures are duds)

@dmcdougall dmcdougall merged commit 06d7f9c into from
@tacaswell tacaswell deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 12, 2013
  1. added explicit 'zorder' kwarg to `Colection` and `LineCollection`.

    Thomas A Caswell authored
    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
Commits on Jan 14, 2013
  1. documentation tweak

    Thomas A Caswell authored
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 3 deletions.
  1. +12 −3 lib/matplotlib/collections.py
View
15 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*
+ The zorder of the LineCollection. Default is 2
+
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)
Something went wrong with that request. Please try again.