I have two dataframes here. What I want to do is to plot these two dataframes on the same set of axes.
dict1 = {'Date': ['2022-12-02', '2022-12-16', '2023-01-15'], 'Impressions': [20, 21, 19]}
dict2 = {'Date': ['2022-08-02', '2022-09-16', '2023-02-20'], 'Impressions': [18, 51, 48]}
df1 = pd.DataFrame(dict1)
df2 = pd.DataFrame(dict2)
what I have done is this:
fig, ax = plt.subplots()
ax2 = ax.twinx()
df1.plot(x="Date", y="Impressions", ax=ax)
df2.plot(x="Date", y="Impressions", ax=ax2, ls="--")
plt.show()
This did not give the results I want, as the solid line graph starts on the same date as the broken line, i.e 2022-08-02 instead of 2022-12-02 and ends on the 2023-02-20 instead of 2023-02-15. How can I fix this?
This is the graph I get: