1
$\begingroup$

I have an issue about a label which is consisted of a variable name [Omega]BD and a numerical value associated.

Firstly, I put the BD subscript to \[Omega]. It seems to work.

Secondly, I tried to concatenate all the label with :

PlotLabel -> Subscript[\[Omega], BD] <> "=" <> ToString[\[Omega]BD]

and insert it like this in ListLinePlot :

pl = ListLinePlot[{ScaleFactorPast,ScaleFactorFuture},PlotStyle->{Blue,Blue},Frame->True,FrameLabel->{"t","a(t)"},LabelStyle->{FontSize->20,FontFamily->"Helvetica",Black,Bold},PlotRange->All, ImageSize->{600},Epilog->{Style[Text["Now",{0,1.4}],24],PointSize[.02],Point[{0, 1}]}, PlotLabel -> Subscript[\[Omega], BD] <> "=" <> ToString[\[Omega]BD]];

But the concatenation is badly done, here is the result :

bad label

This is not the right order : I would like to print : omega_BD = 4.9 and not =4.9 omega_BD

Where is the error ?

$\endgroup$
5
  • 3
    $\begingroup$ Try Row[{Subscript[\[Omega], BD], "=", \[Omega]BD}] because Subscript is not a string. $\endgroup$
    – Kuba
    Apr 14 at 10:25
  • $\begingroup$ @Kuba . Thanks a lot ! I didn't think that was so simple $\endgroup$
    – youpilat13
    Apr 14 at 10:28
  • 2
    $\begingroup$ Or use StringForm, e.g., PlotLabel -> StringForm["`` = ``", Subscript[\[Omega], BD], NumberForm[\[Omega]BD, {3, 1}]] $\endgroup$
    – Bob Hanlon
    Apr 14 at 15:14
  • $\begingroup$ @BobHanlon that's a nice one. Why not making it a fully-fledged answer? $\endgroup$
    – bmf
    Apr 14 at 15:33
  • $\begingroup$ Same question to @Kuba as a matter of fact. $\endgroup$
    – bmf
    Apr 14 at 15:33

1 Answer 1

1
$\begingroup$

You can use ToString + Subscript + StandardForm

ScaleFactorPast = RandomReal[10, 100];
ScaleFactorFuture = RandomReal[5, 100];

pl = ListLinePlot[{ScaleFactorPast, ScaleFactorFuture}, 
  PlotStyle -> {Blue, Blue}, Frame -> True, 
  FrameLabel -> {"t", "a(t)"}, 
  LabelStyle -> {FontSize -> 20, FontFamily -> "Helvetica", Black, 
    Bold}, PlotRange -> All, ImageSize -> {600}, 
  Epilog -> {Style[Text["Now", {0, 1.4}], 24], PointSize[.02], 
    Point[{0, 1}]}, 
  PlotLabel -> 
   ToString[Subscript["ω", "BD"], StandardForm] <> "=" <> 
    ToString[Subscript["4.9ω", "BD"], StandardForm]]

stringsub

$\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.