2
$\begingroup$

Is it possible to assign a couple of Plot options like e.g.

Frame -> True, PlotRange -> All, ImageSize -> 500

to a variable so that I can use it instead of repeating all options in my next plot?

$\endgroup$
2
  • 4
    $\begingroup$ try SetOptions[{Plot}, Frame -> True, PlotRange -> All, ImageSize -> 500] see SetOptions $\endgroup$
    – Nasser
    Apr 4, 2018 at 20:19
  • 6
    $\begingroup$ Also opts = Sequence[Frame->True,PlotRange->All,ImageSize->500 ] should be possible. $\endgroup$ Apr 4, 2018 at 20:31

1 Answer 1

3
$\begingroup$

First of all, one should mention that it is possible to define a custom PlotTheme:

Is it possible to define a new PlotTheme?

Second, something like @Henrik Schumacher's suggestion is possible, but (1) you need to use Evaluate and (2) one can use a simple List instead of Sequence, which makes combining and adding options somewhat easier.

A couple of examples:

myPlotOpts = {Frame -> True, PlotRange -> All, ImageSize -> 500};

Plot[Sin[x], {x, -6, 6}, Evaluate@myPlotOpts]

Mathematica graphics

It combines with other options without having to worry about the list structure:

Plot[Sin[x], {x, -6, 6}, PlotStyle -> Red, Evaluate@myPlotOpts]

Mathematica graphics

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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