       Re: Constructing a Label

• To: mathgroup at smc.vnet.net
• Subject: [mg93413] Re: Constructing a Label
• From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
• Date: Fri, 7 Nov 2008 05:59:20 -0500 (EST)
• Organization: Uni Leipzig
• References: <gepb15\$sfr\$1@smc.vnet.net> <gerqmv\$rit\$1@smc.vnet.net> <geuc0r\$fe8\$1@smc.vnet.net>

```Hi,

look at

Plot[Sin[# x], {x, 0, Pi},
PlotLabel ->
"A = \!\(\*FractionBox[\"" <> ToString[Numerator[#]] <> "\",\"" <>
ToString[Denominator[#]] <> "\"]\)"] & /@ {1/4, 1/3, 1/2, 2/3}

Regards
Jens

Nikolaus Rath wrote:
> Jens-Peer Kuska <kuska at informatik.uni-leipzig.de> writes:
>>> 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
>> Hi,
>>
>> since
>>
>> Plot[Sin[# x], {x, 0, Pi},
>>     PlotLabel ->
>>      "\!\(\*SubscriptBox[\"A\", \"1\"]\)[\!\(\*SuperscriptBox[\"x\", \
>> \"2\"]\),\[Sum] \!\(\*SubscriptBox[\"x\", \"i\"]\)]=" <>
>>       ToString[#]] & /@ {1, 2, 3}
>>
>> work perfect, can you explain what
>> "looks horribly if A is more complicated"
>> may mean ?
>
> Look at the output of e.g. "A = " <> ToString[1/2]. It renders as:
>
> A = 1
> -----
>   2
>
>
> The suggested solutions with Row[] and StringForm[] work perfectly
> though, thanks a lot to the posters.
>
>
> Best,
>
>    -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: ways to save the output from a notebook
• Next by Date: Re: From reactions to differential equations
• Previous by thread: Re: Constructing a Label
• Next by thread: Re: Re: Constructing a Label