5
$\begingroup$

This is an example of a TimelinePlot with 100 intervals:

TimelinePlot[Table[Interval[{0, 1}], {30}], PerformanceGoal -> "Speed"] 

timeline with 100 lines

If we increase the number of intervals to 300, they seem to dissapper:

TimelinePlot[Table[Interval[{0, 1}], {300}], PerformanceGoal -> "Speed"] 

timeline with 300 lines becomes invisible

I know that the lines are still there, but they seem to have a white border or something else that makes them virtually disappear when they are very close to each other. Is there any way to make these lines visible?

Note: I know that in this simplified example, if all lines are shown, we will get a solid rectangle. In my real application, I have hundreds of intervals chronologically close but not exactly on top of each other.

UDTADE: It was suggested to change the AspectRatio but this is not a solution as it just increases the number of intervals needed to blank out the output. I am looking for a way to eliminate the blanking altogether. Ohh wait... While writing this I realized that the blanking is caused by GrayLevel[1] elements and apparently it happens to be possible to remove them without undesired collateral damage:

TimelinePlot[Table[Interval[{0, 1}], {30}], PerformanceGoal -> "Speed"] /. GrayLevel[1] -> Nothing 

enter image description here

TimelinePlot[Table[Interval[{0, 1}], {300}], PerformanceGoal -> "Speed"] /. GrayLevel[1] -> Nothing 

enter image description here

While this solved my problem, it is a hackish workaround as I think that the appearance should be changed with options. I'll leave the question open in case someone knows how to do this with options or at least a less fragile way of achieving this.

$\endgroup$
1
  • 1
    $\begingroup$ Set the AspectRatio to 1 or higher $\endgroup$ Commented Mar 31, 2023 at 4:24

1 Answer 1

2
$\begingroup$

I was not intending to answer my own question, but I found a way to solve this good enough to be shared.

The blanking element can be seen easily using the ReadableForm resource function with a minimal case:

ResourceFunction["ReadableForm"][ TimelinePlot[Interval[{0, 1}], PerformanceGoal -> "Speed"]] 

In the output below I added a comment indicating the problematic white line that needs to be removed:

Graphics[ { { Opacity[ 0 ], AbsolutePointSize[ 0 ], Point @ { { 0., 1 }, { 1., 3 / 2 } }, Point @ { { 0., -1 / 2 }, { 1., 0 } } }, { }, { { Opacity[ 0 ], PointSize[ 0 ], Point @ { { 0., 1 }, { 1., 1 } } }, { { Directive[ AbsolutePointSize[ 7 ], RGBColor[ 0.368417, 0.506779, 0.709798 ], AbsoluteThickness[ 1.6 ], Opacity[ 1 ] ], { { Directive @ Opacity[ 0.2 ], { Directive @ Opacity[ 0.2 ], EdgeForm[ ], Rectangle[ { 0., 1 }, { 1., 1 } ] } }, { { }, { { { { }, { { { (****** This is the problematic white line ******) GrayLevel[ 1 ], AbsoluteThickness[ 2 ], Line @ { { Offset[ { 0, -1 }, { 0., 1 } ], Offset[ { 0, -1 }, { 1., 1 } ] }, { Offset[ { 0, 1 }, { 0., 1 } ], Offset[ { 0, 1 }, { 1., 1 } ] } } }, { AbsolutePointSize[ 10 ], GrayLevel[ 1 ], Point @ { { 0., 1 }, { 1., 1 } } }, Point @ { { 0., 1 }, { 1., 1 } }, Line @ { { 0., 1 }, { 1., 1 } } } }, { }, { { AbsolutePointSize[ 4 ], GrayLevel[ 1 ], Point @ { { 0., 1 }, { 1., 1 } } } } }, { } }, { { }, { } } } } } } }, { { { { } }, { } } } }, { }, { } }, PlotRange -> { { All, All }, { 0, All } }, ImagePadding -> All, PlotRangePadding -> { { Scaled[ 0.08 ], Scaled[ 0.08 ] }, { None, Scaled[ 0.05 ] } }, AspectRatio -> 1 / 20, Axes -> { False, False }, Frame -> { { None, None }, { True, None } }, FrameTicks -> { { None, None }, { Function[ Charting`getDateTicks[ Automatic, { Automatic }, (DateList /@ { ##1 } &)[ ##1 ], None, 7, { { 0.01, 0 }, { 0.005, 0 } }, Automatic ] ], Automatic } }, Ticks -> { { { -1., "23:59:59", { 0.006666666666666666, 0 } }, { 0., "00:00:00", { 0.006666666666666666, 0 } }, { 1., "00:00:01", { 0.006666666666666666, 0 } }, { 2., "00:00:02", { 0.006666666666666666, 0 } }, { -1., Spacer @ { 0, 0 }, { 0.006666666666666666, 0 } }, { 0., Spacer @ { 0, 0 }, { 0.006666666666666666, 0 } }, { 1., Spacer @ { 0, 0 }, { 0.006666666666666666, 0 } } }, None }, AxesOrigin -> { 0, 0 }, { Axes -> Automatic, GridLines -> { None, None }, ImageSize -> { 600, Automatic } } ] 

In order to remove the while lines we use this pattern: {GrayLevel[1], AbsoluteThickness[2], Line[_]}. Also, for large number of intervals, the dots in the boundary of each interval are unnecessary and even problematic as they too have white inside. So this produces clean a output:

TimelinePlot[Table[Interval[{0, 1}], {300}], PerformanceGoal -> "Speed"] /. { {GrayLevel[1], AbsoluteThickness[2], Line[_]} -> Nothing, Point[_] -> Nothing} 

corrected timeline with 300 intervals

Let's conclude with a more realistic example. Without the fix the bars below are very hard to see:

data = Table[NestList[# + Quantity[RandomInteger[{0, 2}], "Hours"] &, DateInterval[Today], 300], {5}]; TimelinePlot[data, PlotStyle -> AbsoluteThickness[1], PerformanceGoal -> "Speed"] 

enter image description here

The presented solution greatly improves the visibility of the bars:

TimelinePlot[data, PerformanceGoal -> "Speed", PlotStyle -> AbsoluteThickness[1]] /. {{GrayLevel[ 1 ], AbsoluteThickness[ 2 ], Line[_]} -> Nothing, Point[_] -> 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.