6
$\begingroup$

Can one set a default PlotTheme globally?

While I recognize one can make lots of workarounds to sort of do this:

  • Go to $UserBaseDirectory -> Kernel, open the init.m and put $PlotTheme = Something where it says (** User Mathematica initialization file **).

  • For a notebook: Mark the input cell $PlotTheme = Something and make it an "Initialization Cell".

These just seem dodgey to me, just not satisfactory for a change in Mathematica (the introduction of PlotThemes) that affects every plot in every notebook I have developed.

It seems to me that PlotTheme does not particularly differ in kind from the kind of Font styling settings Mathematica has available in the OptionInspector.

Does a way exist to do this in OptionInspector?


A response to some of the questions raised in @Mr._Wizard's answer as it might run beyond the size of a comment.

So are you complaining about the general design of Mathematica or do you feel that Plot Themes should be handled specially?

I didn't mean to seem to complain. I think the introduction of PlotTheme provides powerful new functionality and control, very much in keeping with the functional design philosophy of Mathematica -- power at increasingly higher levels of abstraction.

I also think that PlotTheme operates a the right level of abstraction as it can easily affect so much output.

Prior to PlotTheme's introduction, Mathematica had (essentially) a hard coded default plot theme. One could always make local changes in plot formatting, but they all started from that default theme. In introducing PlotTheme, Wolfram not only introduced the new (and better) functionality, but they did a second thing that does not make sense to me. They made a "design" decision (and I'd argue an arbitrary design decision) to reset the hardcoded (default) plot theme.

This arbitrary design decision has had broad ranging consequences for almost all the work I've done in Mathematica since version 2 and I'd wager a great many others' work as well.

Consider what PlotTheme could do if available in OptionInspector. I think the introduction of PlotTheme, begs for inclusion in the OptionInspector. Doesn't it make most sense, there? Following on from my original thoughts in the question, if I can reset the color of fonts that I use for something like comments in code from the OptionInspector, without restarting Mathematica and it affects every notebook I subsequently open, why not a PlotTheme setting to provide comparable affects?

This would also provide an easy way for one to make their own choices about a PlotTheme at the same level in the application whereat Wolfram has controlled the current default setting.

This seems to me like a different kind of thing than the other system parameters you describe - maybe because it has affected so much of the work I have done in the past - but I defer to @Mr._Wizard's greater insight into Mathematica on this. Still, this may also raise the secondary question, what logically ought to get included as a setting in the OptionInspector.

$\endgroup$
  • $\begingroup$ Thanks for updating your question. I'll read it carefully and attempt a thoughtful reply somewhat later. For now after a quick skim I still am not clear about where $PlotTheme is failing you; is it primarily a matter of (in)convenience in editing init.m versus opening the Option Inspector? $\endgroup$ – Mr.Wizard Jun 23 '15 at 14:29
  • $\begingroup$ @Mr.Wizard -- I think it goes beyond inconvenience. The ability to change a setting of something in OptionInspector makes it far easier to try out different things. Having PlotTheme there seems consistent with Mma's paradigm. I've resolved myself, for now, that I can't do it in OptionInspector, but wouldn't it make the most sense there? Also, if a change like the introduction of PlotTheme with the arbitrary change of the default plot theme, foreseeably breaks stuff and Wolfram could provided a great highlevel solution to undo the breakage consistent with its paradigm, shouldn't it do so? $\endgroup$ – Jagra Jun 23 '15 at 14:52
  • $\begingroup$ I have added the language-design tag as I think from your update and comment above it is appropriate. $\endgroup$ – Mr.Wizard Jun 23 '15 at 22:54
4
$\begingroup$

$PlotTheme is exactly the included mechanism for setting a global Plot Theme:

$PlotTheme gives the default setting for the option PlotTheme for graphics functions.

