-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed
Description
Bug report
Bug summary
A recent upgrade to matplotlib 2.2.3 causes a crash when the following conditions are true:
- plot with alpha=0
- rasterized=True
- savefig to pdf.
similar bug report: #12003
Code for reproduction
import numpy as np
from matplotlib.pyplot import *
x = np.random.normal(0,1,5000)
y = np.random.normal(0,1,5000)
ax = subplot(111)
ax.plot(x,y,'g.',rasterized=True, alpha=0.)
savefig("bug.pdf",format='pdf',dpi=300)
show()
Actual outcome
ValueError Traceback (most recent call last)
<ipython-input-1-6378414f85f8> in <module>()
7 ax = subplot(111)
8 ax.plot(x,y,'g.',rasterized=True, alpha=0.)
----> 9 savefig("bug.pdf",format='pdf',dpi=300)
10 show()
~\Anaconda3\lib\site-packages\matplotlib\pyplot.py in savefig(*args, **kwargs)
693 def savefig(*args, **kwargs):
694 fig = gcf()
--> 695 res = fig.savefig(*args, **kwargs)
696 fig.canvas.draw_idle() # need this if 'transparent=True' to reset colors
697 return res
~\Anaconda3\lib\site-packages\matplotlib\figure.py in savefig(self, fname, **kwargs)
2060 self.set_frameon(frameon)
2061
-> 2062 self.canvas.print_figure(fname, **kwargs)
2063
2064 if frameon:
~\Anaconda3\lib\site-packages\matplotlib\backends\backend_qt5agg.py in print_figure(self, *args, **kwargs)
92
93 def print_figure(self, *args, **kwargs):
---> 94 super(FigureCanvasQTAgg, self).print_figure(*args, **kwargs)
95 self.draw()
96
~\Anaconda3\lib\site-packages\matplotlib\backend_bases.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs)
2261 orientation=orientation,
2262 bbox_inches_restore=_bbox_inches_restore,
-> 2263 **kwargs)
2264 finally:
2265 if bbox_inches and restore_bbox:
~\Anaconda3\lib\site-packages\matplotlib\backends\backend_pdf.py in print_pdf(self, filename, **kwargs)
2584 RendererPdf(file, image_dpi, height, width),
2585 bbox_inches_restore=_bbox_inches_restore)
-> 2586 self.figure.draw(renderer)
2587 renderer.finalize()
2588 if not isinstance(filename, PdfPages):
~\Anaconda3\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
53 renderer.start_filter()
54
---> 55 return draw(artist, renderer, *args, **kwargs)
56 finally:
57 if artist.get_agg_filter() is not None:
~\Anaconda3\lib\site-packages\matplotlib\figure.py in draw(self, renderer)
1491
1492 mimage._draw_list_compositing_images(
-> 1493 renderer, self, artists, self.suppressComposite)
1494
1495 renderer.close_group('figure')
~\Anaconda3\lib\site-packages\matplotlib\image.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
139 if not_composite or not has_images:
140 for a in artists:
--> 141 a.draw(renderer)
142 else:
143 # Composite any adjacent images together
~\Anaconda3\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
53 renderer.start_filter()
54
---> 55 return draw(artist, renderer, *args, **kwargs)
56 finally:
57 if artist.get_agg_filter() is not None:
~\Anaconda3\lib\site-packages\matplotlib\axes\_base.py in draw(self, renderer, inframe)
2633 renderer.stop_rasterizing()
2634
-> 2635 mimage._draw_list_compositing_images(renderer, self, artists)
2636
2637 renderer.close_group('axes')
~\Anaconda3\lib\site-packages\matplotlib\image.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
139 if not_composite or not has_images:
140 for a in artists:
--> 141 a.draw(renderer)
142 else:
143 # Composite any adjacent images together
~\Anaconda3\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
58 renderer.stop_filter(artist.get_agg_filter())
59 if artist.get_rasterized():
---> 60 renderer.stop_rasterizing()
61
62 draw_wrapper._supports_rasterization = True
~\Anaconda3\lib\site-packages\matplotlib\backends\backend_mixed.py in stop_rasterizing(self)
128
129 height = self._height * self.dpi
--> 130 buffer, bounds = self._raster_renderer.tostring_rgba_minimized()
131 l, b, w, h = bounds
132 if w > 0 and h > 0:
~\Anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py in tostring_rgba_minimized(self)
142 [extents[0] + extents[2], self.height - extents[1]]]
143 region = self.copy_from_bbox(bbox)
--> 144 return np.array(region), extents
145
146 def draw_path(self, gc, path, transform, rgbFace=None):
ValueError: negative dimensions are not allowed
Expected outcome
A pdf is saved successfully
Matplotlib version
- Operating system: Win10 1809 x64
- Matplotlib version: 2.2.3
- Matplotlib backend (
print(matplotlib.get_backend())
): Qt5Agg - Python version: 3.7.0
- Jupyter version (if applicable):
- Other libraries: numpy 1.5.1
Anaconda 5.3.0 x64
Metadata
Metadata
Assignees
Labels
No labels