Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Graphics--How to plot all functions issued from For loop and

  • To: mathgroup at smc.vnet.net
  • Subject: [mg71838] Re: Graphics--How to plot all functions issued from For loop and
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Thu, 30 Nov 2006 06:05:44 -0500 (EST)
  • Organization: Uni Leipzig
  • References: <ekjg15$df7$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de

Hi,

and keeping a list with the legend labels in the For[] loop
does not help ?

<< "Graphics`";
<< "Graphics`Legend`";
listps = {};
leglist = {};
For[k = 0, k <= 5, {ps = PolarPlot[Sin[k*x], {x, -Pi/2, Pi/2}, PlotStyle 
-> Hue[(k - 1)/7],
        AxesLabel -> {θ, Ï?}, DisplayFunction -> Identity];
      AppendTo[leglist, {Hue[(k - 1)/7], HoldForm @@ {Sin[k*x]}}]; 
listps = Join[listps, {ps}]; }, k++];
pc = PolarPlot[Cos[x], {x, Pi/2, 3*(Pi/2)}, PlotStyle -> Hue[0.8], 
AxesLabel -> {θ, Ï?},
     DisplayFunction -> Identity];
AppendTo[leglist, {Hue[0.8], HoldForm[Cos[k*x]]}];
ShowLegend[DisplayTogether[listps, pc, Ticks -> {PiScale, Automatic},
     PlotRange -> {{-Pi/2, Pi/2}, Automatic}, ImageSize -> 700, 
DisplayFunction -> Identity],
    {leglist, LegendPosition -> {0.8, 0.1}, LegendSize -> {0.3, 0.2}, 
LegendShadow -> {0.02, -0.02}}];

Regards
   Jens


abdou.oumaima at hotmail.com wrote:
> Hello MathGroup,
> I'd like to plot all functions issued from For Loop then color them automatically. If my loop is =10 it'll be very hard to write all Hue commands and all legends. Is there any way to plot and color and legend all functions automatically. I don't want to do that manually.
> Please Help.
> Many thanks in advance.
> Cheers.
> Lian.
> 
> NB: Please copy and past the code bellow into a notebook file to see what I did manually then evaluate it.
> 
> \!\(\*
>   RowBox[{\(<< Graphics`;\), 
>     "\[IndentingNewLine]", \(<< "\<Graphics`Legend`\>";\), 
>     "\[IndentingNewLine]", "\[IndentingNewLine]", \(listps = {};\), 
>     "\[IndentingNewLine]", 
>     RowBox[{
>       RowBox[{"For", "[", 
>         RowBox[{\(k = 0\), ",", \(k \[LessEqual] 5\), ",", 
>           RowBox[{"{", "\[IndentingNewLine]", 
>             RowBox[{
>               RowBox[{"ps", "=", 
>                 RowBox[{
>                   StyleBox["PolarPlot",
>                     FontColor->RGBColor[1, 0, 0]], 
>                   "[", \(Sin[k\ x], {x, \(-Pi\)/2, Pi/2}, 
>                   PlotStyle \[Rule] Hue[\(k - 1\)\/7], 
>                   AxesLabel \[Rule] {\[Theta], \[Psi]}, \ 
>                   DisplayFunction \[Rule] Identity\), "]"}]}], ";", 
>               "\[IndentingNewLine]", 
>               "\[IndentingNewLine]", \(listps = Join[listps, List[ps]]\), 
>               ";"}], "\[IndentingNewLine]", "\[IndentingNewLine]", "}"}], 
>           ",", \(k++\)}], "\[IndentingNewLine]", "]"}], ";"}], 
>     "\[IndentingNewLine]", 
>     RowBox[{
>       RowBox[{"pc", "=", 
>         RowBox[{
>           StyleBox["PolarPlot",
>             FontColor->RGBColor[1, 0, 0]], "[", \(Cos[x], {x, Pi/2, 3\ Pi/2}, 
>           PlotStyle \[Rule] Hue[\ 0.8], \ 
>           AxesLabel \[Rule] {\[Theta], \[Psi]}, \ 
>           DisplayFunction \[Rule] Identity\), "]"}]}], ";"}], 
>     "\[IndentingNewLine]", 
>     "\[IndentingNewLine]", \(ShowLegend[
>         DisplayTogether[listps, pc, Ticks \[Rule] {PiScale, Automatic}, 
>           PlotRange \[Rule] {{\(-Pi\)/2, Pi/2}, Automatic}, 
>           ImageSize \[Rule] 700, 
>           DisplayFunction \[Rule] 
>             Identity], {{{Hue[0], "\<1\>"}, {Hue[1\/7], "\<Sin(x)\>"}, {Hue[
>                 2\/7], "\<Sin(2x)\>"}, {Hue[3\/7], "\<Sin(3 x)\>"}, {Hue[
>                 4\/7], "\<Sin(4 x)\>"}, {Hue[5\/7], "\<Sin(5 x)\>"}, {Hue[
>                 0.8], "\<Cos (x)\>"}}, LegendPosition \[Rule] { .8,  .1}, 
>           LegendSize \[Rule] { .3,  .2}, \ 
>           LegendShadow \[Rule] { .02, \(- .02\)}}];\)}]\)
> 
> Link to the forum page for this post:
> http://www.mathematica-users.org/webMathematica/wiki/wiki.jsp?pageName=Special:Forum_ViewTopic&pid=15758#p15758
> Posted through http://www.mathematica-users.org [[postId=15758]]
> 
> 


  • Prev by Date: RE: Graphics--How to plot all functions issued from For loop and color
  • Next by Date: Re: Graphics--How to plot all functions issued from For loop and
  • Previous by thread: Re: Graphics--How to plot all functions issued from For loop and
  • Next by thread: Re: Graphics--How to plot all functions issued from For loop and