4
$\begingroup$

When I export the below TimelinePlot to an .eps figure (to include in a document), the boundaries of the rounded boxes surrounding the label text do not appear. (They appear in the below .bmp file, however.) Thus I would like to increase their thickness, in hopes they'll appear in the .eps file.

I can change the indicator lines (through PlotStyle -> {{AbsoluteThickness[4], Orange}, {AbsoluteThickness[4], Green}}) but not the boundaries of the rounded boxes themselves.

How do I increase the thickness or otherwise change the style of the surrounding boxes?

Using Framed around the text gives an inappropriate box within the indicator box.

TimelinePlot[
 {
  {Labeled[Interval[{{2017, 1, 1}, {2017, 1, 15}}], "Begin"],
   Labeled[Interval[{{2018, 1, 1}, {2019, 1, 1}}], "Middle"]},

  {Labeled[{2017, 1, 1}, "Project begins"],
   Labeled[{2017, 4, 1}, "xxx"],
   Labeled[{2017, 7, 1}, "yyy"],
   Labeled[{2017, 10, 1}, "zzz"],
   Labeled[{2018, 1, 1}, "Midterm review"],
   Labeled[{2018, 4, 1}, "www"],
   Labeled[{2018, 7, 1}, "rrr"],
   Labeled[{2018, 10, 1}, "sss"],
   Labeled[{2019, 1, 1}, "Overall\n project\n review"]}

  },
 PlotRange -> {{{2017, 1, 1}, {2019, 1, 1}}},
 GridLines -> {DateRange["2017", "2019", Quantity[3, "Months"]], None},
 GridLinesStyle -> {{Dashed, Gray}, None},
 PlotStyle -> {{AbsoluteThickness[4], Orange}, {AbsoluteThickness[4], 
    Green}},
 Spacings -> {10, 10},
 FrameStyle -> {18, {18, Italic}},
 FillingStyle -> Opacity[0.3],
 Method -> {"GridLinesInFront" -> True},
 PlotLegends -> Placed[{"Tasks", "Payable milestones"}, Bottom],
 ImageSize -> 700,
 AspectRatio -> .2,
 Background -> LightYellow]

enter image description here

$\endgroup$
4
$\begingroup$

Inspection of the InputForm of the generated plot reveals that a function is used to generate the labeling rectangles:

DisplayFunction :> (FormBox[
    FrameBox[
     StyleBox[
      StyleBox[
       PaneBox[#1, Alignment -> Left, AppearanceElements -> None, 
        ImageSizeAction -> "ResizeToFit"], LineIndent -> 0, 
       StripOnInput -> False], {FontFamily -> "Arial"}, 
      StripOnInput -> False], Background -> GrayLevel[1], 
     RoundingRadius -> 5, ContentPadding -> True, 
     FrameMargins -> {{5, 5}, {5, 5}}, FrameStyle -> Thickness[0.01], 
     StripOnInput -> False], TraditionalForm] & )

The interesting bit is FrameStyle -> Thickness[0.01]. This doesn't appear anywhere else in the generated code, so it's a prime candidate for replacement.

As it happens, a Thickness of 0.01 is far too low in this context: compare e.g. the following:

Labeled["sample", "label", Frame -> True, FrameStyle -> Thickness[#]] & /@ {0.01, 0.1, 1, 3, 5}

examples

The first three cases are essentially the same. The front end will display the thinnest line it can display probably, but exporting won't work.

Coming back to your plot, you can then change the thickness of those frames after the fact using a replacement rule:

yourplot /. HoldPattern[FrameStyle -> Thickness[0.01]] -> (FrameStyle -> Thickness[5])

exaggerated

This was a bit exaggerated for effect. You will want to scale the new thickness down to your liking. I exported this both to PDF and EPS with success.

$\endgroup$
  • $\begingroup$ Thanks! a non-obvious solution. $\endgroup$ – David G. Stork May 26 '16 at 4:59
  • $\begingroup$ @MarcoB nice 'looking under the hood' +1:) $\endgroup$ – ubpdqn May 26 '16 at 8:21

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.