UDG
UDG

Reputation: 23

Plotting two time series with different sampling rates on same figure in python from a csv

I have two time series datasets that were collected for the same duration of time (roughly 900 seconds). But both of the sampling rates were different so the two csv files have different lengths:

DatasetM=4839 points

DatasetP=8727 points

How do I plot the "TSI" values on the same figure over the same timeframe (900s)?

I have been trying this:

y1 = plot_datasetp['TSI']
y2 = plot_datasetm['TSI']
x1 = plot_datasetp['Sample #']

plt.figure()
plt.plot(y1)
plt.plot(x1, y2)

And keep getting this error:

x and y must have same first dimension, but have shapes (8727,)and (4840,)

I am looking for the most efficient way to develop this code in python as I don't have much experience.

Thanks!

Upvotes: 0

Views: 712

Answers (1)

UDG
UDG

Reputation: 23

I am so silly. I ended up figuring it out!

I made an array using the following code

x = np.linspace(0,8727,4840)

and plotted it:

plt.plot(x,y2)

and it worked...so simple!

Upvotes: 1

Related Questions