In [1]:
from plotly_calplot import calplot
import pandas as pd
import numpy as np
from plotly import graph_objects as go
import calmap
In [2]:
df_calendar =  pd.read_csv("calendar_plot.csv")
In [3]:
df_calendar.day = pd.to_datetime(df_calendar.day, format="%Y-%m-%d")
In [18]:
# creating the plot

fig = go.Figure(data=calplot(
         df_calendar,
         x="day",
         y="count",
         years_title=True,
         title = 'Daily Crime Cases in Chicago from 2016 to 2021 ',
         dark_theme=False,
         month_lines_width=3, 
         month_lines_color="#e07a5f",
        colorscale = [(0, "rgb(0, 119, 182)"), (0.55, "rgb(92, 77, 125)"), (1, "rgb(255, 0, 43)")]
))
fig.update_traces(selector=dict(type="heatmap"), zmax=df_calendar["count"].max(), zmin=df_calendar["count"].min())

fig.update_traces(
        showscale=True,
        selector=dict(type="heatmap"),
    )

fig.update_layout(
   title=dict(font=dict(size=20,
                        family="Roboto Slab",
                        color="black")),
   title_x=0.5,
   title_y=0.98,
   margin = dict(t=70,b=50),
    plot_bgcolor = '#f5ebe0',
    paper_bgcolor="#edede9",
    font_family = "Roboto Slab"
    
)
fig.update_yaxes(ticks="outside", tickwidth=2, tickcolor='#edede9', ticklen=5, col=1)
fig.show()
fig.write_html("calendar.html")
In [ ]: