The 365 Data Science team is proud to invite you to our own community forum. A very well built system to support your queries, questions and give the chance to show your knowledge and help others in their path of becoming Data Science specialists.
Ask
Anybody can ask a question
Answer
Anybody can answer
Vote
The best answers are voted up and moderated by our team

Customer Analytics

Customer Analytics

0
Votes
1
Answer

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 Answer

365 Team
0
Votes

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

×
LAST CHANCE
Ready to Learn Data Science?
50% OFF