1
$\begingroup$

I wanted to include a number of text-box with background color white inside a plot. The text inside the box will also have LaTex expressions as well as multiple lines.

Is there any way to include multiline text (including LaTeX symbol) inside a plot?

In addition I want to set frame and background color for the box. I am currently using Epilog and Prolog to include such text.

  ListLinePlot[
  Table[{k, 
  PDF[BinomialDistribution[50, p], k]}, {p, {0.3, 0.5, 0.8}}, {k, 0,50}], 
  Filling -> Axis, 
  FillingStyle -> Automatic,
  (**Option-1**)
  Epilog -> Text[Style[ToExpression["\\text{E}_{x} \\n text2", TeXForm, HoldForm],Bold],{30, 0.13}],
  (**Option-2**)
  Prolog -> {Inset[Framed[ "E_{x}\ntext2" , RoundingRadius -> 5,Background -> White], {45, 0.13}]}
  (**Option-3**)
(*Prolog -> {Inset[Framed[ MaTeX["E_{x}\\n text2" ] , RoundingRadius -> 5,Background ->White],{45,0.13}]}*)
   ]

Option-1 fails writing E_{x} as well as breaking line. Option-2 fails writing E_{x} but breaks line. Option-3 is the one I wanted but it fails in breaking line.

Is there any way to achieve this.

Moreover I also wanted to ask, what should one do if one has to include say more that two text boxes?

$\endgroup$
2
$\begingroup$

I just found that I can use Grid which solves all the problem.

  ListLinePlot[
  Table[{k, 
  PDF[BinomialDistribution[50, p], k]}, {p, {0.3, 0.5, 0.8}}, {k, 0,50}], 
  Filling -> Axis, 
  FillingStyle -> Automatic,

  (**Option-3**)
  Prolog -> {Inset[Framed[Grid[{ {MaTeX["E_{x}"]}, {MaTeX["text2"]} }] , 
RoundingRadius -> 5, Background -> White], {45, 0.13}]}
   ]
| improve this answer | |
$\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.