X Tutup
Skip to content

zorder values as a sequence are not respected by LineCollection #8465

@afvincent

Description

@afvincent

Bug summary

Looking at LineCollection docstring, one can read: “All parameters must be sequences or scalars” so I would expect passing a sequence of zorder values to be fine. Unfortunately, it does not seem to be working and it looks like the lines zorder correspond to their ”index” in the collection.

Code for reproduction

import matplotlib.pyplot as plt
from matplotlib.collections import LineCollection

ll = LineCollection([((0, 0), (1, 1)),  # tilted line
                     ((0.2, 0), (0.2, 1)),  # vertical line
                     ((0, 0.5), (1, 0.5))],  # horizontal line
                    colors=['r', 'g', 'b'], zorder=[5, 10, 2], linewidths=10)

fig, ax = plt.subplots()
ax.add_collection(ll)

plt.show()

print(ll.get_zorder())  # [5, 10, 2] so the expected result is:
                        # vertical green > oblique red > horizontal blue

# fig.savefig('expecting_green_over_red_over_blue.png')

Actual outcome
expecting_green_over_red_over_blue

Expected outcome
Based on the passed and returned zorder values, one would expect:
vertical green > oblique red > horizontal blue

Matplotlib version

Tested on Matplotlib 2.0.0.post3871+gf9e0b92 from GitHub and 1.5.1 from conda, on Linux (CentOS 7) and with Python 2.7.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup