Group Abstract Group Abstract

Message Boards Message Boards

0
|
19.8K Views
|
7 Replies
|
4 Total Likes
View groups...
Share
Share this post:

PlotLabel with the use of variables

Posted 11 years ago
POSTED BY: Gernot H
7 Replies
Posted 11 years ago

The new StringTemplate in V10 is a nice way to do this. Here a string is constructed for use as a plot label. The code could also be used directly as the option value in the plot function.

In[2]:= n = 10; m = 20;

In[3]:= label = 
 StringTemplate["solution with `1` x `2` grid points"][n, m]

Out[3]= "solution with 10 x 20 grid points"
POSTED BY: David Keith
Posted 4 years ago

In the first case, you are using StringTemplate incorrectly. StringTemplate["string"] produces a TemplateObject which needs to be applied to arguments. Since all you want is the string as written, that is not useful here.

Note in my example above, the StringTemplate is applied to the argruments [n,m].

POSTED BY: David Keith
POSTED BY: Tim Mayes

Okay, thanks for the clarification.

POSTED BY: Dushan Mitrovich

I'm using V 10.0.0.0 but having different, and strange results: using StringTemplate doesn't work, but

does. What am I not understanding?

POSTED BY: Dushan Mitrovich
Posted 11 years ago

Thank you both very much!

POSTED BY: Gernot H
Posted 11 years ago

Tim is quite right -- for versions earlier than 10 StringTemplate is not available, but this is works fine.

POSTED BY: David Keith
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard