I have a DataFrame with a DateTime index:
import pandas as pd
from random import randrange
dates = pd.date_range(start="2020-02-01",end='2020-04-18',freq='1d')
df = pd.DataFrame(index=dates,data=[randrange(10000) for i in range(78)]
Now when I plot the data as a line plot, matplotlib produces a nicely formatted x axis:
df.plot(figsize=(12,4))
However, if instead I do a bar plot, I now get something quite horrible:
df.plot(kind='bar',figsize=(12,4)),
This is quite disconcerting, as it is the same DataFrame. What I want is to have the bar plot, but with the nicely formatted DateTime axis.
Is there an easy way to achieve that? I tried using the bar command directly, but that produces yet another x axis format, not as nice as the one generated by plotting with a pandas method.