2
$\begingroup$

How to put the label on the other side of the interval.

For instance in the following code, how to push the label End on the other hand.

displayLaTeX[string_] := 
  DisplayForm[
   ToBoxes@TraditionalForm@ToExpression[string, TeXForm, HoldForm]];
TimelinePlot[{Interval[{DateObject[{2015, 6, 1}], 
     DateObject[{2016, 2, 29}]}] -> "End "}, AxesOrigin -> Center, PlotTheme -> "Classic"]

enter image description here

Courtesy of this answer given by Jens.

$\endgroup$
2
  • $\begingroup$ I can not make out from your question how you want to change what you have now. Could you please show the result you want? $\endgroup$
    – m_goldberg
    Commented Feb 28, 2016 at 14:57
  • $\begingroup$ The label 'End' is at June in above. I want to put that label at March. i-e there are two extremes of the interval, then how to move the label from one extreme to another extreme? $\endgroup$
    – kaka
    Commented Feb 28, 2016 at 20:06

1 Answer 1

3
$\begingroup$

It is simply a matter of getting the date objects into a sensible grouping, getting the labels attached to the right date objects, and removing the option AxesOrigin -> Center.

TimelinePlot[
  {{Interval[{DateObject[{2015, 1, 15}], DateObject[{2015, 9, 9}]}]},
   {DateObject[{2015, 6, 1}] -> 
      Row[{"Start ", displayLaTeX["\\sum_{i=0}^{10} f(x_i)"]}],
    Interval[{DateObject[{2015, 6, 1}], DateObject[{2016, 2, 29}]}],
    DateObject[{2016, 3, 6}] -> "End "}, 
   {Interval[{DateObject[{2016, 7, 27}], DateObject[{2016, 8, 6}]}]}},
  PlotTheme -> "Classic"]

plot

As far as I can determine, bubble labels can only be placed on point events or at the start of time lines. Therefore, I think what you asking for can not done. Perhaps someone more knowledgable will prove me wrong.

Therefore, you can have this:

TimelinePlot[
  {{Interval[{DateObject[{2015, 1, 15}], DateObject[{2015, 9, 9}]}]}, 
   {Labeled[
      Interval[{DateObject[{2015, 6, 1}], DateObject[{2016, 2, 29}]}], 
      Row[{"Start ", displayLaTeX["\\sum_{i=0}^{10} f(x_i)"]}]],
    Labeled[DateObject[{2016, 3, 6}], "End"]}, 
   {Interval[{DateObject[{2016, 7, 27}], DateObject[{2016, 8, 6}]}]}}, 
  PlotTheme -> "Classic"]

plot2

You can also have a time line with standard labels as follows:

TimelinePlot[
  {{Interval[{DateObject[{2015, 1, 15}], DateObject[{2015, 9, 9}]}]}, 
   {Labeled[
      Interval[{DateObject[{2015, 6, 1}], DateObject[{2016, 2, 29}]}], 
      {Row[{"Start ", displayLaTeX["\\sum_{i=0}^{10} f(x_i)"]}], "End"}, 
      {Before, After}]}, 
   {Interval[{DateObject[{2016, 7, 27}], DateObject[{2016, 8, 6}]}]}}, 
  PlotTheme -> "Classic"]

plot3

$\endgroup$
3
  • $\begingroup$ I have edited the question. There was ambiguity. $\endgroup$
    – kaka
    Commented Feb 29, 2016 at 2:09
  • $\begingroup$ The points are disconnected from the actual interval, so it is not exactly I need. $\endgroup$
    – kaka
    Commented Feb 29, 2016 at 2:25
  • $\begingroup$ The last option you provided might help me. $\endgroup$
    – kaka
    Commented Feb 29, 2016 at 4:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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