My problem is similar to the one encountered on this topic:
CodePudding user response:
Here are a couple ways to adapt that link for your use case (1 label per 6 months):
Either: Show an empty string except on Jan 1 and Jul 1 (i.e., when
%m%d
evals to0101
or0701
)labels = [date if date.strftime('%m%d') in ['0101', '0701'] else '' for date in df.index.date]
Or: Show an empty string except every ~365/2 days (i.e., when
row % 183 == 0
)labels = [date if row % 183 == 0 else '' for row, date in enumerate(df.index.date)]
Note that you don't have a MultiIndex, so you can just use df.index.date
(no need for get_level_values
).
Here is the output with a minimized version of your df
:
sns.heatmap(df, cmap='PuOr', cbar_kws={'label': 'Ice Velocity (m/yr)'},
vmin=df.values.min(), vmax=df.values.max(),
yticklabels=labels)