Open
Description
Bug summary
If I rasterized artists in DrawingArea
, they are rendered correctly in rasterized backend but will be misplaced in the vectorized backend
Code for reproduction
import matplotlib.pyplot as plt
from matplotlib.offsetbox import AnchoredOffsetbox, DrawingArea
from matplotlib.patches import Rectangle
from matplotlib.collections import PatchCollection
for backend in ["png", "pdf", "svg"]:
for rasterized in [True, False]:
fig, ax = plt.subplots(figsize=(2, 2))
box = DrawingArea(10, 10)
rects = PatchCollection([
Rectangle((0, i), width=10, height=1, ec="red")
for i in range(10)
])
rects.set_rasterized(rasterized)
box.add_artist(rects)
canvas = AnchoredOffsetbox(child=box, loc="center", pad=0)
ax.add_artist(canvas)
fig.savefig(f"DA_rasterized={rasterized}.{backend}")
Actual outcome
When set rasterized=True
and in backend svg
or pdf
:
In other situations, it's properly render:
Expected outcome
This is expected in any situation:
Additional information
No response
Operating system
OS/X arm
Matplotlib Version
3.9.1
Matplotlib Backend
module://matplotlib_inline.backend_inline
Python version
3.10.13
Jupyter version
4.1.1
Installation
pip
Metadata
Metadata
Assignees
Labels
No labels