import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
df = pd.read_csv('Iris.csv')
plot = plt.scatter(df['SepalLengthCm'], df['PetalLengthCm'])
plot.savefig('ScatterIris.png')
I'm trying to do some really basic matplotlib stuff and it keeps raising errors.
C:\Users\Robert\Anaconda3\python.exe
C:/Users/Robert/PycharmProjects/linear_regression/ML.py
Traceback (most recent call last):
File "C:/Users/Robert/PycharmProjects/linear_regression/ML.py", line 9, in <module>
plot.savefig('ScatterIris.png')
AttributeError: 'PathCollection' object has no attribute 'savefig'
First I couldn't use the .show() attribute and then I couldn't use the .savefig() attribute. Is there something wrong with my matplotlib installation?
For reference I tried changing the backend of my matplotib in matplotlibrc to a couple different ones and the same error everytime.
Edit @ nbryans
plt.scatter(df['SepalLengthCm'], df['PetalLengthCm']).savefig('ScatterIris.png')
Same error comes up
Edit 2:
Yeah you guys were right I can save figures and use the show() attribute/method. Thanks!
plt.savefig()savefig) that doesn't exist forPathCollectionobjects.