Message Boards Message Boards

0
|
2559 Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:

How do I color each individual curves differently inside a single plot?

Posted 2 years ago

How do I color each individual curves differently inside a single plot using a custom color function? The code used to work when I had manually created the variables instead of using a Do Loop to automatically generate variables. I've used both PlotStyle and ColorFunction but none of them works.

R[r_] := 2/(5*3)*1/(2*3)!*((2*r)/(5*3))^(2*3)*E^((-2*r)/(5*3))
SampleInitialConditions = N[Table[R[r], {r, 0, 100, 4}]];
SampleInitialConditionsMatrix = 
    List@N[Table[{r, R[r]}, {r, 0, 100, 4}]];
ALPHAkWITH = Table[0.002*Mass*Radius, {Mass, 1, 6}, {Radius, 1, 6}];
ALPHAkWITHOUT = 
  Table[0.001*Mass*Radius, {Mass, 1, 6}, {Radius, 1, 6}];

LabelString = Table[StringForm["\[NumberSign] ``", LS], {LS, 1, 25}];
ColorList = {Table[{Blend[{Blue, Green, Yellow, Red, Brown}, 
       InitialCond]}, {InitialCond, 
            1/25, 1, 1/25}]} // Flatten;

LegendWith = 
    SwatchLegend[ColorList, LabelString, 
      LegendLabel -> "With Photophoresis", LegendFunction -> "Frame", 
      LegendLayout -> "Row"];
LegendWithout = 
    SwatchLegend[ColorList, LabelString, 
      LegendLabel -> "Without Photophoresis", 
   LegendFunction -> "Frame", 
      LegendLayout -> "Row"];
LegendInitialConditions = 
    SwatchLegend[ColorList, LabelString, 
      LegendLabel -> "Initial Conditions", LegendFunction -> "Frame", 
      LegendLayout -> "Row"];

