5

Let's say I decide I want all my axes to be colored red, so I do

SetOptions[Plot,AxesStyle->Red]

For the remainder of my session, I correctly get

Options[Plot,AxesStyle]
(* {AxesStyle->Red} *)

But when I quit and subsequently reload MMA, I get

Options[Plot,AxesStyle]
(* {AxesStyle -> {}} *)

For how long are changes made by SetOptions supposed to persist? I (apparently incorrectly) understood that these changes were supposed to persist across sessions (i.e., permanent). I thought if you wanted such changes to persist only for the current session, you needed to use something like $FrontEndSession.

bmclaurin
  • 341
  • 1
  • 8

1 Answers1

6

For how long are changes made by SetOptions supposed to persist?

Normally, SetOptions is used with functions (see here). In this case changes do not persist across kernel restarts.

I (apparently incorrectly) understood that these changes were supposed to persist across sessions (i.e., permanent).

No, that is not the case, except in special situations.

I thought if you wanted such changes to persist only for the current session, you needed to use something like $FrontEndSession.

SetOptions[$FrontEnd, ...] does indeed persist between restarts. This is a special case though. The same applies to using SetOptions with cell or notebook references: the cells/notebooks are modified, and if you then save them, the changes become permanent.

This use of SetOptions in my mind is completely distinct from setting options for functions, it just happens to have the same syntax.

Szabolcs
  • 234,956
  • 30
  • 623
  • 1,263
  • thank you very much. I suppose adding SetOptions[symb,rule] to a kernel Init.m file would make the change persist across sessions? Not sure if that's a best practice, but it seems it would work. – bmclaurin Oct 09 '21 at 19:24
  • @bmclaurin Yes, it would work. I do not think it is best practice, and I do not recommend it. Sometimes people change stuff in their init.m, then forget it, and it takes a long time to figure out the cause of a problem they are posting about. If you want to change multiple such options, put the changes in a package, and load that package manually when you need it. – Szabolcs Oct 09 '21 at 20:21
  • Perfect counsel, thank you again. – bmclaurin Oct 09 '21 at 23:49