I have three simple graphs in one Plot. Now I am trying to make a button for each graph so you can hide or show it in the plot. Until now I was just able to make a checkbox with the Manipulate function, but I don't now how to tell the checkbox that it should hide my graph when unchecked an display it when checked.
Here is what I was able to make so far, I know it looks simple but I also have many other mathematica documents which at the end just need this button.
Answer
One way to do this is to use Opacity
to hide a graph and empty label "" to hide a label:
Manipulate[
Plot[{0.5 x + 1, x, 2 x - 2}, {x, -1, 5},
PlotRange -> {-1, 5}, AspectRatio -> 1,
PlotStyle -> {Opacity[a], Opacity[b], Opacity[c]},
Epilog -> {
Text[If[a == 1, "f(x)", ""], {4.5, 2.7}],
Text[If[b == 1, "y=x", ""], {4.5, 4}],
Text[If[c == 1, "g(x)", ""], {3, 4.5}]
}],
{{a, 1, "f(x)"}, {1, 0}},
{{b, 1, "y=x"}, {1, 0}},
{{c, 1, "g(x)"}, {1, 0}}, ControlPlacement -> Left,
FrameMargins -> 0]
Comments
Post a Comment