Customer Analytics
plt.figure(figsize=(12,9))
s = sns.heatmap(df_segmentation.corr(), annot=True ,cmap= 'RdBu', vmin = -1, vmax = 1)
s.set_yticklabels(s.get_yticklabels, rotation = 0, fontsize = 12)
s.set_xticklabels(s.get_xticklabels, rotation = 90, fontsize = 12)
plt.title("Correlation .heatmap")
plt.show()
while running above code it was showing error....i'm trying to fix it....but i didn't get it
Note: My editor is Google colab... i'm using all updated versions
Error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-44-01cbef8b82eb> in <module>() 1 plt.figure(figsize=(12,9)) 2 s = sns.heatmap(df_segmentation.corr(), annot=True ,cmap= 'RdBu', vmin = -1, vmax = 1) ----> 3 s.set_yticklabels(s.get_yticklabels, rotation = 0, fontsize = 12) 4 s.set_xticklabels(s.get_xticklabels, rotation = 90, fontsize = 12) 5 plt.title("Correlation .heatmap")
1 frames
/usr/local/lib/python3.6/dist-packages/matplotlib/axis.py in set_ticklabels(self, ticklabels, minor, *args, **kwargs) 1714 "3.1; passing them will raise a TypeError in Matplotlib 3.3.") 1715 get_labels = [] -> 1716 for t in ticklabels: 1717 # try calling get_text() to check whether it is Text object 1718 # if it is Text, get label content
TypeError: 'method' object is not iterable
1 answers ( 0 marked as helpful)
Hi
you've forgotten to add () after get_yticklabels and get_xticklabels methods.
The proper commands are:
s.set_yticklabels(s.get_yticklabels(), rotation = 0, fontsize = 12)
s.set_xticklabels(s.get_xticklabels(), rotation = 90, fontsize = 12) Best, Eli
s.set_xticklabels(s.get_xticklabels(), rotation = 90, fontsize = 12) Best, Eli