Learn how to use Dash Bio for next-gen sequencing & quality control. 🧬 Access the recorded webinar.

Visual ideas to showcase multiple timelines by a category

I am trying to find a visual that will be able to showcase events by categories.
Requirements:

  • Category on the y-axis (e.g. Rain, Snow, Thunderstorm)
  • Timeline on the x-axis (e.g. Months of the year)

Example:
Every time there was rain snow or thunder, there should be a dot on the time it happened along its category section.

What I tried is using a px.bar chart with horizontal orientation but it doesn’t really work
image

Ideal graph should look like this:
image

You could start from something like:


cat_list = ["rain", "snow", "thunder"]

fig = go.Figure()
for idx, cat in enumerate(cat_list):
   fig.add_trace(
     go.Scatter(
       x=cat_timestamp_list,
       # this will add one dot per item in cat_timestamp_list
       # the dots will be along the y=idx+1 line
       y=[idx+1 for i in cat_timestamp_list],
       mode="markers"
     )
   )

# format yticks to match cat names
fig.update_layout(
    yaxis = dict(
        tickmode = 'array',
        tickvals = [idx + 1 for idx in range(cat_list)],
        ticktext = cat_list
    )
)

You would have to format the date in xaxis as well, but this is well covered in the documentation. I am not sure if there is a simpler solution with express, it could be.