jmquintana79
10/15/2019 - 2:07 PM

Bar plot for timeseries data

## bar plot for timeseries data
def plot_timebars(df:'df'):
    """
    Bar plot for timeseries data.
    df -- dataframe with index datetime.
    """
    import matplotlib.pyplot as plt
    import matplotlib.dates as mdates
    fig, ax = plt.subplots(figsize=(15,5))
    ax.bar(df.index, df['estimation'])
    ax.xaxis.set_major_locator(mdates.DayLocator())
    ax.xaxis.set_major_formatter(mdates.DateFormatter('%b %d\n%a'))
    ax.grid(False)
    ax.set_title("estimated daily visitors")
    ax.set_xlabel("day")
    ax.set_ylabel("num. visitors")
    plt.show()