I am new to Data Science and Python.
I have a Data Set with date range Starting: "2020-03-15" and Ending: "2022-02-23". On each date there are multiple activities.
I am looking forward to create a Histogram to display the number of activities in the y-axis. On the x-axis I want to distribute the date range in quarterly bin (buckets).
e.g
y-axis = Number of counter
x-axis = Q1-2020 (2020-03-15 to 2020-03-31), Q2-2020 (2020-04-01 to 2020-06-30), ... END
If there is a better solution then please direct or guide. Can any body please help or guide me here.
I was able to create a solution as below:
import matplotlib.pyplot as plt
from matplotlib.ticker import StrMethodFormatter
ax = df.hist(column='COLUMN_NAME', bins=25, grid=False, figsize=(12,8), color='#274490', zorder=2, rwidth=0.9)
ax = ax[0]
for x in ax:
# Despine
x.spines['right'].set_visible(False)
x.spines['top'].set_visible(False)
x.spines['left'].set_visible(False)
# Switch off ticks
x.tick_params(axis="both", which="both", bottom="off", top="off", labelbottom="on", left="off", right="off", labelleft="on")
# Draw horizontal axis lines
vals = x.get_yticks()
for tick in vals:
x.axhline(y=tick, linestyle='dashed', alpha=0.4, color='#eeeeee', zorder=1)
# Remove title
x.set_title("")
# Set x-axis label
x.set_xlabel("Distribution", labelpad=20, weight='bold', size=12)
# Set y-axis label
x.set_ylabel("Observations", labelpad=20, weight='bold', size=12)
# Format y-axis label
x.yaxis.set_major_formatter(StrMethodFormatter('{x:,g}'))