# Changing Plot Options for two different graphs under Manipulate

I am trying to plot two discontinuous functions, each with different plot options, using Manipulate. In my code, I have defined a function for $z$ and $sq$ in my code.

opt := {Exclusions -> DeleteDuplicates[Flatten[Table[
{d + (n - 1)*ct, d + (n - 1)*ct + swt, d + n*ct}, {n, 1, nct}]]],
PlotStyle -> Orange, AxesLabel -> {"\[Mu]s", "V"}}
opt2 := {Exclusions -> All, ExclusionsStyle -> Dotted, PlotStyle -> Orange,
PlotPoints -> 5*tt, AxesLabel -> {"\[Mu]s", "V"}}
Manipulate[
Plot[f[x], {x, 0, 10}, Evaluate[opt]], {{f, 1, "Output Type:"},
{z -> "Discontinuous Sine Wave", sq -> "Discontinuous Square Wave"}},
ControlType -> RadioButtonBar, FrameLabel -> {{None,
None}, {"Voltage Peak Amplitude: " <> ToString[vp] <>
"V, Frequency: " <> ToString[f] <> "MHz, Phase Shift: " <>
ToString[\[Phi]] <> " degrees.",
Style["Program for Discontinuous Sine & Square Wave Function", Bold]}}]

I am wondering if there is any possibility to switch the plot option in Evaluate under Manipulate to $opt$ when the user selects function $z$ and $opt2$ when the user selects $sq$. I have been struggling for a very long time trying to figure out a way to achieve this. Thank you so much!

• Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! Commented Jul 21, 2016 at 4:34
• You did well to paste Mathematica code. To make your questions easy for members to answer, a good technique for quality control is to start a new Mathematica notebook and then copy and run your code. If it fails, find the mistake or omission and fix it. Commented Jul 21, 2016 at 14:50

Commenting out incomplete code and making up definitions for z and sq, this works:

z = Sin;
sq = Sign@*Cos;
opt = {(*Exclusions\[Rule]DeleteDuplicates[Flatten[Table[{d+(n-1)*ct,
d+(n-1)*ct+swt,d+n*ct},{n,1,nct}]]],*)PlotStyle -> Orange,
AxesLabel -> {"μs", "V"}};
opt2 = {Exclusions -> All, ExclusionsStyle -> Dotted,
PlotStyle -> Orange,(*PlotPoints\[Rule]5*tt,*)
AxesLabel -> {"μs", "V"}};
Manipulate[
Plot[f[x], {x, 0, 10}, Evaluate[If[f === z, opt, opt2]]],
{{f, z, "Output Type:"}, {z -> "Discontinuous Sine Wave",
sq -> "Discontinuous Square Wave"}},
FrameLabel -> {{None, None},
{"Voltage Peak Amplitude: " <> ToString[vp] <>
"V, Frequency: " <> ToString[f] <> "MHz, Phase Shift: " <>
ToString[ϕ] <> " degrees.",
Style["Program for Discontinuous Sine & Square Wave Function",
Bold]}}]

• Thank you so much!! This is exactly what I am seeking for. Commented Jul 21, 2016 at 4:46

I can't follow what you wrote, but I made small example. Using If it checks which function selected, uses SetOptions[Plot... to set the options

Manipulate[

If[f === Cos,
SetOptions[Plot, {PlotStyle -> Red, Frame -> True}],
SetOptions[Plot, {PlotStyle -> Blue, Frame -> False}]
];

Plot[f[x], {x, -2 Pi, 2 Pi}],
{f, {Sin, Cos}}
]