`PlotLabel` für Diagramme in einer` Tabelle`

Sep 08 2020

Ich habe Tablezwei Grundstücke, gegeben durch

Table[
 Plot[{Re[f[n]] /. j -> 3, Im[f[n]] /. j -> 3}, {n, 0, 15}, 
  GridLines -> Automatic, PlotRange -> All, PlotLegends -> {"Real", "Imaginary"}, 
  PlotLabel -> f[n]], 
{f, {Sum[Sinc[Pi*(#1 - i*j)], {i, 1, Floor[#1]}] & , 
   (-1 + E^(2*I*Pi*#1))/(j*(-1 + E^((2*I*Pi*#1)/j))) & }}
]

Wie Sie sehen können, hat Mathematica den ersten PlotLabel(dh Sum[Sinc[Pi*(#1 - i*j)], {i, 1, Floor[#1]}] &) in einen Ausdruck umgeschrieben, den es für nützlicher oder natürlicher hält. Ich möchte nicht, dass es das tut. Ich möchte, PlotLabeldass die Handlung so aussieht:

dh als ob es geschrieben wurde PlotLabel -> "expr". Aber das andere Label ist schon so, wie ich es will.

Ich habe mit der Verwendung experimentiert, StringFormaber es hilft nicht. Wie mache ich das? Oder ist das nicht möglich?

Antworten

6 kglr Sep 08 2020 at 19:04
Table[Plot[{Re[ReleaseHold@f] /. j -> 3,  Im[ReleaseHold@f] /. j -> 3}, {n, 0, 15}, 
  GridLines -> Automatic, 
  PlotRange -> All, ImageSize -> 350, 
  PlotLegends -> {"Real", "Imaginary"}, 
  PlotLabel ->  f], 
{f, {HoldForm@Sum[Sinc[Pi*(n - i*j)], {i, 1, Floor[n]}], 
   HoldForm[(-1 + E^(2*I*Pi*n))/(j*(-1 + E^((2*I*Pi*n)/j)))]}}]

Sie können HoldFormund ReleaseHolddurch Deferbzw. ersetzen First, um das gleiche Ergebnis zu erzielen.

Wie Bob Hanlon in den Kommentaren vorgeschlagen hat, können Sie in Versionen 12.0+ ReImPlotFolgendes verwenden:

 Table[ReImPlot[ReleaseHold[f] /. j -> 3, {n, 0, 15}, 
    GridLines -> Automatic, PlotRange -> All, ImageSize -> 350, 
    PlotLegends -> "ReIm", 
    ReImLabels -> {"Real", "Imaginary"}, 
    ReImStyle -> {ColorData[97][1], {ColorData[97][2], Dashing[{}]}},
    PlotLabel -> f], 
  {f, {HoldForm@Sum[Sinc[Pi*(n - i*j)], {i, 1, Floor[n]}], 
      HoldForm[(-1 + E^(2*I*Pi*n))/(j*(-1 + E^((2*I*Pi*n)/j)))]}}]