You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Traceback (most recent call last):
File "test.py", line 23, in <module>
pyplot.savefig('test.pdf')
File "/home/edwin/matplotlib/lib/matplotlib/pyplot.py", line 954, in savefig
res = fig.savefig(*args, **kwargs)
File "/home/edwin/matplotlib/lib/matplotlib/figure.py", line 3273, in savefig
self.canvas.print_figure(fname, **kwargs)
File "/home/edwin/matplotlib/lib/matplotlib/backend_bases.py", line 2357, in print_figure
result = print_method(
File "/home/edwin/matplotlib/lib/matplotlib/backend_bases.py", line 2223, in <lambda>
print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
File "/home/edwin/matplotlib/lib/matplotlib/backends/backend_pdf.py", line 2815, in print_pdf
self.figure.draw(renderer)
File "/home/edwin/matplotlib/lib/matplotlib/artist.py", line 74, in draw_wrapper
result = draw(artist, renderer, *args, **kwargs)
File "/home/edwin/matplotlib/lib/matplotlib/artist.py", line 51, in draw_wrapper
return draw(artist, renderer)
File "/home/edwin/matplotlib/lib/matplotlib/figure.py", line 3070, in draw
mimage._draw_list_compositing_images(
File "/home/edwin/matplotlib/lib/matplotlib/image.py", line 131, in _draw_list_compositing_images
a.draw(renderer)
File "/home/edwin/matplotlib/lib/matplotlib/artist.py", line 51, in draw_wrapper
return draw(artist, renderer)
File "/home/edwin/matplotlib/lib/matplotlib/axes/_base.py", line 3151, in draw
mimage._draw_list_compositing_images(
File "/home/edwin/matplotlib/lib/matplotlib/image.py", line 131, in _draw_list_compositing_images
a.draw(renderer)
File "/home/edwin/matplotlib/lib/matplotlib/artist.py", line 45, in draw_wrapper
renderer.stop_rasterizing()
File "/home/edwin/matplotlib/lib/matplotlib/backends/backend_mixed.py", line 97, in stop_rasterizing
img = np.asarray(self._raster_renderer.buffer_rgba())
AttributeError: 'NoneType' object has no attribute 'buffer_rgba'
Expected outcome
Additional information
The bug appears in version 3.5.1 and commit 2d18bba, but not version 3.1.2.
The most immediate cause seems to be reentrance tracking being dropped from MixedModeRenderer.start_rasterizing() and MixedModeRenderer.stop_rasterizing() in commit b6a2739:
As mentionedd in 3.4.0 api changes behaviour.rst the tracking should
be handled there.
This commit avoids calling stop_rasterizing method twice in row making
it throw an exception.
Fixesmatplotlib#24235
If an artist was rasterized both by setting state on the artist and
be being below the z-order threshold than we would try to stop rasterization
one too many times.
This constructions lets us re-use the `allow_rasterization` logic.
closesmatplotlib#24235
If an artist was rasterized both by setting state on the artist and
be being below the z-order threshold than we would try to stop rasterization
one too many times.
This constructions lets us re-use the `allow_rasterization` logic.
closesmatplotlib#24235
Uh oh!
There was an error while loading. Please reload this page.
Bug summary
According to the documentation, a color plot can be rasterized in two ways:
pyplot.pcolormesh(…, rasterized=True)
pyplot.gca().set_rasterization_zorder(…)
The two ways cannot be used together.
Code for reproduction
Actual outcome
Expected outcome
Additional information
The bug appears in version 3.5.1 and commit 2d18bba, but not version 3.1.2.
The most immediate cause seems to be reentrance tracking being dropped from
MixedModeRenderer.start_rasterizing()
andMixedModeRenderer.stop_rasterizing()
in commit b6a2739:matplotlib/lib/matplotlib/backends/backend_mixed.py
Lines 87 to 88 in b6a2739
matplotlib/lib/matplotlib/backends/backend_mixed.py
Line 116 in b6a2739
However, these are probably not the right places to fix this bug.
Operating system
Ubuntu 20.04, 22.04
Matplotlib Version
3.1.2, 3.5.1, 3.7.0.dev447+g2d18bba0ea
Matplotlib Backend
agg
Python version
3.8.10, 3.10.6
Jupyter version
No response
Installation
git checkout
The text was updated successfully, but these errors were encountered: