Closed
Description
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()
![]() |
![]() |
---|---|
default | with reset segments |
This is with mpl 3.4.2.