hswan
(Herbert Swan)
April 6, 2016, 3:37pm
1
I want to annotate a Plot3D or a Plot with the clause:
PlotLabel-> "c=" <> c
where c is a variable that has been assigned a numeric value. I get the error message,
StringJoin::string : String expected at position 2 in c = <> 150.
I have tried several other syntaxes, to no avail:
PlotLabel-> StringJoin["c=", c]
PlotLabel->"c=" <> StringForm[c]
PlotLabel-> StringJoin["c=", InputForm[c]]
Does anyone know know to do this in Mathematica?
mthiel
(Marco Thiel)
April 6, 2016, 3:42pm
2
What about this?
c = 0.3;
Plot[Sin[c x], {x, 0, 20}, PlotLabel -> "C=" <> ToString[c]]
Cheers,
M.
Vitaliyk
(Vitaliy Kaurov)
April 6, 2016, 3:51pm
4
Marco is precise, this is the way. A small note for the future. PlotLabel formats as TraditionalForm so if you need advanced blend of strings and typesetting you could use Row:
Plot[Sin[3 x], {x, 0, 20}, PlotLabel -> Row[{"C=", Integrate[f[x] BesselJ[x, Pi], {x, a, b}]}]]