I have a dataset where there are stored the measurements of 30 devices. Each device has about 4000 values and it is structured as well:

device01 0.02;0.13;1.15;0.10;8.30;........;4.20
device02 0.06;0.13;1.40;0.03;7.40;........;6.30
device30 0.03;0.24;1.10;0.43;4.40;........;2.30

Each value is got each X seconds (I don't have the timestamp reference, I only know they are got through time). How can I plot them to get a single time series plot like the one in this picture? enter image description here

As you can see lots of the values do overlap, how can I make them consecutive in the plot?


You can create overlapping plots by looping over your dataset and plotting onto the same axes:

ax, fig = plt.subplots()
n = 30 # number of device
for i in (number+1 for number in range(n)):
    ax.plot(data[i], label='device_0' + i)


It might be best to first put your data into a pandas Dataframe.

In regard to the X-axis, you will need to convert the seconds to datetime, by adding an estimate of the starting date to each value in the dataset.

  • $\begingroup$ Hi, thanks for the reply. I tried your code, but what I would like to avoid is the overlap of the devices, because otherwise the results would be this: imgur.com/b97IvKx Since I need to find the anomalies in my dataset, my idea was to create a unique plot, so I transposed the data and this is the result: imgur.com/2CwJsri The problem is that I do not understand if does makes sense. What do you think? $\endgroup$
    – Fabio
    Mar 20 at 20:54
  • $\begingroup$ Pre 7000 data looks different, maybe plot that separately so you can see the difference between devices (i.e. eliminate the big variations, these look like noise(?)). You can use the alpha value to make the plots transparent. Otherwise you could plot using subplots for each device? e.g. ax, fig = plt.subplots(n) $\endgroup$
    – WBM
    Mar 20 at 21:03
  • $\begingroup$ It also really depends what you want to achieve. $\endgroup$
    – WBM
    Mar 20 at 21:05

Not the answer you're looking for? Browse other questions tagged or ask your own question.