Message Boards Message Boards

GROUPS:

Plot a list and array matrix data with date objects?

Posted 6 months ago
998 Views
|
3 Replies
|
4 Total Likes
|

I need to combine a dated Object list to the data list for a time plot. I am able to get a series plot for the data but not getting a time plot. What I am doing incorrect? Notebook attached (test2222.nb)

dates1 = \!\(\*
TagBox[
StyleBox[
RowBox[{"List", "[", 
RowBox[{
RowBox[{"DateObject", "[", 
RowBox[{
RowBox[{"List", "[", 
RowBox[{"2019", ",", "1", ",", "21", ",", "10", ",", "18", ",", 
"0.9855802`7.746266959226736"}], "]"}], ",", 
"\"\<Instant\>\"", ",", "\"\<Gregorian\>\"", ",", 
RowBox[{"-", "4.`"}]}], "]"}], ",", 
RowBox[{"DateObject", "[", 
RowBox[{
RowBox[{"List", "[", 
RowBox[{"2019", ",", "1", ",", "21", ",", "10", ",", "18", ",", 
"2.0161095`8.057089099749374"}], "]"}], ",", 
"\"\<Instant\>\"", ",", "\"\<Gregorian\>\"", ",", 
RowBox[{"-", "4.`"}]}], "]"}], ",", 
RowBox[{"DateObject", "[", 
RowBox[{
RowBox[{"List", "[", 
RowBox[{"2019", ",", "1", ",", "21", ",", "10", ",", "18", ",", 
"3.0089646`8.230992059340544"}], "]"}], ",", 
"\"\<Instant\>\"", ",", "\"\<Gregorian\>\"", ",", 
RowBox[{"-", "4.`"}]}], "]"}], ",", 
RowBox[{"DateObject", "[", 
RowBox[{
RowBox[{"List", "[", 
RowBox[{"2019", ",", "1", ",", "21", ",", "10", ",", "18", ",", 
"4.0177117`8.356553747996239"}], "]"}], ",", 
"\"\<Instant\>\"", ",", "\"\<Gregorian\>\"", ",", 
RowBox[{"-", "4.`"}]}], "]"}], ",", 
RowBox[{"DateObject", "[", 
RowBox[{
RowBox[{"List", "[", 
RowBox[{"2019", ",", "1", ",", "21", ",", "10", ",", "18", ",", 
"5.0224632`8.45349173884294"}], "]"}], ",", 
"\"\<Instant\>\"", ",", "\"\<Gregorian\>\"", ",", 
RowBox[{"-", "4.`"}]}], "]"}], ",", 
RowBox[{"DateObject", "[", 
RowBox[{
RowBox[{"List", "[", 
RowBox[{"2019", ",", "1", ",", "21", ",", "10", ",", "18", ",", 
"6.0270943`8.53268295929326"}], "]"}], ",", 
"\"\<Instant\>\"", ",", "\"\<Gregorian\>\"", ",", 
RowBox[{"-", "4.`"}]}], "]"}], ",", 
RowBox[{"DateObject", "[", 
RowBox[{
RowBox[{"List", "[", 
RowBox[{"2019", ",", "1", ",", "21", ",", "10", ",", "18", ",", 
"7.0394571`8.600114136657384"}], "]"}], ",", 
"\"\<Instant\>\"", ",", "\"\<Gregorian\>\"", ",", 
RowBox[{"-", "4.`"}]}], "]"}], ",", 
RowBox[{"DateObject", "[", 
RowBox[{
RowBox[{"List", "[", 
RowBox[{"2019", ",", "1", ",", "21", ",", "10", ",", "18", ",", 
"8.0605501`8.658939649001152"}], "]"}], ",", 
"\"\<Instant\>\"", ",", "\"\<Gregorian\>\"", ",", 
RowBox[{"-", "4.`"}]}], "]"}], ",", 
RowBox[{"DateObject", "[", 
RowBox[{
RowBox[{"List", "[", 
RowBox[{"2019", ",", "1", ",", "21", ",", "10", ",", "18", ",", 
"9.0670313`8.710040079558373"}], "]"}], ",", 
"\"\<Instant\>\"", ",", "\"\<Gregorian\>\"", ",", 
RowBox[{"-", "4.`"}]}], "]"}], ",", 
RowBox[{"DateObject", "[", 
RowBox[{
RowBox[{"List", "[", 
RowBox[{"2019", ",", "1", ",", "21", ",", "10", ",", "18", ",", 
"10.0633786`8.755318773717672"}], "]"}], ",", 
"\"\<Instant\>\"", ",", "\"\<Gregorian\>\"", ",", 
RowBox[{"-", "4.`"}]}], "]"}]}], "]"}],
ShowSpecialCharacters->False,
ShowStringCharacters->True,
NumberMarks->True],
FullForm]\);
test1 = {{362, 362, 350}, {332, 342, 336}, {308, 316, 314}, {302, 310,
308}, {309, 319, 316}, {318, 329, 322}, {312, 322, 317}, {295, 
303, 302}, {298, 307, 304}, {313, 324, 318}};
ListLinePlot[Transpose@%, PlotLegends -> Automatic]

MapThread[Append, {test1, dates1}] // MatrixForm

Here there is another sample data list array with notebook attached (SampleConvertion.nb)

rawReadings = {{DateObject[{2019, 1, 20, 23, 59, 
     40.3018325`9.357899673756814}, "Instant", "Gregorian", -4.`], 51,
    52, 51, 9, 51, 52, 52, 9, 51, 51, 48, 
   13}, {DateObject[{2019, 1, 20, 23, 59, 41.31746`9.368708492650018},
     "Instant", "Gregorian", -4.`], 51, 48, 49, 9, 51, 49, 48, 9, 51, 
   48, 56, 13}, {DateObject[{2019, 1, 20, 23, 59, 
     42.3018329`9.378934059971904}, "Instant", "Gregorian", -4.`], 50,
    57, 56, 9, 51, 48, 56, 9, 51, 48, 53, 
   13}, {DateObject[{2019, 1, 20, 23, 59, 
     43.3174578`9.389237832852807}, "Instant", "Gregorian", -4.`], 51,
    49, 50, 9, 51, 50, 52, 9, 51, 49, 56, 
   13}, {DateObject[{2019, 1, 20, 23, 59, 
     44.3330828`9.39930280113551}, "Instant", "Gregorian", -4.`], 51, 
   48, 56, 9, 51, 49, 57, 9, 51, 49, 52, 
   13}, {DateObject[{2019, 1, 20, 23, 59, 
     45.3174592`9.408840418840361}, "Instant", "Gregorian", -4.`], 50,
    56, 55, 9, 50, 57, 55, 9, 50, 57, 52, 
   13}, {DateObject[{2019, 1, 20, 23, 59, 
     46.3330829`9.418466061844384}, "Instant", "Gregorian", -4.`], 50,
    56, 55, 9, 50, 57, 55, 9, 50, 57, 52, 
   13}, {DateObject[{2019, 1, 20, 23, 59, 
     47.317461`9.427596293809678}, "Instant", "Gregorian", -4.`], 51, 
   48, 50, 9, 51, 49, 52, 9, 51, 48, 57, 
   13}, {DateObject[{2019, 1, 20, 23, 59, 
     48.3330824`9.43681935101085}, "Instant", "Gregorian", -4.`], 51, 
   48, 56, 9, 51, 50, 48, 9, 51, 49, 51, 
   13}, {DateObject[{2019, 1, 20, 23, 59, 
     49.3643282`9.44598808658013}, "Instant", "Gregorian", -4.`], 50, 
   57, 54, 9, 51, 48, 54, 9, 51, 48, 49, 
   13}, {DateObject[{2019, 1, 20, 23, 59, 
     50.3643245`9.454697866233866}, "Instant", "Gregorian", -4.`], 50,
    56, 52, 9, 50, 57, 52, 9, 50, 57, 50, 
   13}, {DateObject[{2019, 1, 20, 23, 59, 
     51.3643299`9.463236476729206}, "Instant", "Gregorian", -4.`], 50,
    57, 49, 9, 51, 48, 50, 9, 50, 57, 57, 
   13}, {DateObject[{2019, 1, 20, 23, 59, 
     52.3799596`9.471740006451922}, "Instant", "Gregorian", -4.`], 51,
    48, 56, 9, 51, 50, 48, 9, 51, 49, 51, 
   13}, {DateObject[{2019, 1, 20, 23, 59, 
     53.3955781`9.480080137466796}, "Instant", "Gregorian", -4.`], 51,
    48, 53, 9, 51, 49, 54, 9, 51, 49, 48, 
   13}, {DateObject[{2019, 1, 20, 23, 59, 
     54.4112082`9.488263211388297}, "Instant", "Gregorian", -4.`], 50,
    56, 52, 9, 50, 57, 51, 9, 50, 57, 50, 
   13}, {DateObject[{2019, 1, 20, 23, 59, 
     55.3955848`9.496049990635818}, "Instant", "Gregorian", -4.`], 50,
    56, 57, 9, 50, 57, 57, 9, 50, 57, 54, 
   13}, {DateObject[{2019, 1, 20, 23, 59, 
     56.4112077`9.503940233995696}, "Instant", "Gregorian", -4.`], 51,
    48, 55, 9, 51, 49, 57, 9, 51, 49, 50, 
   13}, {DateObject[{2019, 1, 20, 23, 59, 
     57.4112076`9.511571515700364}, "Instant", "Gregorian", -4.`], 51,
    48, 54, 9, 51, 49, 55, 9, 51, 49, 49, 
   13}, {DateObject[{2019, 1, 20, 23, 59, 
     58.4268327`9.519187174946014}, "Instant", "Gregorian", -4.`], 50,
    56, 54, 9, 50, 57, 53, 9, 50, 57, 50, 
   13}, {DateObject[{2019, 1, 20, 23, 59, 
     59.4424623`9.526671619249914}, "Instant", "Gregorian", -4.`], 50,
    56, 54, 9, 50, 57, 54, 9, 50, 57, 51, 13}}
3 Replies
Posted 6 months ago
TimelinePlot[Map[<|Thread[# -> dates1]|> &, test1\[Transpose]]]

enter image description here

TimelinePlot[MapThread[<|#1 -> #2|> &, {test1, dates1}]]

enter image description here

TimelinePlot[MapThread[<|#1 -> #2|> &, {test1[[All, 1]], dates1}]]

enter image description here

Posted 6 months ago

Probably I misunderstood your intention in my 1st post. You could use TemporalData and dateListPlot

td = TemporalData[test1, {dates1}]

DateListPlot[td, GridLines -> Automatic]

enter image description here

How about this:

ds = Dataset@Association[#1 -> {##2} & @@@ rawReadings];
ds = ds[All, ToExpression@*StringSplit@*FromCharacterCode];
DateListPlot[Transpose@ds, GridLines -> Automatic, ImageSize -> Large]
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract