I always have had performance issues of Manipulate
while using PlotLegends
, for example take a look at the following minimal examples
man1 = Manipulate[
Plot[Evaluate@Table[a*x^n, {n, 1, 8}], {x, 0, 2},
PlotRange -> 2], {a, -1, 1}];
man2 = Manipulate[
Plot[Evaluate@Table[a*x^n, {n, 1, 8}], {x, 0, 2}, PlotRange -> 2,
PlotLegends -> Automatic], {a, -1, 1}];
man3 = Manipulate[
Grid[{{
Dynamic@
Plot[Evaluate@Table[a*x^n, {n, 1, 8}], {x, 0, 2},
PlotRange -> 2, ImageSize -> 350, PlotStyle -> ColorData[97]]
, LineLegend[Table[ColorData[97][ci], {ci, 1, 8}], Automatic]
}}]
, {a, -1, 1}
];
Grid[{{"man1", "man2 (slow)", "man3 (fixed, but cumbersome)"}, {man1,
man2, man3}}]
Here, in man1
a standard plot is manipulated, in man2
you have the same but only with a legend and in man3
I used a grid in order to embed the plot with Dynamic
and the legend separately. man2
is preeeeeeeeetty slow / not as fluently responsive as man1
, although the only difference to man1
is the call of PlotLegends
. I am using Mathematica 11.0.1 for Windows.
Is there any way to fix this more elegantly than my grid in man3
(for larger programs within Manipulate
this becomes somewhat annoying)?