import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns from pandas_profiling import ProfileReport from sklearn import datasets from mpl_toolkits.mplot3d import Axes3D from sklearn.decomposition import PCA from sklearn.preprocessing import StandardScaler data=pd.read_csv('H:/analysis_results/mean_HN.csv') columns=['folder', 'volume', 'convex_volume', 'surface_area','length','max_width', 'max_depth'] data.head() values=data.iloc[:,1:7] correlation=values.corr() fig,ax=plt.subplots(figsize=(12,10)) sns.heatmap(correlation,annot=True,annot_kws={'size':16},cmap='Reds',square=True,ax=ax) sns.pairplot(data,hue='folder') plt.show()如何保存这两张图
时间: 2023-12-26 21:07:04 浏览: 138
import numpy as np import matplotlib.pyplot as plt import math
你可以在代码的最后添加以下语句来保存这两张图:
```python
fig.savefig('heatmap.png')
sns_plot = sns.pairplot(data,hue='folder')
sns_plot.savefig('pairplot.png')
```
这将会把热力图保存为 `heatmap.png`,把散点图矩阵保存为 `pairplot.png`,并将它们存储在当前工作目录下。请确保你有当前工作目录的写入权限。
阅读全文