Python Question

Error trying to Plot data with different size using Matplotlib

I'm trying to plot two variables for several years. The first variable is measured every hour, and the second is measured every 24 hours. But both correspond to the same period. I'm using the following code:

x1= np.arange(0,129392)
fig_1,ax1 = plt.subplots()
ax1.plot(x1,Data_OBS_h,'k',marker='o',linestyle=' ',label='PM10-1h',linewidth=1.5)
ax1.tick_params(axis='x', labelsize=15)
ax1.tick_params(axis='y', labelsize=15)

I've made a secondary axis with values like 0,24,48,..But I'm getting the following error:

ValueError: x and y must have same first dimension.

Someone know how to fix this? In addition, I need to use
to be able to change size of

Thank you very much,
All the best,

Answer Source

Make sure this holds:

assert len(x1) == len(Data_OBS_h)
assert len(x2) == len(Data_OBS) 

then you should be able to plot what you want.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download