20 lines
623 B
Python
20 lines
623 B
Python
|
"""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.
|