How can I give Plot formating expressions on a separate line just like ListPlot?

When I use the following code with ListPlot, it produces a plot without any errors:

graphs = {ImageSize -> Full, Frame -> True};
ListPlot[Table[x, {x, 1, 2, .01}], graphs]

However, the same thing doesn't work for Plot:

graphs = {ImageSize -> Full, Frame -> True};
Plot[x, {x, 1, 2}, graphs]

Why? What is the simple notation change that I need to make it work?


You can use

Plot[x, {x, 1, 2}, Evaluate@graphs]


The reason Plot[x, {x, 1, 2}, graphs] doesn't work and ListPlot[Table[x, {x, 1, 2, .01}], graphs]does is that Plot has attribute HoldAll ("all arguments (..) maintained in an unevaluated form")


{HoldAll, Protected, ReadProtected}

whereas ListPlot doesn't:


{Protected, ReadProtected}

  • $\begingroup$ Alternatively, you can inject graph using With as in m_goldberg's answer or using Plot[x, {x, 1, 2}, #] &@graphs. $\endgroup$ – kglr Mar 13 at 23:25

You can also use With because it makes the needed substitution before Plot sees any of its arguments.

options = {ImageSize -> Full, Frame -> True};
With[{opts = options}, Plot[x, {x, 1, 2}, opts]



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.