美文网首页
Matplotlib: 多张图像存放到一个 PDF 中

Matplotlib: 多张图像存放到一个 PDF 中

作者: LET149 | 来源:发表于2025-04-06 22:37 被阅读0次

https://matplotlib.org/stable/api/backend_pdf_api.html#module-matplotlib.backends.backend_pdf

matplotlib.backends.backend_pdf()

import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages

pdf_used = PdfPages("/data/Zhiyong/AAA__Work/Analysis/PM-FCA/Figure-2/E___Resolution-selection_and_Marker-validation/marker_validation/output.pdf")     '# create the object to stote all plot

sc.pl.tsne(scanpy_oject_used, color='res_3_celltype', size=7, show=False)     # plot the first figure
fig_used=plt.gcf()     # capture the new plot
fig_used.set_size_inches(5,5)     # change the size of the current plot
pdf_used.savefig(fig_used)     # save the current plot to the pdf_used
plt.close()     # close the current plot

sc.pl.tsne(scanpy_oject_used, color='res_3_celltype', size=1, show=False)     # plot the second figure
fig_used=plt.gcf()
fig_used.set_size_inches(7,5)
pdf_used.savefig(fig_used)
plt.close()

pdf.close()     # close and output the pdf file

相关文章

网友评论

      本文标题:Matplotlib: 多张图像存放到一个 PDF 中

      本文链接:https://www.haomeiwen.com/subject/infwpjtx.html