Re: Baffling Failure when plotting multiple curves.
- To: mathgroup at smc.vnet.net
- Subject: [mg44171] Re: Baffling Failure when plotting multiple curves.
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Sat, 25 Oct 2003 06:26:20 -0400 (EDT)
- Organization: Universitaet Leipzig
- References: <bnao48$4ei$1@smc.vnet.net>
- Reply-to: kuska at informatik.uni-leipzig.de
- Sender: owner-wri-mathgroup at wolfram.com
Hi,
and
Plot[Evaluate[voteCurves[{p1, p2}]], {\[Theta], -90, 180},
AxesOrigin -> {0, 0}, PlotRange -> {{-90, 180}, {0, 255 Sqrt[2]}},
AspectRatio -> 1, Frame -> True]
works also.
Regards
Jens
Bob Harris wrote:
>
> Howdy,
>
> Am having trouble getting collections of 2D function plots to work. I have
> created a function that returns a list of "equations" in one variable,
> theta. I.e. an equation is an expression like 17 Cos[theta] + 10
> Sin[theta]. When I try to plot this list of functions AS THE RETURN VALUE
> OF MY FUNCTION, Mathematica complains (details below). However, if I
> evaluate the function first, then cut and paste the result into the call to
> Plot, it works ok (but this is not very useful to me, since I want to
> incorporate this into a larger function). Further, if my function returns a
> list with only one equation in it, then handing the function call to Plot
> works. I'm clueless as to what he difference is.
>
> Here are the details.
>
> This function returns a list of eqations, given a list of 2D points (cos[]
> and sin[] are degree-based versions of Cos[] and Sin[] that I've defined)
>
> voteCurves[pnts_List] := Module[{vc, xx, yy},
> vc = {};
> For[ix = 1, ix ¾ Length[pnts], ix++,
> xx = pnts[[ix]][[1]];
> yy = pnts[[ix]][[2]];
> vc = Append[vc, xx cos[\[Theta]] + yy sin[\[Theta]]];
> ];
>
> vc
> ]
>
> Here are two typical points:
>
> p1 = {158, 116};
> p2 = {74 , 135};
>
> and here's a typical list of equations result:
>
> voteCurves[{p1, p2}]
>
> { 158 Cos[\[Pi] \[Theta] /180] + 116 Sin[\[Pi] \[Theta] /180],
> 74 Cos[\[Pi] \[Theta] /180] + 135 Sin[\[Pi] \[Theta] /180]}
>
> This works (two equations, by cut and paste):
>
> Plot[
> { 158 Cos[\[Pi] \[Theta] /180] + 116 Sin[\[Pi] \[Theta] /180],
> 74 Cos[\[Pi] \[Theta] /180] + 135 Sin[\[Pi] \[Theta] /180]},
> {\[Theta], -90, 180},
> AxesOrigin -> {0,0},
> PlotRange -> {{-90, 180}, {0, 255 Sqrt[2]}},
> AspectRatio -> 1,
> Frame -> True])
>
> And this works (one equation, as function return value):
>
> Plot[voteCurves[{p1}],{\[Theta], -90, 180},
> AxesOrigin -> {0,0},
> PlotRange -> {{-90, 180}, {0, 255 Sqrt[2]}},
> AspectRatio -> 1,
> Frame -> True])
>
> But this fails (two equations, as function return value):
>
> Plot[voteCurves[{p1,p2}],{\[Theta], -90, 180},
> AxesOrigin -> {0,0},
> PlotRange -> {{-90, 180}, {0, 255 Sqrt[2]}},
> AspectRatio -> 1,
> Frame -> True])
>
> The errors I get are
> Plot::"plnr": "\!\(voteCurves[\(\({p1, p2}\)\)]\) is not
> a machine-size real number at \!\(\[Theta]\) = \!\(-89.99998875`\)."
>
> My best guess is that the theta I return from my function call is considered
> to be a different theta than the one I use in the plot statement. But if
> that is true, why does the function call usage work ok when the function
> just returns one value? I'm baffled trying to figure out the difference,
> and in trying to come up with a solution.
>
> Thanks for any help,
> Bob Harris
>
> P.S. I'm using Mathematica 4.0.1.0 on Mac OS 9.04 at home, *AND* Mathematica
> 5.something on Mac OSX at school. Had the same problem on both.