Closed
Description
This is the root cause of #16461. The single path optimisation does not correctly take into account offsets:
matplotlib/lib/matplotlib/collections.py
Lines 354 to 362 in acc7ecb
As an example, this code creates two collections which differ only by their edgecolors
, and have an offset of [0.5, 0.5]
. In both cases the collection should be drawn at the offset, but only the collection with edgecolors=None
is correct, because this does not follow the 'optimised' code path above.
import matplotlib.pyplot as plt
import matplotlib.collections as mcoll
import matplotlib.transforms as mtransforms
import numpy as np
polygon = np.array([[-1, -1], [-1, 1], [1, 1], [1, -1]]) * 0.1
offsets = np.array([0.5, 0.5])
fig, axs = plt.subplots(ncols=2)
for ax, edgecolors in zip(axs, [None, 'face']):
collection = mcoll.PolyCollection(
[polygon],
edgecolors=edgecolors,
linewidths=[1],
offsets=offsets,
transOffset=mtransforms.IdentityTransform(),
offset_position="data"
)
ax.add_collection(collection)
plt.show()
Metadata
Metadata
Assignees
Labels
No labels