# PlotLabel for plots in a Table

I have a Table containing two plots, given by

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


As you can see, Mathematica has rewritten the first PlotLabel (i.e.,Sum[Sinc[Pi*(#1 - i*j)], {i, 1, Floor[#1]}] &) into an expression it considers more useful or natural. I don't want it to do this. I want the PlotLabel for that plot to look like this:

i.e., as though it was written PlotLabel -> "expr". But the other label is already how I want it.

I have experimented with using StringForm but it doesn't help. How do I do this? Or is it not possible?

## 1 Answer

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


You can replace HoldForm and ReleaseHold with Defer and First, respectively, to get the same result.

As Bob Hanlon suggested in comments, in versions 12.0+ you can use ReImPlot as follows:

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


• +1 Also with version 12 you could use ReImPlot Commented Sep 8, 2020 at 13:09
• Thanks @Bob Hanlon. Yes, I'm aware of ReIm but haven't found a way to make the two lines different colours! Commented Sep 8, 2020 at 13:30
• @RichardBurke-Ward - Use the option ReImStyle Commented Sep 8, 2020 at 13:33
• Thank you @BobHanlon. I updated with a version using ReImPlot.
– kglr
Commented Sep 8, 2020 at 13:46
• Many thanks to both of you. Commented Sep 8, 2020 at 14:06