I want to do the bar plot using pandas
but the xticks
are incorrect for date
type (there are integers starting from 0). Here is my code:
import matplotlib.pyplot as plt
import datetime as dt
import pandas as pd
y = [dt.date(2021, 12, 12), dt.date(2022, 6, 12), dt.date(2023, 12, 12)]
df = pd.DataFrame()
df["Date"] = y
df["V1"] = [0, 0.2, 0.8]
df["V2"] = [0.4, 0.3, 0.3]
# df.set_index("Date", inplace = True)
ax = df.plot.bar(x = "Date", stacked = True)
print(ax.get_xticks())
fig, ax = plt.subplots()
ax.plot(df["Date"], df["V1"])
print(ax.get_xticks())
How can I fix that?