6

我有一个形成 scatter_matrix 的数据框,但我似乎无法保存图像。我该如何保存?

import pandas as pd
my_scatter = pd.scatter_matrix(my_dataframe, diagonal="kde")

我该如何保存my_scatter

4

2 回答 2

9

假设您使用的是 matplotlib:

import pandas as pd
import numpy as np # Only necessary for this example if you don't use it no poblem
import matplotlib.pyplot as plt

# Random data
my_dataframe = pd.DataFrame(np.random.randn(1000, 4), columns=['a', 'b', 'c', 'd'])

# Your plotting funciton
my_scatter = pd.scatter_matrix(my_dataframe, diagonal="kde")

# Save the figure (this can also be a path). As it stands now it will save in this codes directory.
plt.savefig(r"figure_1.png")
于 2013-05-14T18:34:21.123 回答
0

你在使用 IPython 吗?如果您在 IPython 笔记本中,您尝试过savefig('/path/to/filename.png')吗?

于 2013-05-14T07:14:36.023 回答