enter image description here

s = Import[
"Desktop/crack.xlsx", {"Data", 2, Range[1, 546], {1, 2, 4}}];
ListContourPlot[s, AspectRatio -> Automatic, 
ColorFunction -> "Pastel", 
Contours -> Range[0.054, 0.27, (0.27 - 0.054)/10], 
FrameLabel -> {Subscript[X, 1], Subscript[X, 2]}, 
PlotLegends -> Placed[Automatic, Right], ColorFunction -> "Pastel",
PlotLabel -> Style["MLS" Subscript[u, 2]
OverTilde[\[Eta]] "=0.048%", FontSize -> 18]]

The label of this ouput has subscript and string. But I want the label show like the below. How to modify the Plotlabel command??

I want the label like


You can try using Row to layout the text, and use Spacer command to adjust the spacing as needed

Mathematica graphics

Plot[Sin[x], {x, -Pi, Pi}, 
 PlotLabel -> 
     Row[{"MLS", Spacer[5], Subscript[u, 2], Spacer[20], 
       OverTilde[\[Eta]] , Spacer[5], "= 0.048%"}]], FontSize -> 18], 
 ImagePadding -> 20]

Or, the way I would actually do it, is use Szhorvat nice MaTex package, like this

<< MaTeX`
label = MaTeX["\\text{MLS}\\, u_2 \\qquad \\tilde\\eta = 0.048\%", 
   Magnification -> 2];
Plot[Sin[x], {x, -Pi, Pi}, PlotLabel -> label, ImagePadding -> 20]

Mathematica graphics

  • $\begingroup$ I personally prefer to just maintain labels as Strings like so: TraditionalForm["MLS \!\(\*SubscriptBox[\(u\), \(2\)]\) \ \!\(\*OverscriptBox[\(\[Eta]\), \(~\)]\)=0.048%"]. The InputForm is quite ugly, but within the notebook one can use typesetting and it becomes a one-liner along the lines of TraditionalForm["MLS u_2 ~\Eta=0.048%"] $\endgroup$ – LLlAMnYP Apr 13 '15 at 7:23

Your output is formatted wrongly, because what you gave to Style is not a series of things to style, but a multiplication of its elements. Just evaluate the arguments on their own in your notebook to see the effect:

"MLS" Subscript[u, 2] OverTilde[\[Eta]] "=0.048%"
(* "=0.048%" "MLS" \!\(\*OverscriptBox[\(\[Eta]\), \(~\)]\) Subscript[u, 2] *)

To get what you wanted, you could modify PlotLabel to

 Style[Row[{"MLS ", Subscript[u, 2], "\t", OverTilde[\[Eta]], 
  "=0.048%"}], FontSize -> 18]

enter image description here

  • $\begingroup$ fyi, I am not sure that using tab "\t" is recommend for spacing, as it might generate different space amount depending on the platform or some other system configuration. I think Spacer[n] is supposed to generate the exact space on all systems. (mac, linux, windows) $\endgroup$ – Nasser Apr 13 '15 at 8:02
  • $\begingroup$ @Nasser: Well, \t works for me. ;) But you are right, of course. $\endgroup$ – Jinxed Apr 13 '15 at 8:05

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.