Re: Re: format Text in graphics
- To: mathgroup at smc.vnet.net
- Subject: [mg42285] Re: [mg42273] Re: [mg42251] format Text in graphics
- From: Gianluca Gorni <gorni at dimi.uniud.it>
- Date: Fri, 27 Jun 2003 06:31:15 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
If you want "sin x" instead of "sin(x)", you can do it this way: Format[myEqual[x_, y_], TraditionalForm] := DisplayForm[RowBox[{x, "=", y}]]; Plot[Sin[x], {x, 0, 2Pi}, Epilog -> {Text[ TraditionalForm[myEqual[y, RowBox[{sin, x}]]], {Pi, 1/2}]}]; It seems that to do this sort of things you need to become expert in Box structures! If you set $FormatType = TraditionalForm you no longer need to write TraditionalForm every time you use Text[]. This seems to affect text only within graphics, and tick marks too. Gianluca Gorni > From: Murray Eisenberg <murray at math.umass.edu> To: mathgroup at smc.vnet.net > Organization: Mathematics & Statistics, Univ. of Mass./Amherst > Reply-To: murray at math.umass.edu > Date: Thu, 26 Jun 2003 05:36:26 -0400 (EDT) > To: mathgroup at smc.vnet.net > Subject: [mg42285] [mg42273] Re: [mg42251] format Text in graphics > > NO -- that does not work properly, on several grounds: > > (1) The typeset formula in the graphic is NOT set in conventional > mathematical style, since it seems to be using an italic monospaced font > (Courier?) rather than times; > > (2) I require a literal f(x) typset with the f and x in italic roman and > the parentheses upright, and not the value of f[x]; > > (3) The y and f within the Epilog are not insulated from values that > might be assigned to them previously, so for example > > f[x_] := Sin[x] > y = 3; > Plot[x^2, {x, -1, 1}, Epilog -> {Text[SequenceForm[TraditionalForm[ > y], " = ", TraditionalForm[f[x]]], {0.5, 0.5}]}]; > > produces on the graph the text > > 3 = sin(x) > > which is hardly what's needed. Wrapping each of y and the f[x] with > HoldForm does fix (2) and (3), but not (1). > > I cannot believe this is so hard to do! > > > > David Park wrote: >> Murray, >> >> Doesn't SequenceForm work here? >> >> f[x_] := x^2 >> >> Plot[f[x], {x, -1, 1}, >> Epilog -> {Text[ >> SequenceForm[TraditionalForm[y], " = ", >> TraditionalForm[f[x]]], {0.5, 0.5}]}]; >> >> David Park >> djmp at earthlink.net >> http://home.earthlink.net/~djmp/ >> >> From: Murray Eisenberg [mailto:murray at math.umass.edu] To: mathgroup at smc.vnet.net > To: mathgroup at smc.vnet.net >> >> What value of Epilog in a Plot expression will properly format >> >> y = f(x) >> >> in conventional mathematical style? That is, the y, f, and x should be >> italicized but the = and parentheses should not. >> >> Some things that do NOT work: >> >> Epilog -> Text[TraditionalForm[y = f(x)], {0.5, 0.5}] >> >> (* that just sets y to be f(x) and then displays f(x) *) >> >> textForm[txt_] := StyleForm[txt, FontFamily -> Times] >> mathForm[txt_] := StyleForm[txt, FontFamily -> Times, FontSlant -> Italic] >> >> Epilog -> Text[mathForm["y "], textForm["="], mathForm[" f(x)"], {0.5 0.5}] >> >> (* SOMETHING like the preceding should work, but I don't see how to >> combine the three StyleForm results *) >> > > -- > Reply to "REPLY TO" address and NOT to the "FROM" address!! > Otherwise I will never see your reply!!!!!!!!!!!!!!!!!!!!!! > > Murray Eisenberg murray at math.umass.edu > Mathematics & Statistics Dept. > Lederle Graduate Research Tower phone 413 549-1020 (H) > University of Massachusetts 413 545-2859 (W) > 710 North Pleasant Street fax 413 545-1801 > Amherst, MA 01003-9305 >