Plotting TimeStamp Data from Excel -
i have data recorded on excel sheet. data timestamp.
i plot recorded time-stamp first image values similar second following figure.
answering both question , comment, want build histogram of occurrences in time.
you need define size of bin want. let's bin size 5 minutes, , want plot histogram 24 hours period.
doing hand
create little table follows:
| b | c ----------------------------------------------------- 1 | start | end | event_count 2 | 00:00:00 | =a2 + time(0,5,0) | =countifs(datasheet!g:g,">=" & a2,datasheet!g:g,"<" & b2) 3 | =b2 | =a3 + time(0,5,0) | =countifs(datasheet!g:g,">=" & a3,datasheet!g:g,"<" & b3)
copy formulas in row 3 times need. create bar chart.
notice value in formula written in cells b2
, b3
,... size of bin specifying.
doing code
since programming q&a site, programming solution expected:
public sub createmytimehistogram(inputrange range, binsize integer) ' parameters: ' inputrange: range stores data ' binsize: size of bin (in minutes) dim t date dim n integer dim outputsheet string, outputrow long t = timeserial(0,0,0) outputsheet = "myoutputsheet" ' i'll assume worksheet exists in current workbook, ' , empty thisworkbook.sheets(outputsheet) .cells(1,1).value = "bin" .cells(1,2).value = "count" end outputrow = 2 while t < 1 n = excel.worksheetfunction.countifs(inputrange, ">=" & cdbl(t), inputrange, "<" & cdbl(t + timeserial(0,binsize,0))) thisworkbook.sheets(outputsheet) .cells(outputrow, 1).value = t .cells(outputrow, 2).value = n end t + timeserial(0,binsize,0) outputrow = outputrow + 1 wend end sub
Comments
Post a Comment