Using expressions in Text

I want to use Text to add some labels to a graph and was wondering if it is possible to use expressions inside Text? Here is a MWE of what I am trying.

field = 1.45;
Plot[x, {x, 1, 3}, Epilog -> {Style[Text[“H = ” field ” T”, {1.5, 2.5}], 12]}]

The problem is that this adds 1.45H=T to the plot and I want it to add H=1.45T. I have tried converting field to a string first and using that instead, but the output is the same.

=================

=================

2 Answers
2

=================

field = 1.45;

Plot[x, {x, 1, 3},
Epilog -> {Style[Text[“H = ” <> ToString@field <> ” T”, {1.5, 2.5}], 12]}]

  

 

Thank you for this quick fix!
– Michael
Oct 15 ’14 at 16:15

  

 

My pleasure, thanks for acceptance 🙂
– eldo
Oct 15 ’14 at 16:17

  

 

Or if you want TraditionalForm: Epilog -> {Style[Text[ToString@TraditionalForm[H == field*T], {1.5, 2.5}], 12]}
– Bob Hanlon
Oct 15 ’14 at 16:53

  

 

@Michael, welcome to Mathematica.SE. You can also Upvote an answer – especially the answers you Accept.
– kglr
Oct 15 ’14 at 18:10

  

 

@kguler Thanks for letting me know, I have upvoted the answer.
– Michael
Oct 15 ’14 at 18:35

You could also use

field = 1.45;
Plot[x, {x, 1, 3}, Epilog -> Inset[Style[Row[{“H = “, field, ” T”}], 12], {1.5, 2.5}]]

  

 

+1 because the Row-solution is superior in more complicated cases (Superscript etc.).
– eldo
Oct 15 ’14 at 17:53

  

 

thank you @eldo.
– kglr
Oct 15 ’14 at 18:10