将情节与不同的传说相结合

Combining plots with distinct legends

首先,抱歉,因为我对 Mathematica、英语和 Whosebug 还很陌生。所以,我有以下代码:

k := (di^3 *dj*wi^2 + 2*di^2*(2 - dj)*wi*wj + 
     di*(2 - dj)*wj^2) / (4*di^2*wi + 4*(2 - dj) wj);
wi := 10;
wj := 9;

Table[Plot[
  Evaluate[f[b] /. 
    NDSolve[{f'[b] == 
       2*f[b]/(di*f[b] + 
           di^2*((2*b - (2 - dj)*f[b])/(di*
                 dj) + ((2*b - (2 - dj)*f[b])^2/(di*dj)^2 + (2 - 
                    dj)*(4*b - di*f[b])*f[b]/(di^3*dj))^(1/2) - 2*b)),
       f[0] == 10^-5}, f, {b, 0, k}]], {b, 0, k}, PlotRange -> All, 
  PlotLegends -> 
   StringTemplate["di = `a`, dj = `b`"][<|"a" -> di, "b" -> dj|>]],
 {dj, 0.5, 0.7, 0.1}, {di, 0.1, 0.3, 0.1}];

我想像那样将曲线组合在一个图形中

k := (di^3 *dj*wi^2 + 2*di^2*(2 - dj)*wi*wj + 
     di*(2 - dj)*wj^2) / (4*di^2*wi + 4*(2 - dj) wj);
wi := 10;
wj := 9;

Show[Table[
  Plot[Evaluate[
    f[b] /. NDSolve[{f'[b] == 
        2*f[b]/(di*f[b] + 
            di^2*((2*b - (2 - dj)*f[b])/(di*
                  dj) + ((2*b - (2 - dj)*f[b])^2/(di*dj)^2 + (2 - 
                    dj)*(4*b - di*f[b])*f[b]/(di^3*dj))^(1/2) - 2*b)),
        f[0] == 10^-5}, f, {b, 0, k}]], {b, 0, k}, PlotRange -> All],
  {dj, 0.5, 0.9, 0.1}, {di, 0.1, 0.4, 0.1}]]

谁能帮我把下面的图例放上去?

RAveList = RandomReal[1, {11, 5}];
colors = ColorData[97];
labels = Row[{#, "-clusters"}] & /@ Range[2, 12];
ListPlot[Thread[Tooltip[RAveList, labels]], Joined -> True, 
 DataRange -> {0, 5}, PlotStyle -> colors, PlotLegends -> labels, 
 Axes -> None, Frame -> True]

您有 20 个地块

range = Catenate[Table[{dj, di}, {dj, 0.5, 0.9, 0.1}, {di, 0.1, 0.4, 0.1}]];
Length[range]

20

在 ColorData 中查找 20 种颜色的范围

Column[Select[
  {#, Length[cols = ColorData[#, "ColorList"]], cols} & /@
   ColorData["Indexed"], #[[2]] >= 20 &]]

ColorData[54] 就可以了。

colours = ColorData[54, #] & /@ Range[20];

为各种 {dj, di}

分配 20 种颜色给 f
MapThread[(f[#1] = #2) &, {range, colours}];

添加 PlotStyleLineLegend 显示 {dj, di}

GraphicsRow[{Show[Catenate[Table[Plot[Evaluate[f[b] /. NDSolve[
         {f'[b] == 2*f[b]/
             (di*f[b] + di^2*((2*b - (2 - dj)*f[b])/(di*dj) +
                  ((2*b - (2 - dj)*f[b])^2/(di*dj)^2 +
                    (2 - dj)*(4*b - di*f[b])*f[b]/
                    (di^3*dj))^(1/2) - 2*b)),
          f[0] == 10^-5}, f, {b, 0, k}]], {b, 0, k},
      PlotRange -> All, PlotStyle -> f[{dj, di}]],
     {dj, 0.5, 0.9, 0.1}, {di, 0.1, 0.4, 0.1}]]],
  LineLegend[colours, range]}]

为了更直观地排列图例,请按照绘制的顺序列出。

ordered = Catenate[Reverse /@ Transpose[
     Table[{dj, di}, {dj, 0.5, 0.9, 0.1}, {di, 0.1, 0.4, 0.1}]]];

GraphicsRow[{Show[...],
  LineLegend[f /@ ordered, ordered]}]