Re: showing variables in plots?

• To: mathgroup at smc.vnet.net
• Subject: [mg70057] Re: showing variables in plots?
• From: dimmechan at yahoo.com
• Date: Sun, 1 Oct 2006 04:10:31 -0400 (EDT)
• References: <efle9v\$dds\$1@smc.vnet.net>

```Dear Sam,

One possible way is to work with pure functions as follows

(*a simple example of plotting sin(a x)*)

curve = Plot[Sin[#1*x], {x, 0, 2*Pi}, TextStyle -> {FontFamily ->
Times,
FontSize -> 14}, DisplayFunction -> Identity] & ;

txt = Graphics[Text[StyleForm[StringJoin["a=", ToString[#1]],
FontColor -> Red, FontFamily -> "Times", FontSize -> 16],  {2, 0.8}]] &

Show[curve[2], txt[2], DisplayFunction -> \$DisplayFunction]
(*plot to be displayed*)
Show[curve[6], txt[6], DisplayFunction -> \$DisplayFunction]
(*plot to be displayed*)

Another way is to use PlotLabel in the following way

curve2 = Plot[Sin[#1*x], {x, 0, 2*Pi}, TextStyle -> {FontFamily ->
Times,
FontSize -> 14}, PlotLabel -> StyleForm[StringJoin["a=", ToString[#1]],
FontColor -> Red, FontFamily -> "Times", FontSize -> 16]] & ;

curve2[2]
(*plot to be displayed*)

If you want to avoid pure functions (I don't recomend you; one of
the most attractive elements of Mathematica programming is pure
functions. It is difficult in the beggining but after you can do
amazing
things) one way to work is the follow, in which you work more

f[x_, a_] := Plot[Sin[x], {x, 0, 2*Pi}, TextStyle -> {FontFamily ->
Times,
FontSize -> 14},  Epilog -> {Text[StyleForm[StringJoin["a=",
ToString[a]],
FontColor -> Red, FontFamily -> "Times", FontSize -> 16], {4, 0.8}]}]

f[x, 2]
(*plot to be displayed*)

```

• Prev by Date: Re: tableform question
• Next by Date: Re: subsets of a set
• Previous by thread: Re: showing variables in plots?
• Next by thread: RE: tableform question