I am struggling to understand how the gridlines work with matplotlib
specially when working with pandas
dataframe. I need to plot DatetimeIndex
vs multiple columns of the dataframe. Here is my code
import pandas
import matplotlib.pyplot as plt
plt.style.use("seaborn-whitegrid")
plt.rcParams.update({'figure.figsize': [15, 8],
'font.family': 'sans-serif',
'font.sans-serif': 'Verdana',
'font.size': 13,
'legend.frameon': True,
'legend.framealpha': 0.9,
'legend.facecolor': "white",
'legend.edgecolor': "black"})
d = pandas.DataFrame({"A": [x for x in range(12)], "B": [6 for x in range(12)]})
d.index = pandas.date_range("2021-01-01", "2021-01-01 11:00:00", freq="H")
ax = d.plot()
xtick_minor = pandas.date_range(start=d.index.min(), end=d.index.max(), freq='H')
ax.set_xticks(xtick_minor, minor=True)
ax.grid('on', which='both', axis='x', linestyle="--")
I also want a solid major grid line every 6 hours. How do I get that?