Message Boards Message Boards

0
|
5945 Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Use expression and string together in text command?

Hello. I have a very small problem but cannot solve it.

I would like to put a label referring to a running index in a plot (e.g., Plot) such as “z=10.0123”. If you see the attached file, I do not know how to combine the string “z=” with the expression “PaddedForm[N[z], {6, 4}]” together in command text. So far I just got the expression in.

So my problem is how to combine string and expression/number so that is can be used within the command text.

Any help would be greatly appreciated.

Thanks, Markus

Attachments:
POSTED BY: Markus Schmidt
3 Replies

Hi guys. Perfect, thank you both very much for that. Markus

POSTED BY: Markus Schmidt

While Louis` solution is perfectly good and perhaps the simplest, I would like to point out that the expression inside Text does not have to be a String, You could use a Row construction to compose and format any kind of line using String and non-String elements.

{Slider[Dynamic[z], {0, 1}], 
 Dynamic@Text[
   Style[Row[{"z:", Spacer[5], PaddedForm[N[z], {6, 4}]}], 16, Bold]]}
Posted 8 years ago

Try this:

  Text["z =" <> ToString[PaddedForm[N[z], {6, 4}]]
POSTED BY: Louis Godwin
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract