I am new to Mathematica
and want to change the FillingStyle
Dynamically in this Plot
. I want that when I pick a color from the "Color" then, it should dynamically change in the Sin plot.
a = RGBColor[1, 2, 0]
Row[{Button["<>", a = SystemDialogInput["Color"]],
Evaluate[Plot[Sin[m], {m, -Pi, Pi}, Filling -> Bottom,
FillingStyle -> Dynamic[a]]]}]
I am able to pick a color but the plot is not changing dynamically. But, it changes when I am executing it again.
Answer
The expression FillingStyle -> value
is not preserved in the output Graphics
expression of Plot
, therefore it cannot be changed after-the-fact in that fashion. Instead you need to regenerate the plot when the value of a
changes, meaning that Dynamic
needs to surround Plot
:
a = RGBColor[1, 2, 0]
Row[{Button["<>", a = SystemDialogInput["Color"]],
Dynamic @ Plot[Sin[m], {m, -Pi, Pi}, Filling -> Bottom, FillingStyle -> a]}]
Comments
Post a Comment