„PlotLabel” dla wykresów w „Tabeli”

Sep 08 2020

Mam Tabledwie działki, podane przez

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))) & }}
]

Jak widać, Mathematica przepisała pierwsze PlotLabel(tj. Sum[Sinc[Pi*(#1 - i*j)], {i, 1, Floor[#1]}] &) Na wyrażenie, które uważa za bardziej przydatne lub naturalne. Nie chcę, żeby to robił. Chcę, PlotLabelaby działka wyglądała następująco:

tj. tak, jakby było napisane PlotLabel -> "expr". Ale druga wytwórnia jest już taka, jaką chcę.

Eksperymentowałem z użyciem, StringFormale to nie pomaga. Jak mam to zrobic? Czy nie jest to możliwe?

Odpowiedzi

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)))]}}]

Można wymieniać HoldFormi ReleaseHoldz Deferi First, odpowiednio, aby uzyskać ten sam rezultat.

Jak zasugerował Bob Hanlon w komentarzach, w wersjach 12.0+ możesz użyć ReImPlotw następujący sposób:

 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)))]}}]