I have a dataframe that forms a scatter_matrix, but I can't seem to save the image. How do I save it?
import pandas as pd
my_scatter = pd.scatter_matrix(my_dataframe, diagonal="kde")
How do I save my_scatter
?
Assuming you are using 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")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With