动态显示和隐藏绘图
如果在图中有多条线,你希望隐藏或显示特定一条。该操作可以使用 Opacity 和 Manipulate 完成.
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]