11
$\begingroup$

Say I had some good reason to use, for example

SetOptions[Plot,ImageSize->500, LabelStyle->OutrageousPink];

But now sometime has passed, life has changed, and I changed my mind. I don't remember which options I have set for plot, let alone what their default values were. Is there a way to "undo" this?

PS: I know that I can save in advance all the options with plotOptions=Options[Plot], but this requires thinking ahead, which I'm obviously trying to avoid...

$\endgroup$
1

2 Answers 2

10
$\begingroup$

I saw this somewhere else on here, but I cannot remember where. The simplest method is to use a fresh kernel:

SetOptions[Plot, Axes -> False];
LaunchKernels[1];
ParallelEvaluate[Options[Plot, Axes]]
(* {{Axes -> True}} *)

then you dispose of the kernel

CloseKernels[]
(* {KernelObject[1, "local", "<defunct>"]} *)
$\endgroup$
4
  • $\begingroup$ Something like this was used here, although that was about Attributes, and not Options... (+1) $\endgroup$
    – Jens
    Commented Dec 2, 2014 at 4:07
  • $\begingroup$ @Jens yes, that is exactly where I remember seeing it. $\endgroup$
    – rcollyer
    Commented Dec 2, 2014 at 4:36
  • $\begingroup$ @rcollyer Probably instead of AbortKernels[] you meant CloseKernels[]... $\endgroup$ Commented Jul 2, 2015 at 22:21
  • $\begingroup$ @AlexeyPopkov why yes I did. :) $\endgroup$
    – rcollyer
    Commented Jul 3, 2015 at 12:44
2
$\begingroup$

Another option is to use LocalSubmit. Here's a function to do this:

originalOptions[sym_, option_] := Module[{res},
    TaskWait @ LocalSubmit[
        Options[sym, option], 
        HandlerFunctions -> <|"TaskFinished" -> ((res = #["EvaluationResult"])&)|>
    ];
    res
]

Then:

SetOptions[Plot, Axes->False];
originalOptions[Plot, Axes]

{Axes -> True}

$\endgroup$
1
  • $\begingroup$ which, of course, is a self-contained method of sending it to a parallel kernel. :) $\endgroup$
    – rcollyer
    Commented Jun 15, 2019 at 23:39

Your Answer

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

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