I have 5 time series (class pandas.core.series.Series
) with different frequencies and I want to make this chart:
desired chart
df1 (daily data, only working days)
Date exchange_rate_daily
2013-01-02 25.225
2013-01-03 25.26
2013-01-04 25.35
2013-01-07 25.535
2013-01-08 25.58
2013-01-09 25.53
2013-01-10 25.63
2013-01-11 25.615
2013-01-14 25.615
2013-01-15 25.61
2013-01-16 25.58
2013-01-17 25.54
2013-01-18 25.63
2013-01-21 25.625
df2 (monthly data for 2 time series)
Date intervention_monthly client_monthly
2013-01-01 0.6 0.67273
2013-02-01 0.2 0.04
2013-03-01 0.4 0.17443
2013-04-01 0.3 0.53883
2013-05-01 0.7 -0.0647
2013-06-01 0.2 0.20103
2013-07-01 0.0 0.22846
2013-08-01 0.0 -0.2611
2013-09-01 0.0 0.16002
2013-10-01 0.0 -0.10967
2013-11-01 7.4 -0.31122
Line chart:
X-axis: date_exchangerate_daily
(size = 2198, daily date i.e. 2013-01-02 00:00:00
, but only business days - no weekends, no holidays)
Y-axis (left): `exchangerate_daily (size = 2198, daily exchange rate)
My code for this line chart works well. See below:
fig, ax1 = plt.subplots(figsize=(10,6))
ax1.plot(date_exchangerate_daily, exchangerate_daily, color="k", label="Exchange rate (daily)", linewidth=2)
ax1.legend(loc = "upper left")
Grouped bar chart:
X-axis: date_operations_monthly
(size = 107, monthly date e.g. 2013-01-01 00:00:00
)
Y-axis (right): intervention_monthly
(size = 107, monthly data)
Y-axis (right): client_monthly
(size = 107, monthly data)
x = np.arange(len(date_operations_monthly))
width = 0.1
ax2 = ax1.twinx()
rects1 = ax2.bar(x - width/2, intervention_monthly, width, label='Intervention (monthly)')
rects2 = ax2.bar(x + width/2, client_monthly, width, label='Client operation (monthly)')
ax2.set_xticks(x)
ax2.set_xticklabels(date_operations_monthly2, rotation = 70)
ax2.legend(loc = "upper right")
And I get this chart: chart
If I plot the charts separately, I get the right charts. So there is a problem with combining these two charts. And I guess the problem is that the data frequency is different and then the size of the dates series (daily x monthly date) I want to plot on the X-axis is different. Is there please any solutions for this?
Thank you so much.