I want to create a function as follows: g[x_]:=Graphics[Text["mean=" x, {a,b}]]. That is at some coordinate point (a,b) the text, mean = x is printed. I get 3mean= when I use this function, i.e. g[3]
$\begingroup$
$\endgroup$
Try this:
g[x_] := Graphics[Text[Row[{Style["mean=", 16], Style[x, 16]}], {0, 0}]]
Have fun!
$\begingroup$
$\endgroup$
2
I would do
g[x_]:=Graphics[Text["mean="<>ToString[x], {a,b}]]
-
$\begingroup$
g[1/2]
is not going to do what you want because of the default behavior ofToString
. $\endgroup$ – Brett Champion Aug 4 '16 at 15:47 -
$\begingroup$ @BrettChampion Ok, it doesn't look nice for $x=1/2$, but it works for $x=0.5$. $\endgroup$ – corey979 Aug 4 '16 at 16:02
Row
orStringTemplate
, now you are just multiplying. $\endgroup$ – Kuba♦ Aug 4 '16 at 13:38