MathGroup Archive 2008

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

Search the Archive

RE: Constructing a Label

  • To: mathgroup at smc.vnet.net
  • Subject: [mg93397] RE: [mg93336] Constructing a Label
  • From: "Jose Luis Gomez" <jose.luis.gomez at itesm.mx>
  • Date: Thu, 6 Nov 2008 04:05:24 -0500 (EST)
  • References: <200811041117.GAA29178@smc.vnet.net>

Dear Nikolaus

I think is NOT such a good idea to transform to a String in order to make a
Label for a Plot.

In my opinion it can be better to use the HoldForm[] and TraditionalForm[]
commands (actually, TraditionalForm[] is not needed in PlotLabel IN
MATHEMATICA 6).

(*FIRST EXAMPLE: COPY-PASTE AND EVALUATE IN MATHEMATICA 6*)
f[x_] := Sin[3 x + Cos[2 x]];
Plot[f[x], {x, 0, 2}, PlotLabel -> HoldForm[f[x]] == f[x]]

(*SECOND EXAMPLE: COPY-PASTE AND EVALUATE IN MATHEMATICA 6*)
f[x_] :=Exp[x]/x;
Plot[f[x], {x, 0, 2}, PlotLabel -> HoldForm[f[x]] == f[x]]

(*THIRD EXAMPLE: COPY-PASTE AND EVALUATE IN MATHEMATICA 6*)
f[x_] :=Exp[x]/x;
TraditionalForm[HoldForm[f[x]]==f[x]]


Best regards
Jose
Mexico

-----Mensaje original-----
De: Nikolaus Rath [mailto:Nikolaus at rath.org] 
Enviado el: Martes, 04 de Noviembre de 2008 05:18
Para: mathgroup at smc.vnet.net
Asunto: [mg93336] Constructing a Label

Hello,

I want to automatically construct labels of the form
"A = <value of A>" for a number of plots.

However, I cannot quite figure out how to generate the above
expression. My first idea was to construct it as a string

label = "A = " <> ToString[A]

but this looks horribly if A is more complicated than just a single
literal. So I assume that I have to "concatenate" the Mathematica
expressions "A = " and A (rather than the stringified A). But how do I
do that? My feeble attempts with

label = RowBox["A", "=", A]

are displayed exactly the way I entered them, i.e. with the literal
"RowBox" printed out.


Thanks in advance,

   -Nikolaus

--
 =C2=BBIt is not worth an intelligent man's time to be in the majority.
  By definition, there are already enough people to do that.=C2=AB
                                                         -J.H. Hardy

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C




  • Prev by Date: Re: Data fitting from coupled differential equations
  • Next by Date: Bras and Kets
  • Previous by thread: Constructing a Label
  • Next by thread: Re: Constructing a Label