In the code below, how can I make 3 separate parameter tables for tup1
, tup2
, tup3
and plot each function fi
of corresponding tupi
as in the image below?
Currently there is one one tup
table.
f1[a_, b_, c_] := (a x^2 + b x + c)/3;
f2[a_, b_, c_] := (a x^2 + b x + c)^2;
f3[a_, b_, c_] := 3 (a x^2 + b x + c);
tup1 := RandomInteger[5, {6, 3}];
tup2 := RandomInteger[5, {8, 3}];
tup3 := RandomInteger[5, {10, 3}];
tup = Join[tup1, tup2, tup3];
functions1 = f1 @@@ tup1;
functions2 = f2 @@@ tup2;
functions3 = f3 @@@ tup3;
functions = Join[functions1, functions2, functions3];
colors = ColorData[97] /@ Range[Length@functions];
functionswithtooltips = MapThread[Tooltip, {functions, tup}];
plot1 = Plot[Evaluate[functionswithtooltips], {x, 0, 5},
GridLines -> Automatic, ImageSize -> Large,
PlotStyle -> Thread[Directive[colors, Opacity[.3], Thin]]];
ttlist = Cases[plot1, _Tooltip, All];
t = Deploy@
DynamicModule[{n = {1}, hidden = ConstantArray[1, Length@ttlist]},
hidden[[n]] = 2;
Dynamic[
Legended[
Graphics[
Table[With[{i = i, ind = hidden[[i]]},
Tooltip[{ttlist[[i, 1, 1]],
DynamicModule[{boxes = {ttlist[[i, 1, 2]],
Style[ttlist[[i, 1, 2]], Opacity[1], Thickness[Large]]},
index = ind, length = 2},
EventHandler[
Dynamic[
boxes[[index]]], {"MouseClicked" :> (index =
index /. {1 -> 2, 2 -> 1};
hidden[[i]] = index;
n = Flatten[Position[hidden, 2]];),
Method -> "Preemptive", PassEventsDown -> True,
PassEventsUp -> True}], DynamicModuleValues :> {}]},
ttlist[[i, 2]]]], {i, 1, Length@ttlist}], ImageSize -> 700,
AspectRatio -> 1/GoldenRatio, PlotRange -> {{0, 5}, {0, 50}},
Frame -> True, GridLines -> Automatic],
TogglerBar[
Dynamic[n, (n = #; hidden[[All]] = 1; hidden[[n]] = 2) &],
MapIndexed[#2[[1]] ->
Style[#, 16, Bold, Opacity[1], colors[[#2[[1]]]]] &, tup],
Appearance -> "Vertical" -> {Automatic, 4}]]]]
f1
is plotted withtup1
,f2
is plotted withtup2
,f3
is plotted withtup3
and then make 3 separate tables for each tuple. Current code plotf1, f2, f3
over all combinations and combine alltup1
,tup2
, tup2` into one table. $\endgroup$ – anhnha Feb 17 at 23:15