0
$\begingroup$

I'm trying to graph a text in a couple of plots I have. I want to be able to edit the text depending on the values I choose (rho0, zp, zm, temp, ion, and perm) and show them at some point in my plot (X,Y) . I'm using the following code in order to achieve it

rho[rho0_, zp_, zm_, temp_, ion_, perm_, X_, Y_] := 
 Graphics[Text[
   Style[{rho0 " M, " zp ":" zm ", " temp " K, " ion " \[Angstrom], " perm}, 
    Black, Italic, 16], {X, Y}]]

However when I input

rho[0.001, 1, 1, 278.15, 4.25, 78.5, 1, 1]

Mathematica returns

{92.7978,:K,M,\[Angstrom],}

But what I expect to get is the text

0.001 M, 1:1, 278.15 K, 4.25 \[Angstrom], 78.5

What do I need to change in order to get this output? Thanks on advance

$\endgroup$
  • 1
    $\begingroup$ rho[rho0_, zp_, zm_, temp_, ion_, perm_, X_, Y_] := Graphics[Text[ Style[ToString[rho0] <> " M, " <> ToString[zp] <> ":" <> ToString[zm] <> ", " ToString[temp] <> " K, " <> ToString[ion] <> " \[Angstrom], " <> ToString[perm], Black, Italic, 16], {X, Y}]] $\endgroup$ – march May 14 at 3:05
  • 2
    $\begingroup$ Don’t multiply strings and symbols. Use Row to put them in order $\endgroup$ – Carl Woll May 14 at 3:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.