I can't give my graph a title after giving it a legend (seaborn)

My code:

slope, intercept, r_value, p_value, std_err = stats.linregress(ages_charges['age'],ages_charges['charges'])

).legend().set_title('The Linear Regression Equation')
scat.set_title('The Correlation between Age and Charge Amount')
#when running the above line I get an Attribute Error: 'NoneType' object has no attribute 'set_title'

The seaborn regplot function will return the axis reference as per- http://seaborn.pydata.org/generated/seaborn.regplot.html

However, by using the methods of this axis on the same line what actually gets returned is the return from the method itself, which in this case is the None object. A similar thing can be seen if you tried to assign a list after calling its .sort method.

a_name = [0, 1, 2].sort()  # what we actually assign is the return from the method itself
print(a_name is None)
Out: True

Return the axis object and then start calling its methods to change it. If there are a lot of changes to be made consider the axis.set() method.

*bumped this into get help-Python

1 Like