2
$\begingroup$

Part-related to this question and part-related to this one, I would like to make use of the new features of TimelinePlot in 10.3, but would like to incorporate some sort of automated text-wrapping, rather than be forced to do it manually. For example:

TimelinePlot[{Labeled[ Interval[{DateObject[{2016, 2, 5, 12, 30}], 
DateObject[{2016, 2, 5, 14, 30}]}], "Lorem ipsum dolor sit amet,
eu mollis integre adipisci usu.
Vim an debitis corpora. Quis 
paulo definitiones te nec,
his ceteros probatus ex.
Has nostrum senserit elaboraret 
ut. Sit eu solum maluisset.
Vel soleat option ea, vim ad 
justo liber viderer. Causae 
definitionem sea ei. Ornatus 
nominavi scaevola nam eu. Eum 
utinam menandri an, pri in
quod persecuti, ne vim dicunt 
audire placerat."]}]

gives (approximately) the desired output, but label box-sze has been adjusted manually. Ultimately, my timeline will be quite detailed and multileveled, so the additional issue of left/right (or other custom) placement of the label itself would be desirable, but is not essential.

What is the best way to create a heavily annotated timeline, using the easy-to-use TimelinePlot in 10.3?

$\endgroup$
  • 2
    $\begingroup$ Currently TimelinePlot is only useful for manually designed posters. Need a layout engine. I mentioned this to SW at the last conference. By analogy, think of label placement in GIS (eg Google Maps) and more generally graph layout. People spend entire careers working on those. $\endgroup$ – alancalvitti Feb 5 '16 at 15:09
0
$\begingroup$

Using @Mr.Wizard's answer to this question works quite well:

textchunk[text_String, len_Integer, size_Integer] := 
Text[Style[Module[{aa, bb},
  aa = Accumulate[Join[{0}, Length@# & /@ Module[{t = 0}, 
  Split[StringLength@# & /@ StringSplit[text, " "], 
  (t += #) <= len || (t = 0) &]]]]; 
    bb = {#[[1]], #[[2]]} & /@ Transpose@{Most@aa, Rest@aa}; 
    StringJoin@Riffle[StringJoin@Riffle[Drop[Take[StringSplit[text, " "], 
    #[[2]]], #[[1]]], " "] & /@ bb, "\n"]], size]]

txt01 = "Lorem ipsum dolor sit amet, eu mollis integre adipisci usu. Vim an debitis corpora. Quis paulo definitiones te nec, his ceteros probatus ex. Has nostrum senserit elaboraret ut. Sit eu solum maluisset. Vel soleat option ea, vim ad justo liber viderer. Causae definitionem sea ei. Ornatus nominavi scaevola nam eu. Eum utinam menandri an, pri in quod persecuti, ne vim dicunt audire placerat.";

TimelinePlot[{
Interval[{"12:30, Feb 5, 2016", "14:30, Feb 5, 2016"}] -> textchunk[txt01, 20, 12],
Interval[{"15:00, Feb 5, 2016", "15:10, Feb 5, 2016"}] -> textchunk[txt01, 50, 12],
Interval[{"15:30, Feb 5, 2016", "15:40, Feb 5, 2016"}] -> textchunk[txt01, 50, 12]},
PlotRange -> {"12:00, Feb 5, 2016", "17:10, Feb 5, 2016"}, 
ImageSize -> 1000, AspectRatio -> .4]

where ImageSize and AspectRatio have to be manually adjusted:

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.