git.stats/src/gitstats/plots.py

20 lines
623 B
Python
Raw Normal View History

2023-09-02 19:57:48 +02:00
"""Plot contribution heatmap using calmap
ref. https://builtin.com/data-science/github-contribution-plot"""
import calmap
import pandas as pd
import matplotlib.pyplot as plt
def year_of_contributions(df: pd.DataFrame):
events = pd.Series(df["count"], index=df["date"])
fig = plt.figure(figsize=(20,8))
ax = fig.add_subplot(111)
cax = calmap.yearplot(events, # cmap='YlGn',
fillcolor='lightgrey',
daylabels="MTWTFSS",
dayticks=[0, 2, 4, 6],
linewidth=2,
ax=ax
)
# fig.colorbar(cax.get_children()[1], ax=cax, orientation='horizontal') # FIXME: this is ugly.