MathGroup Archive 2009

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

Search the Archive

Re: AxesLabel from expression

  • To: mathgroup at smc.vnet.net
  • Subject: [mg103860] Re: AxesLabel from expression
  • From: annetts729 <annetts729 at gmail.com>
  • Date: Fri, 9 Oct 2009 07:18:28 -0400 (EDT)
  • References: <hakjrg$dd3$1@smc.vnet.net>

Hi Elmar,


> I am trying to construct an AxesLabel by using a combination of
> strings and previously defined variables. I have:
>
> mode = 1 (*this is changed ever so often*)
>
> Switch[mode,
>  0, sscript = "cert",
>  1, sscript = "auc",
>  2, sscript = "muc",
>  3, sscript = "adist",
>  4, sscript = "mdist"]
>
> plabel=Superscript["p",sscript]
> olabel=Superscript["o",sscript]
>
> I do this so I can, in this case, place the label "E(p^auc), E(o^auc)"
> on the Y-axis, where "^" of course means that the contents of the
> variable sscript is shown as a superscript of p or o.
>
> To do this in the Plot (2D), I tried different ways to define
> AxesLabel, and none of them worked:
>
> AxesLabel -> {"x", Print["E(", plabel, "),E(", olabel, ")"]}
>
> gives me what I want, but three times, row by row, like in a loop.
>
> AxesLabel -> {"x", "E(" <> ToString[plabel] <> "),E(" <> ToString
> [plabel] <>")"}
>
> removes the superscript formatting, and leads to a label: E(auc p), E
> (auc o)
>
> AxesLabel -> {"x", "E("plabel] "),E("olabel ")"}
>
> doesn't work either, it returns: )), E(E(p^auc o^auc
>
> Now I have run out of ideas on how to accomplish this. Any help is
> greatly appreciated.

You want a combination of SuperscriptBox & RowBox.

Given

sscript = Switch[mode,
  0, "cert",
  1, "auc",
  2, "muc",
  3, "adist",
  4, "mdist"]  (* where you are defining sscript once *)

and

plabel = SuperscriptBox["p", sscript]
olabel = SuperscriptBox["o", sscript]

define

ylabel = RowBox[{"E(", plabel, "),E(", olabel, ")"}]

So you can use

Plot[x^2, {x, -2, 2}, Frame -> False, Axes -> True,
 AxesLabel -> {"x", DisplayForm@ylabel}]

Dave.




  • Prev by Date: Re: Re: Usage Messages Have Become a High Tech Kludge
  • Next by Date: Re: AxesLabel from expression
  • Previous by thread: Re: AxesLabel from expression
  • Next by thread: Re: AxesLabel from expression