Re: Re: format Text in graphics
- To: mathgroup at smc.vnet.net
- Subject: [mg42322] Re: [mg42299] Re: format Text in graphics
- From: Paul Abbott <paul at physics.uwa.edu.au>
- Date: Tue, 1 Jul 2003 08:45:33 -0400 (EDT)
- References: <200306250950.FAA04042@smc.vnet.net> <bdefg7$dko$1@smc.vnet.net> <200306271031.GAA24612@smc.vnet.net> <3EFC5CEF.2090301@math.umass.edu>
- Sender: owner-wri-mathgroup at wolfram.com
On 27/6/03, Murray Eisenberg wrote: >Yes, thank you! (Thanks also to Carl Woll and Gianluca Gorni, who >privately sent the same solution.) > >But this solution, using > >TraditionalForm[HoldForm[y = f[x]]] > >within the Text function, is not foolproof (as Gianluca Gorni >pointed out to me): Mathematica will still insist on changing the >form in some instances, e.g., > > TraditionalForm[HoldForm[y = f[x] + c]] > >displays (with the letters italicized Times) as: > > y = c + f(x) This is because TraditionalForm re-orders expressions (even inside Hold or HoldForm). E.g, try f[x] + c // TraditionalForm You can, if you like, define your own Form, say MurrayForm which does not do such a re-ordering. (I think that this is the "right" way of doing this). There will be an item in a future issue of The Mathematica Journal (9(2)?) that describes an easy way to define a new format using ParentForm. All rules of a particular format (say StandardForm) are inherited from the ParentForm and new rules can be added and old rules overridden if desired. Cheers, Paul >Paul Abbott wrote: >>In article <bdefg7$dko$1 at smc.vnet.net>, >> Murray Eisenberg <murray at math.umass.edu> wrote: >> >>>Thanks to all who have replied so far -- and please keep the >>>answers coming! Perhaps we will at last see a truly simple, >>>straigntforward, robust, and correct way to accomplish what seems >>>such a basic task for annotating graphics! >>> >>>So far, the solution below -- with the proposer's subsequent >>>(privately sent) amendment to wrap y and f[x] with HoldForm -- >>>seems to be the only one that actually works in the sense I >>>indicated. >>> >>>There still seems to be no general solution that would also >>>properly format, in conventional form, other math expressions as >>>Text in graphics output. >> >> >>Surely HoldForm does exactly what you want? Try >> >> Plot[Sin[x], {x, 0, 2Pi}, >> Epilog -> {Text[TraditionalForm[HoldForm[y = f[x]]], {Pi, 3/4}]}]; >> >>Cheers, >>Paul >> >>>Gianluca Gorni wrote: >>> >>>>Hello! >>>> >>>>I do it this way: >>>> >>>>Format[myEqual[x_, y_], TraditionalForm] := >>>> DisplayForm[RowBox[{x, "=", y}]]; >>>> >>>>Plot[Sin[x], {x, 0, 2Pi}, >>>> Epilog -> {Text[TraditionalForm[myEqual[y, f[x]]], {Pi, 1/2}]}]; >>>> >>>>Good luck, >>>> >>>> Gianluca Gorni >>>> >>>>>From: Murray Eisenberg <murray at math.umass.edu> To: mathgroup at smc.vnet.net >> >>To: mathgroup at smc.vnet.net >> >>>>To: mathgroup at smc.vnet.net >>>> >>>>>Organization: Mathematics & Statistics, Univ. of Mass./Amherst >>>>>Reply-To: murray at math.umass.edu >>>>>Date: Wed, 25 Jun 2003 01:53:47 -0400 (EDT) >>>>>To: mathgroup at smc.vnet.net >>>>>Subject: [mg42322] [mg42299] format Text in graphics >>>>> >>>>>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 >>>>> >>>> >>>> >>>> >> > >-- >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