I have a pandas df as follows:
ipdb> df_calmap
count
start_datetime
2021-03-10 17:40:24 1
2021-03-11 23:41:34 1
2021-03-12 00:41:42 1
2021-03-12 13:11:25 1
2021-03-15 00:02:49 1
2021-03-15 11:40:50 1
2021-03-17 12:42:14 1
2021-03-18 01:50:22 1
2021-03-21 19:10:55 1
2021-03-22 15:00:06 1
2021-03-25 00:22:22 1
2021-03-26 16:33:11 1
2021-03-29 19:16:59 1
2021-03-30 17:58:53 1
2021-03-31 17:46:08 1
I am able to draw a heatmap using calmap, however I would like to have the colorbar the same size as the image as shown here on a similar answer to my question. However, the code does not work for me. I don't seem to be able to achieve what I want.
I have searched the matplotlib doc but I couldn't make it work either. Here is my current code. Thank you very much.
def plot_trades_heatmap_chart(self):
df_calmap = ...
fig, ax = calmap.calendarplot(df_calmap['count'], monthticks=1, daylabels='MTWTFSS',
dayticks=[0, 1, 2, 3, 4, 5, 6], cmap='RdYlGn',
fillcolor='whitesmoke', linewidth=0.3,
fig_kws=dict(figsize=(8, 4)))
# Vertical
fig.colorbar(ax[0].get_children()[1], ax=ax.ravel().tolist())
plt.xlabel("Trades grouped by day", fontsize=12)
fig.suptitle('Number of trades per day heatmap', fontsize=16)
return(fig)
The expected output should be like this:
Thank you very much!