I get some problems when I tried to save a plot to a PDF file. The plot looks good in the notebook, but I cannot save it to a PDF.
Saving figure to ./plot/celltype.pdf...
ValueError Traceback (most recent call last)
in
1 dyn.pl.streamline_plot(adata, color=['celltype'], basis='umap', show_legend='on data', show_arrowed_spines=True, pointsize = 0.3, theme = "darkred", save_show_or_return = "return")
----> 2 dyn.pl.save_fig("./plot/celltype")
3
4
~/.local/lib/python3.7/site-packages/dynamo_release-0.95.2-py3.7.egg/dynamo/plot/utils.py in save_fig(path, prefix, dpi, ext, transparent, close, verbose)
1251
1252 # Actually save the figure
-> 1253 plt.savefig(savepath, dpi=300 if dpi is None else dpi, transparent=transparent, format=ext, bbox_inches='tight')
1254
1255 # Close it
~/miniconda3/lib/python3.7/site-packages/matplotlib/pyplot.py in savefig(*args, **kwargs)
857 def savefig(*args, **kwargs):
858 fig = gcf()
--> 859 res = fig.savefig(*args, **kwargs)
860 fig.canvas.draw_idle() # need this if 'transparent=True' to reset colors
861 return res
~/miniconda3/lib/python3.7/site-packages/matplotlib/figure.py in savefig(self, fname, transparent, **kwargs)
2309 patch.set_edgecolor('none')
2310
-> 2311 self.canvas.print_figure(fname, **kwargs)
2312
2313 if transparent:
~/miniconda3/lib/python3.7/site-packages/matplotlib/backend_bases.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2215 orientation=orientation,
2216 bbox_inches_restore=_bbox_inches_restore,
-> 2217 **kwargs)
2218 finally:
2219 if bbox_inches and restore_bbox:
~/miniconda3/lib/python3.7/site-packages/matplotlib/backend_bases.py in wrapper(*args, **kwargs)
1637 kwargs.pop(arg)
1638
-> 1639 return func(*args, **kwargs)
1640
1641 return wrapper
~/miniconda3/lib/python3.7/site-packages/matplotlib/backends/backend_pdf.py in print_pdf(self, filename, dpi, bbox_inches_restore, metadata)
2591 RendererPdf(file, dpi, height, width),
2592 bbox_inches_restore=bbox_inches_restore)
-> 2593 self.figure.draw(renderer)
2594 renderer.finalize()
2595 if not isinstance(filename, PdfPages):
~/miniconda3/lib/python3.7/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
39 renderer.start_filter()
40
---> 41 return draw(artist, renderer, *args, **kwargs)
42 finally:
43 if artist.get_agg_filter() is not None:
~/miniconda3/lib/python3.7/site-packages/matplotlib/figure.py in draw(self, renderer)
1862 self.patch.draw(renderer)
1863 mimage._draw_list_compositing_images(
-> 1864 renderer, self, artists, self.suppressComposite)
1865
1866 renderer.close_group('figure')
~/miniconda3/lib/python3.7/site-packages/matplotlib/image.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
129 if not_composite or not has_images:
130 for a in artists:
--> 131 a.draw(renderer)
132 else:
133 # Composite any adjacent images together
~/miniconda3/lib/python3.7/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
39 renderer.start_filter()
40
---> 41 return draw(artist, renderer, *args, **kwargs)
42 finally:
43 if artist.get_agg_filter() is not None:
~/miniconda3/lib/python3.7/site-packages/matplotlib/cbook/deprecation.py in wrapper(*inner_args, **inner_kwargs)
409 else deprecation_addendum,
410 **kwargs)
--> 411 return func(*inner_args, **inner_kwargs)
412
413 return wrapper
~/miniconda3/lib/python3.7/site-packages/matplotlib/axes/_base.py in draw(self, renderer, inframe)
2745 renderer.stop_rasterizing()
2746
-> 2747 mimage._draw_list_compositing_images(renderer, self, artists)
2748
2749 renderer.close_group('axes')
~/miniconda3/lib/python3.7/site-packages/matplotlib/image.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
129 if not_composite or not has_images:
130 for a in artists:
--> 131 a.draw(renderer)
132 else:
133 # Composite any adjacent images together
~/miniconda3/lib/python3.7/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
39 renderer.start_filter()
40
---> 41 return draw(artist, renderer, *args, **kwargs)
42 finally:
43 if artist.get_agg_filter() is not None:
~/miniconda3/lib/python3.7/site-packages/matplotlib/collections.py in draw(self, renderer)
410 self._linewidths, self._linestyles,
411 self._antialiaseds, self._urls,
--> 412 self._offset_position)
413
414 gc.restore()
~/miniconda3/lib/python3.7/site-packages/matplotlib/backends/backend_pdf.py in draw_path_collection(self, gc, master_transform, paths, all_transforms, offsets, offsetTrans, facecolors, edgecolors, linewidths, linestyles, antialiaseds, urls, offset_position)
1873 offsets, offsetTrans, facecolors, edgecolors,
1874 linewidths, linestyles, antialiaseds, urls,
-> 1875 offset_position)
1876
1877 padding = np.max(linewidths)
~/miniconda3/lib/python3.7/site-packages/matplotlib/backend_bases.py in draw_path_collection(self, gc, master_transform, paths, all_transforms, offsets, offsetTrans, facecolors, edgecolors, linewidths, linestyles, antialiaseds, urls, offset_position)
240 transform = transform.frozen()
241 transform.translate(xo, yo)
--> 242 self.draw_path(gc0, path, transform, rgbFace)
243
244 def draw_quad_mesh(self, gc, master_transform, meshWidth, meshHeight,
~/miniconda3/lib/python3.7/site-packages/matplotlib/backends/backend_pdf.py in draw_path(self, gc, path, transform, rgbFace)
1821 def draw_path(self, gc, path, transform, rgbFace=None):
1822 # docstring inherited
-> 1823 self.check_gc(gc, rgbFace)
1824 self.file.writePath(
1825 path, transform,
~/miniconda3/lib/python3.7/site-packages/matplotlib/backends/backend_pdf.py in check_gc(self, gc, fillcolor)
1771 delta = self.gc.delta(gc)
1772 if delta:
-> 1773 self.file.output(*delta)
1774
1775 # Restore gc to avoid unwanted side effects
~/miniconda3/lib/python3.7/site-packages/matplotlib/backends/backend_pdf.py in output(self, *data)
730
731 def output(self, *data):
--> 732 self.write(fill([pdfRepr(x) for x in data]))
733 self.write(b'\n')
734
~/miniconda3/lib/python3.7/site-packages/matplotlib/backends/backend_pdf.py in (.0)
730
731 def output(self, *data):
--> 732 self.write(fill([pdfRepr(x) for x in data]))
733 self.write(b'\n')
734
~/miniconda3/lib/python3.7/site-packages/matplotlib/backends/backend_pdf.py in pdfRepr(obj)
252 elif isinstance(obj, (float, np.floating)):
253 if not np.isfinite(obj):
--> 254 raise ValueError("Can only output finite numbers in PDF")
255 r = b"%.10f" % obj
256 return r.rstrip(b'0').rstrip(b'.')
ValueError: Can only output finite numbers in PDF