Do[
  ToExpression[
    "DiffequaWith\[VerticalLine]\[NumberSign]" <> ToString[Mass] <> 
   "\[VerticalLine]§\[VerticalLine]\[NumberSign]" <> 
   ToString[Radius] <> "\[VerticalLine]", StandardForm,
    Function[sym,
     sym = 
      Table[NDSolve[{q[\[Phi]] + 

         q''[\[Phi]] == -(ALPHAkWITH[[Mass, 
             Radius]]/(1 + q[\[Phi]]))^2, 
            q[0] == R[r], q'[0] == R[r]}, q, {\[Phi], 0, 100}], {r, 
      0, 100, 
          4}]
     , HoldAll]
    ],
  {Mass, 1, 6}, {Radius, 1, 6}
  ]

Do[
  ToExpression[
    "DiffequaWithout\[VerticalLine]\[NumberSign]" <> ToString[Mass] <> 
   "\[VerticalLine]§\[VerticalLine]\[NumberSign]" <> 
   ToString[Radius] <> "\[VerticalLine]", StandardForm,
    Function[sym,
     sym = 
      Table[NDSolve[{q[\[Phi]] + 

         q''[\[Phi]] == -(ALPHAkWITHOUT[[Mass, 
             Radius]]/(1 + q[\[Phi]]))^2, 
            q[0] == R[r], q'[0] == R[r]}, q, {\[Phi], 0, 100}], {r, 
      0, 100, 
          4}]
     , HoldAll]
    ],
  {Mass, 1, 6}, {Radius, 1, 6}
  ]

Do[
  ToExpression[
    "CartesianEvaluateWith\[VerticalLine]\[NumberSign]" <> 
   ToString[Mass] <> "\[VerticalLine]§\[VerticalLine]\[NumberSign]" <> 
   ToString[Radius] <> "\[VerticalLine]", StandardForm,
    Function[sym, 
      sym = 
    Evaluate[
     q[\[Phi]] /. 
      ToExpression[
       "DiffequaWith\[VerticalLine]\[NumberSign]" <> ToString[Mass] <> 
        "\[VerticalLine]§\[VerticalLine]\[NumberSign]" <> 
        ToString[Radius] <> "\[VerticalLine]"]], 
      HoldAll]
    ],
  {Mass, 1, 6}, {Radius, 1, 6}
  ]
 
Do[
  ToExpression[
    "CartesianEvaluateWithout\[VerticalLine]\[NumberSign]" <> 
   ToString[Mass] <> "\[VerticalLine]§\[VerticalLine]\[NumberSign]" <> 
   ToString[Radius] <> "\[VerticalLine]", StandardForm,
    Function[sym, 
      sym =  
    Evaluate[
     q[\[Phi]] /. 
      ToExpression[
       "DiffequaWithout\[VerticalLine]\[NumberSign]" <> 
        ToString[Mass] <> 
        "\[VerticalLine]§\[VerticalLine]\[NumberSign]" <> 
        ToString[Radius] <> "\[VerticalLine]"]], 
      HoldAll]
    ],
  {Mass, 1, 6}, {Radius, 1, 6}
  ]

Do[
  ToExpression[
    "CartesianPlotWith\[VerticalLine]\[NumberSign]" <> 
   ToString[Mass] <> "\[VerticalLine]§\[VerticalLine]\[NumberSign]" <> 
   ToString[Radius] <> "\[VerticalLine]", StandardForm,
    Function[sym, 
      sym = 
    Plot[ToExpression[
      "CartesianEvaluateWith\[VerticalLine]\[NumberSign]" <> 
       ToString[Mass] <> 
       "\[VerticalLine]§\[VerticalLine]\[NumberSign]" <> 
       ToString[Radius] <> "\[VerticalLine]"], {\[Phi], 0, 100}, 
     PlotLabels -> 

      Table[Callout[
        "With Photohoresis \[NumberSign] " <> ToString[InitialCond], 
        Above], {InitialCond, 
              1, Length[SampleInitialConditions]}], 
     PlotStyle -> Table[ColorList[[T]], {T, 0, 25}], 
        PlotLegends -> Placed[LegendWith, {Top, Left}], 
     ImageSize -> 900], 
      HoldAll]
    ],
  {Mass, 1, 6}, {Radius, 1, 6}
  ]
 
Do[
  ToExpression[
    "CartesianPlotWithout\[VerticalLine]\[NumberSign]" <> 
   ToString[Mass] <> "\[VerticalLine]§\[VerticalLine]\[NumberSign]" <> 
   ToString[Radius] <> "\[VerticalLine]", StandardForm,
    Function[sym, 
      sym =  
    Plot[ToExpression[
      "CartesianEvaluateWithout\[VerticalLine]\[NumberSign]" <> 
       ToString[Mass] <> 
       "\[VerticalLine]§\[VerticalLine]\[NumberSign]" <> 
       ToString[Radius] <> "\[VerticalLine]"], {\[Phi], 0, 100}, 
     PlotLabels -> 

      Table[Callout[
        "Without Photophoresis \[NumberSign] " <> 
         ToString[InitialCond], 
              Below], {InitialCond, 1, 
        Length[SampleInitialConditions]}], 
     PlotStyle -> Table[ColorList[[T]], {T, 0, 25}], 
        PlotLegends -> Placed[LegendWithout, {Bottom, Right}], 
        ImageSize -> 900], 
      HoldAll]
    ],
  {Mass, 1, 6}, {Radius, 1, 6}
  ]
 
 Do[
  ToExpression[
    "CombinedCartesianPlot\[VerticalLine]\[NumberSign]" <> 
   ToString[Mass] <> "\[VerticalLine]§\[VerticalLine]\[NumberSign]" <> 
   ToString[Radius] <> "\[VerticalLine]", StandardForm,
    Function[sym, 
      sym = 
    Show[ToExpression[ 
      "CartesianPlotWith\[VerticalLine]\[NumberSign]" <> 
       ToString[Mass] <> 
       "\[VerticalLine]§\[VerticalLine]\[NumberSign]" <> 
       ToString[Radius] <> "\[VerticalLine]"], 
     ToExpression[
      "CartesianPlotWithout\[VerticalLine]\[NumberSign]" <> 
       ToString[Mass] <> 
       "\[VerticalLine]§\[VerticalLine]\[NumberSign]" <> 
       ToString[Radius] <> "\[VerticalLine]"],   PlotLabel -> 

      "Positions of With and Without Photophoresis of a particle with \
#InsertRadiusHere#", Frame -> True], 
      HoldAll]
    ],
  {Mass, 1, 6}, {Radius, 1, 6}
  ]
CombinedCartesianPlot\[VerticalLine]\[NumberSign]1\[VerticalLine]§\
\[VerticalLine]\[NumberSign]1\[VerticalLine]

Note: I want to color each individual curves (all 25 of them) using my own color function (ColorList) inside a plot, but I don't want each of the 6X6 (36) Plot Variables to have individual color schemes each.

Here is the notebook that I use:

Posted 2 years ago

Crossposted here.

POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract