1

Lets say you have python dict that describes the "events" that occurred at different times during a certain activity.

activity = {
   "start_time":"2018-09-05 06:30:53.242",
   "end_time":"2018-09-09 09:30:53.242",
   "eventType1":[
      {
         "event_pos":123,
         "event_time":"2018-09-05 06:50:53.242",
         "message":"blah"
      },
      {
         "event_pos":125,
         "event_time":"2018-09-05 07:50:53.242",
         "message":"type1 event blah"
      }
   ],
   "eventType2":[
      {
         "event_pos":18,
         "event_time":"2018-09-05 06:40:58.242",
         "message":"type2 event1"
      },
      {
         "event_pos":700,
         "event_time":"2018-09-05 08:59:58.242",
         "message":"type2 event2"
      }
   ]
}

My intention is to visualize this in a graph and or table. Initially i Converted this to a table with the first two rows being start and end, and the event instances, messages and times as subsequent rows.

The problem is that events can repeat, and because they can repeat messages get duplicated (on a millisecond frequency). Therefore the subsequent event lists can grow very quickly and have repeated messages only milliseconds apart. This makes for an ugly, hard to read table.

What I have done in the mean time is to get the unique instances of an event, by message, and display the number of occurrences for each event message. This cleans things up, but a visual of where these events occurred would also be useful.

My Goal:

To create a timeline of events based on categories.

  • Have a y axis as [eventType1, eventType2, eventType3 etc...]
  • Have x axis as date times for the duration of the activity
  • Have ticks horizontally that attribute to each event (possibly placing the message across the tick, horizontally, although i feel this will be a mess as well)

What I have Tried:

following this post --> Matplotlib timelines

But I am having troubles getting categories (eventTypes) as a y axis and python date times as x axis. I convert to matplotlib date time strings but issues such as the following come up often:

ValueError: x and y must have same first dimension, but have shapes (20,) and (2,)

Questions:

  1. How to plot categories against specific event times in matplotlib when events have metadata( like messages and event positions )
  2. Is there a better way to visualize this type of data? I am open to suggestions.
aramnhammer
  • 135
  • 2
  • 9

0 Answers0