0

I have data samples, that have a magnitude, with an associated time & date of when the sample was taken.

I would like to plot these datapoints over time, but would like the datapoints spaced, proportionally to the time they were sampled.

Essentially I have a person that is taking various numbers of readings per day, at inconsistent time periods.

Any ideas on how to create this time plot?

Example Data:

Mag    : Time     , Date
4.0 in : 11:12:02 , 11/11/21
4.3 in : 13:27:01 , 11/11/21
7.5 in : 14:01:45 , 11/11/21
2.1 in : 01:27:54 , 11/13/21
1.4 in : 16:32:41,  11/13/21
0.7 in : 14:12:09,  11/14/21
0.8 in : 14:12:13,  11/14/21

I would like to either sample and hold (til next datapoint), or (preferably) if possible, connect each point of the trace with a linear line, and apply a smoothing function, so there are no abrupt features in the line plot.

Once I get this plotted, I would also like to possibly resample and/or integrate the area under the curve... but that can be a task for another day.

Thanks!

  • 1
    You have a lot of different things you want to accomplish here. I would start by the plotting, and remove the rest -- like you say problems for another day. Have you tried? Are you familiar with plotting dates in python? Are you familiar with `matplotlib`? – ramzeek Mar 16 '22 at 02:51
  • I have plotted data in python before, but my question really concerns the irregularity of my sampling intervals. I need to retain the time information, so when I do work these other tasks, the data isn't skewed. (And I can properly resample or integrate the area under the curve) For example, if I was measuring humidity, I don't want the Monday, that had 10 samples, skewing Tuesday that have only 1 sample. 100% Humidity on Monday (Sampled 10 Times) and 0% Humidity on Tuesday (Sampled 1 Time) Average humidity between Monday and Tuesday using this method is 90% (Instead of 50%) – CalicoBrak Mar 16 '22 at 04:53
  • You will get more responses to your question if you show you have researched the problem and tried to plot it. Based on your reply it sounds like you need to know how to do `matplitlib.pyplot.plot(x,y)` with date time objects (there is no need for `x` values to be evenly spaced). I'd suggest starting [here](https://stackoverflow.com/questions/9627686/plotting-dates-on-the-x-axis-with-pythons-matplotlib). There are plenty of questions on SO about [`datetime`](https://docs.python.org/3/library/datetime.html) in python. You need to format your date strings similar to: `%H:%M:%S %m/%d/%y`. – ramzeek Mar 17 '22 at 14:04

0 Answers0