MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: PlotLabel with assigned variables *and* on several lines

  • To: mathgroup at smc.vnet.net
  • Subject: [mg49049] Re: PlotLabel with assigned variables *and* on several lines
  • From: Bill Rowe <readnewsciv at earthlink.net>
  • Date: Tue, 29 Jun 2004 04:50:36 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

On 6/28/04 at 4:13 AM, alain at geophysik.uni-muenchen.de (Alain
Cochard) wrote:

>By searching the archives I found how to write variables with
>specific values.  E.g., the following examples work:

>In[253]:= a=1;b=2; Plot[ Sin[x],{x,0,1},PlotLabel->"a=" <>
>ToString[a] "b=" <> ToString[b] ]

>In[254]:= a=1;b=2; Plot[ Sin[x],{x,0,1},PlotLabel->SequenceForm
>["a=",a,"b=",b]]

>Then I also found how to write a label on several lines:

>In[256]:= Plot[ Sin[x],{x,0,1},PlotLabel->"2 \n lines"]

>But I did not find or succeed in combining the two.  E.g., those do
>not work:

>In[255]:= a=1;b=2; Plot[ Sin[x],{x,0,1},PlotLabel->"a=" <>
>ToString[a] \n "b=" <> ToString[b] ]

Here, since the \n is not in quotes, Mathematica does not see it as a string. Rewrite this as:

Plot[ Sin[x],{x,0,1},PlotLabel->"a="<>ToString[a] "\nb="<>ToString[b] ]

and you will get the result you want. But if it was me, I would be explicit in my desire for PlotLabel to see the argument as a single string and write it as

Plot[ Sin[x],{x,0,1},PlotLabel->"a="<>ToString[a]<>"\nb="<>ToString[b] ]


>In[264]:= a=1;b=2; Plot[
>Sin[x],{x,0,1},PlotLabel->SequenceForm["a=",a,\n" b=",b]]

There is the same problem here. The \n needs to be in quotes, i.e.,

Plot[Sin[x],{x,0,1},PlotLabel->SequenceForm["a=",a,"\n",b=",b]]

will do what you want.
--
To reply via email subtract one hundred and four


  • Prev by Date: Re: Printing "The Mathematica Book"
  • Next by Date: Re: Pattern Matching
  • Previous by thread: RE: PlotLabel with assigned variables *and* on several lines
  • Next by thread: Re: PlotLabel with assigned variables *and* on several lines