I am using matplotlib to plot some data and my code looks like this
import datetime
import random
import matplotlib.pyplot as plt
x = [datetime.datetime.strptime(str(i), '%H') for i in range(24)]
# y is an array consists of 8640 elements for 1 day
y = [ 299.8, 299.8, 299.8, ....... 299.7, 299.7, 299.6, 299.6]
# z is an array consists of 144 elements for 1 day
z = [32, 32, 32.3, 33.54, .............31.43, 31.21, 36]
plt.plot(x,y)
plt.plot(x,z)
plt.show
but i get this error.
ValueError: x and y must have same first dimension
what i understand is that both x and y should equal length. "y" produced data every 10 seconds, so total 8640 points and "z" is the data which is produce every 10 minutes so total points 144. I look at SO and google but could not find to solve my problem. I try this one also 'plotting unix timestamps in matplotlib'
I am new to python and matplotlib. Can someone guide me how to solve this problem and to produce x-axis correctly. Thanks
xto the same time intervals that youryandzarrays are sampled atplt.plot(x, y)is fine but yourxdoes not make sense. It should contain the timestamp of every element iny. The same goes for plottingz. Here you need a differentxwith the timestams of the elements inz.xy = np.linspace(0, 1, 3000)andxz = np.linspace(0, 1, 1000). (3000/1000 points seems inconsistent with your question where you state 1000+/500)