3
$\begingroup$

I noticed that when I use Plot3D, ContourPlot3D, etc., I usually pass the same many options like this

Plot3D[{x + y, x - y}, {x, -1, 1}, {y, -1, 1}, 
AspectRatio -> 1, ImageSize -> Large, AxesLabel -> Automatic, 
PlotRange -> Full, LabelStyle -> {FontSize -> 18}, BoxRatios -> {1, 1, 1}]

and

ContourPlot3D[x + y - z == 0, {x, -3, 3}, {y, -3, 3}, {z, -3, 3}, 
AspectRatio -> 1, ImageSize -> Large, AxesLabel -> Automatic, 
PlotRange -> Full, LabelStyle -> {FontSize -> 18}, BoxRatios -> {1, 1, 1}]

Is there a way to avoid copy and paste all the options?

$\endgroup$
  • 3
    $\begingroup$ I am sure this is duplicate. But you can try SetOptions[{Plot3D, ContourPlot3D}, AspectRatio -> 1, ImageSize -> Large, AxesLabel -> Automatic, PlotRange -> Full, LabelStyle -> {FontSize -> 18}, BoxRatios -> {1, 1, 1}]; once. Then use Plot3D and the options will be read from the above set command automatically. $\endgroup$ – Nasser Aug 27 '19 at 11:40
2
$\begingroup$

Another option:

opts = Sequence[AspectRatio -> 1, ImageSize -> Large, 
   AxesLabel -> Automatic, PlotRange -> Full, 
   LabelStyle -> {FontSize -> 18}, BoxRatios -> {1, 1, 1}];

Plot3D[{x + y, x - y}, {x, -1, 1}, {y, -1, 1}, ##] &[opts]
$\endgroup$
4
$\begingroup$

An alternative approach is to create your custom PlotTheme with the collection of options you desire:

System`PlotThemeDump`resolvePlotTheme["myTheme", _] := 
 {ImageSize -> Large, 
   AxesLabel -> Automatic, 
   PlotRange -> Full, 
   LabelStyle -> {FontSize -> 18},
   BoxRatios -> {1, 1, 1}}

and use it as the option setting for PlotTheme:

Plot3D[{x + y, x - y}, {x, -1, 1}, {y, -1, 1},
  PlotTheme -> "myTheme"]

enter image description here

ContourPlot3D[(x + y)( x - y), {x, -1, 1}, {y, -1, 1}, {z, 0, 1}, 
   PlotTheme->"myTheme"]

enter image description here

You can use it in combination with built-in themes:

Plot3D[{x + y, x - y}, {x, -1, 1}, {y, -1, 1}, 
   PlotTheme->{"myTheme", "Detailed", "ThickSurface"}]

enter image description here

$\endgroup$
  • $\begingroup$ Is the context of resolvePlotTheme one of your own creation or the one that exists in the internals? $\endgroup$ – CA Trevillian Aug 28 '19 at 3:49
  • 1
    $\begingroup$ @CATrevillian, System`PlotThemeDump`resolvePlotTheme is an internal function. $\endgroup$ – kglr Aug 28 '19 at 4:05
  • $\begingroup$ thank you for the clarification! I am surprised to see internals that have lowercasing for the first letter of the function $\endgroup$ – CA Trevillian Aug 28 '19 at 4:36

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.