4
$\begingroup$

I want to render a TimelinePlot of events. But the events are so dense that they may overlap.

For exmaple something like:

events = DateObject[{2024, 1, 1, 0, 0, #}]& /@ RandomReal[{0,60}, 100]; 

Now when I plot it, the problem is that the events with overlapping marker block each other, so visually, the information about multiple events stacked close to each other is lost

TimelinePlot[events] 

Plot1

I tried adding opacity but that doesn't work either. I would expect the markers to overlap with higher opacity on the overlap, but that's not the case.

TimelinePlot[events, PlotStyle->Opacity[0.5]] 

Plot2

Another thing I tried was to add a custom marker with opacity, for example like this:

TimelinePlot[events, PlotMarkers->Graphics[{Blue, Opacity[0.5], Disk[]}]] 

now the output is closer to what I'd expect but the rendering is somewhat ugly

Plot3

This is almost there, but I don't like how the individual marker is rendered. When we look closer it looks like this:

marker

being darker on the inside and lighter on the outside. This is probably due to some antialiasing? I would be OK with this on the boundary, but I don't like it in the center. This becomes a lot more apparent when I want to set the opacity lower. The default PlotMarkers don't suffer this issue.

Any ideas how to improve this?

$\endgroup$
5
  • 1
    $\begingroup$ Just an idea TimelinePlot[events, PlotMarkers -> Graphics[{Blue, Text["|"]}]] $\endgroup$ Commented Dec 4, 2024 at 9:53
  • $\begingroup$ Cool idea, also coul use Line[{{0,1},{0,0}}] with a similar results but there is still some unpleasant fuzziness from a close look. Is it somehow possible to force the line to be exactly one pixel wide (with no antialiasing attempts)? AbsoluteThickness[1] does not seem to cut it in the Graphics. $\endgroup$ Commented Dec 4, 2024 at 12:18
  • 1
    $\begingroup$ What do you want to do with the plot, I mean, what export format you have in mind? Is it for printing or viewing? It is relative to talk about pixels in vector formats. But if you aim at raster graphics, you have to specify the desired resolution. In current form your question is too vague. $\endgroup$ Commented Dec 4, 2024 at 12:56
  • $\begingroup$ TimelinePlot[events , PlotLayout -> "Stacked" , PlotMarkers :> {"\[EmptyCircle]", 12} , PlotStyle -> Opacity[1] , Filling -> Axis , AspectRatio -> 1/5 , ImageSize -> 1200 ] ? $\endgroup$ Commented Dec 4, 2024 at 14:05
  • $\begingroup$ I ultimately want to export it as a PNG $\endgroup$ Commented Dec 4, 2024 at 14:19

2 Answers 2

2
$\begingroup$

I think that "jittering" might be what you're after (as I assume that it is about the "display" of the data rather than an "analysis" of the data).

events = DateObject[{2024, 1, 1, 0, 0, #}] & /@ RandomReal[{0, 60}, 100]; y = RandomReal[{0, 1}, Length[events]]; DateListPlot[Transpose[{events, y}], Joined -> False, AspectRatio -> 1/8, Frame -> {{False, False}, {True, False}}, FrameTicks -> {Automatic, None}, PlotRangePadding -> 1] 

Jittered data

You might need to play around with values of AspectRatio and/or PlotRangePadding to get exactly what you want.

$\endgroup$
1
$\begingroup$

Your question is about many points in a TimelinePlot. I had a similar question about many intervals in TimelinePlot so I tried the same solution to see if it would work and it does:

TimelinePlot[events] /. GrayLevel[1] -> Nothing 

enter image description here

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.