To declare this "dodgey" without further explanation is rather peculiar. Many System parameters are configured the same way: $Pre, $Post, $PreRead, $PrePrint, $MessagePrePrint, $IterationLimit, $RecursionLimit, $CharacterEncoding, $CompilationTarget, $DisplayFunction, $Echo, $Epilog, $HistoryLength, $MaxExtraPrecision, $Output, $Urgent, etc.

So are you complaining about the general design of Mathematica or do you feel that Plot Themes should be handled specially? If the latter you should include your reasoning in the question.

You can of course SetOptions for individual plot functions like Plot, ListPlot, etc. but that seems to go against your stated goal.

PlotTheme is an option for plotting functions, not Graphics or the low level GraphicsBox, therefore you cannot set it as a BaseStyle for GraphicsBoxOptions in the Option Inspector.

Perhaps if you explained why you think that using the Option Inspector is superior to init.m it would be possible to address your concerns in another way.


Global Variables versus Front End Options

The updated question and comments below it are now about the interplay of global variables such as $Pre and $PlotStyle and Front End options as configured with the Option Inspector (as well as Notebook and Selection options). Here are my initial thoughts on the matter. (I shall attempt to better organize them later.)

  • $FrontEnd options both conceptually and in practice are primarily about functionality controlled by the Front End. Examples include rendering characteristics such as anti-aliasing, the size of the Front End undo buffer, action to take on error message generation, input aliases, file locations used by the Front End, Palettes to open on start-up, whether or not to show the Suggestions bar, the PrintPrecision used for display of numbers, and options used in the rendering of a variety of special Box types that can be displayed by the Front End. Changes to Front End options can usually be applied independent of the Kernel; updating them will change existing Notebooks without reevaluation.

  • Global Variables are typically used to configure things that have an effect upon or make use of the Kernel. I believe a connection can be demonstrated for all of the examples given in the first part of this answer. These settings change or use Kernel evaluation in some way; they are not independent of the Kernel so changing them will not automatically updated existing Notebooks.

  • Global Variables can be easily and temporarily configured by using Block. Their values are expected to be dynamic, e.g. $ControlActiveSetting, $PerformanceGoal.

  • PlotThemes is a Kernel functionality. They are not preserved in the Box forms displayed by the Front End. They are qualified and converted by the Kernel into standard Graphics or Graphics3D expressions when a Plot expression is evaluated. You cannot apply a new PlotTheme after-the-fact without regenerating the plot in some way.

If the points above are correct it simply does not make sense for $PlotTheme to be a Front End option.

The fact that it exists as a Global Variable rather than some other setting type means that one can do things like:

Block[{$PlotTheme = "Classic"},
  Plot[{Sin[x], Sin[2 x], Sin[3 x]}, {x, 0, 2 Pi}]
]

This is a level of control that is difficult to emulate otherwise.

Instead of a Front End option within the Option Inspector I propose that what you really want is a Preferences dialog item for setting $PlotTheme. This would be like the checkbox for "Allow Mathematica to access the Internet" in the Internet Connectivity tab which changes the value assigned to $AllowInternet.

$\endgroup$
  • $\begingroup$ +1, Please see added thoughts in my original question. $\endgroup$ – Jagra Jun 23 '15 at 14:19
  • $\begingroup$ @Jagra Please see my added thoughts now. :-) $\endgroup$ – Mr.Wizard Jun 23 '15 at 23:52
  • $\begingroup$ Great answer providing real insight into Mathematica's design. And yes, a Preferences dialog item would work fine. Many thanks. $\endgroup$ – Jagra Jun 24 '15 at 12:06
  • $\begingroup$ Is there an easy way to determine what $PlotTheme->Automatic actually implies in a given notebook? $\endgroup$ – Alan Jun 16 '17 at 17:34
  • 1
    $\begingroup$ @Alan That is addressed in (54486) and (66923) -- e.g. Charting`ResolvePlotTheme[Automatic, ListPlot] $\endgroup$ – Mr.Wizard Jun 16 '17 at 17:48

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.