Chech this example:

SetOptions[Plot,ImagePadding -> {{50, 30}, {Automatic, Automatic}}];    
Options[Plot, ImagePadding]    
 (*{ImagePadding -> {{50, 30}, {Automatic, Automatic}}}*)
SetOptions[Grid, Dividers -> All, Alignment -> Left];
Options[Grid, {Alignment, Dividers}]
 (*{Alignment -> Left, Dividers -> All}*)
Grid[{{Plot[{Sin[x], Cos[x]}, {x, 0, 2}, 
 PlotLegends -> "Expressions"]}, {Plot[Exp[x], {x, 0, 10}]}}]

enter image description here

However this works fine:

Grid[{{Plot[{Sin[x], Cos[x]}, {x, 0, 2}, 
  PlotLegends -> "Expressions"]}, {Plot[Exp[x], {x, 0, 10}]}}, 
  Alignment -> Left, Dividers -> All]

Any idea why and any solutions?


  • $\begingroup$ Recently, I have become of opinion that SetOptions should in fact never be used, because it redefines the option values in a global way (which means that two different applications using it may easily conflict with each other without knowing it). You can pass options locally, and it should always work and is much safer. I have discussed a solution that would emulate stateful option changes (and make this convenient), while still passing them locally, here and here. $\endgroup$ Jun 22, 2015 at 23:17
  • $\begingroup$ @LeonidShifrin Setting Options globally sometimes is helpful. in me case, I have a big code where Grid is used every where and it is going to be pain to add same option to each Grid function. I did not get your point when you said "two different applications use it may easily conflict" . isn't the option when set globally is going to be attached to the needed function? so what is harm with that. As long as the function accept the option in local base with any argument it should not matter to set it globally $\endgroup$ Jun 23, 2015 at 5:38
  • $\begingroup$ In my post I linked to, I gave a solution that would have almost the same convenience as SetOptions, in terms of setting it once and then just using it, while would be much safer and also would always work (SetOptions is known to not work properly on some functions). Re: app conflict - well, imagine two apps which are used intermittently and both set some option to the same built-in function, but in a different way. Then, unless they call SetOptions in every function they provide, chances are that at least one such app will not work properly. $\endgroup$ Jun 23, 2015 at 15:35


Browse other questions tagged or ask your own question.