2
$\begingroup$

How do I change the default ImageSize for all functions producing graphics programmatically for the current session (only)?

Something close to an answer is given in https://mathematica.stackexchange.com/a/15270/45020, but it either only changes the output of one function (such as Plot) or the solution uses the FrontEnd Menu instead of code.

$\endgroup$

1 Answer 1

5
$\begingroup$

You can see how to set frontend options programmatically in the question Is there a way to programmatically set global preferences?.

In your particular case:

SetOptions[
 $FrontEndSession,
 GraphicsBoxOptions -> {"ImageSize" -> 600}
 ]

where 600 is the default image size. This should last only for the current session, you can reset it using this code:

SetOptions[
 $FrontEndSession,
 GraphicsBoxOptions -> {"ImageSize" -> Automatic}
 ]
$\endgroup$
5
  • $\begingroup$ Thanks! Hmm making it last only for the current sessions is kind of important. When sharing the file for example you don't want to mess up someone else's global settings for example. Having to run a specific exit code is bound to fail when someone forgets to close that way. $\endgroup$
    – Kvothe
    Aug 14, 2020 at 11:39
  • $\begingroup$ @Kvothe I didn't read the post that I linked to carefully enough. It seems like using EvaluationNotebook[] instead of $FrontEnd should limit the effect to the current session. $\endgroup$
    – C. E.
    Aug 14, 2020 at 11:47
  • 1
    $\begingroup$ $FrontEndSession should affect all notebooks until the frontend is restarted, can't test it at the moment though. $\endgroup$
    – Lukas Lang
    Aug 14, 2020 at 12:13
  • $\begingroup$ @C.E. Thanks! But now it seems that some settings cannot be changed this way. For example how can I change the LabelStyle using this? The naive attempt LabelStyle -> Red does not work probably for the reasons explained in mathematica.stackexchange.com/a/36770/45020. (Ah sorry I see I changed the scope of my question. But still I would be very grateful for something that works for more general options.) $\endgroup$
    – Kvothe
    Aug 14, 2020 at 18:57
  • $\begingroup$ @LukasLang You are right, it works! I changed the answer to use that. $\endgroup$
    – C. E.
    Aug 15, 2020 at 17:11

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.