Re: format Text in graphics
- To: mathgroup at smc.vnet.net
- Subject: [mg42341] Re: format Text in graphics
- From: bghiggins at ucdavis.edu (Brian Higgins)
- Date: Tue, 1 Jul 2003 08:45:46 -0400 (EDT)
- References: <200306250950.FAA04042@smc.vnet.net> <200306271031.GAA24552@smc.vnet.net> <bdjgee$8er$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
As a result of some off-line correspondence with Murray Eisenberg, I have some additional info on embedding traditionalFormat eqns into plots that might be of interest to others. Murray wanted a robust way that would allow him to write general functions. His example was to create a function myText[expr_, where__] := Text[HoldForm[expr], Sequence[where], FormatType :> TraditionalForm] and then apply this function to a plot as Plot[x^2, {x, -1, 1}, Epilog -> myText[f[x] = x^2 + c, {0.5, .8}, {0, 1}]]; This does not produce the desired effect as at the first argument of myText is evaluated before the RHS, and all you get in the plot is "x^2+c". You can get around this problem by changing the attributes of myText SetAttributes[myText,HoldFirst] Then everything works as expected. Thus another example of this approach is SetAttributes[{myXlabel,myYLabel,myPlotLegend},HoldFirst] myXLabel[expr_]:=TraditionalForm[HoldForm[expr]] myYLabel[expr_]:=TraditionalForm[HoldForm[expr]] myPlotLegend[expr_]:=TraditionalForm[HoldForm[expr]] Plot[x^2, {x, -1, 1}, Frame -> True, FrameLabel -> {myXLabel[x], myYLabel[f[x] = x^2]}, RotateLabel -> False, PlotLabel -> myPlotLegend[f[x] = x^2]] Cheers, Brian