Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

set_segments(get_segments()) makes lines coarse #20551

Copy link
Copy link
Closed
@nschloe

Description

@nschloe
Issue body actions

After plotting with contourf, I would like to retrieve the lines and manipulate them. Unfortunately, I noticed that the result is much coarser than without manipulation. In fact, a simple lc.set_segments(lc.get_segments()) has this effect. I would have expected this does nothing at all.

MWE:

import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(-1.1, 1.1, 100)
y = np.linspace(-1.1, 1.1, 100)

X, Y = np.meshgrid(x, y)
Z = X ** 2 + Y ** 2

c = plt.contour(X, Y, Z, levels=[1.0], colors="k")

# reset segments
lc = c.collections[0]
segments = lc.get_segments()
lc.set_segments(segments)

plt.gca().set_aspect("equal")
plt.show()
sc1 sc2
default with reset segments

This is with mpl 3.4.2.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.