[英]How to save multiple seaborn plots to the same pdf/png file?
I'm struggling to save the a few plots on the same pdf. 我正在努力将几张图保存在同一PDF上。 The data source is a dataframe.
数据源是一个数据框。 I considered saving them as png, but that is not practical at all..
我考虑过将它们另存为png,但这一点都不实际。
pdf_pages = PdfPages('kde.pdf')
for i in range(1,114):
for j in range(0,113):
x=t1.iloc[:,i]
y=t1.iloc[:,j]
fig=sns.jointplot(x=x, y=y, kind="kde",dropna=True);
pdf_pages.savefig(fig)
Seaborn's jointplot
does not return a figure
, it returns a seaborn.JointGrid
instance. Seaborn的
jointplot
不返回figure
,而是返回一个seaborn.JointGrid
实例。
You need to pass a figure to pdf_pages.savefig
, so use: 您需要将数字传递给
pdf_pages.savefig
,因此请使用:
with PdfPages('kde.pdf') as pdf_pages:
for i in range(1, 114):
for j in range(0, 113):
x=t1.iloc[:, i]
y=t1.iloc[:, j]
joint_grid = sns.jointplot(x=x, y=y, kind="kde", dropna=True)
pdf_pages.savefig(joint_grid.fig)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.