0

I have big sparce pandas dataframe and using seaborn.heatmap to visualize it. The problem is I cannot have proper ticks on x and y axis - format is unreadable! On the x axis we have column names, which is strings and in the y axis it is index of datetime64 type. I tried code like

import matplotlib.dates as mdates

f, ax = plt.subplots(1, figsize=(8,8))
sns.heatmap(pvt.iloc[:,:], ax=ax)

ax.yaxis.set_major_formatter(mdates.DateFormatter("%Y-%m"))
ax.yaxis.set_minor_formatter(mdates.DateFormatter("%Y-%m"))

but this causes an error

Cannot convert 0 to a date. This often happens if non-datetime values are passed to an axis that expects datetime objects.

I think the problem is index has datetime64 type, but cannot handle with this. Please, help.

How it looks now:
How it looks now

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
user1443993
  • 371
  • 4
  • 10

0 Answers0