# Passing list of options to Plot

I'm looking for a way to create a variable that I can use to hold all of the graphics directives for, say, a plot command. For example, I have 8 plots with variations on the following:

Plot[{Im[eppar[400*10^12, t, 0.1]],
Im[eppar[400*10^12, t, 0.2]],
Im[eppar[400*10^12, t, 0.5]],
Im[eppar[400*10^12, t, 0.8]]
}, {t, tlow, thigh}, (**directives**)]


There's a fairly long list of directives I'm using for the plots, and I'd like to avoid having to modify 8 long, complicated expressions every time I want to change anything. Does anybody know of a solution to this? It would make my code much cleaner.

-
You can use With like in here. –  Kuba Jul 30 '13 at 17:33
Can you give us a clearer idea what you have in mind when you say "avoid having to modify 8 long, complicated expressions every time I want to change anything"? And I think we would like to see the "8 long, complicated expressions" and definition or eppar so we can work with your code. –  m_goldberg Jul 30 '13 at 17:59
I think you may simply be looking for Directive. –  Pickett Jul 30 '13 at 18:22
Closely related: (20718) (setSpec in my second answer is directly applicable.) –  Mr.Wizard Jul 30 '13 at 20:12
@Mr.Wizard Guys, this is not a duplicate of that question (somehow my comment was deleted). That question was about how options are passed to HoldAll functions, but the question asked here is not about that technicality. It is much closer (may be a dupe) to this one. I hope I won't have to repeat this comment a third time (i.e this one won't get deleted). –  Leonid Shifrin Jul 30 '13 at 21:35

Here is another way using Evaluate:

ops1 = {Filling -> {1 -> {2}}, PlotStyle -> {Red, Green}, Frame -> True};

Plot[{Sin[x] + x/2, Sin[x] + x}, {x, 0, 10}
, Evaluate@ops1
, PlotLabel -> Style["Using Evaluate", 20]
]


-

On Leonid's valued opinion that the Close was inappropriate I have reopened this question.

By my interpretation this does what is requested:

SetAttributes[setSpec, HoldAllComplete]

setSpec[s_Symbol, spec__] := s /: h_[pre__, s, post___] := h[pre, spec, post]


The usage is:

setSpec[ops1,
Filling -> {1 -> {2}},
PlotStyle -> {Red, Green},
Frame -> True
]


Now:

Plot[{Sin[x] + x/2, Sin[x] + x}, {x, 0, 10}, ops1]


Because Plot handles both Plot[. . ., option1, option2, . . .] and Plot[. . ., {option1, option2, . . .}] you can use either form in setSpec.

setSpec can also be configured to apply to only certain heads, e.g.:

SetAttributes[setSpecFor, HoldAllComplete]


And usage would be: setSpecFor[Plot, ops1, (* options *)]