3
$\begingroup$

I am currently looking for a stylesheet in a black theme that still has high contrast for graphics/plots and similar. Preferably it should also change the menu to a darker color. It preferably should also highlight the cells better.

I am working on computational physics problems that can sometimes take a lot of time and the white is quite painful after a bit but dark theme and dracula theme are simply not good for showing graphs. Sadly I do not know how to edit stylesheets but hopefully someone else already made one.

$\endgroup$
1
  • $\begingroup$ Thanks for accepting the answer. I should add that there are at least 2 init files, a kernel one and a front end one. I never modified the front end init file, modifying the kernel one with the SetOptions commands below should work. $\endgroup$ Nov 28, 2022 at 23:43

1 Answer 1

3
$\begingroup$

Outline

  • Stylesheets

  • Graphics visualization (Plot, Graph, Dataset, etc) modifications

  • FrontEnd modifications


Stylesheets:

Consider perhaps the links below :

https://resources.wolframcloud.com/FunctionRepository/search/?i=stylesheet

I tried the dracula theme and indeed the contrast is not good for graphs. DarkMode in https://resources.wolframcloud.com/FunctionRepository/resources/DarkMode/ looks better with graphs

(did not try this one) https://github.com/search?q=mathematica+stylesheet

Graphics visualization (Plot, Graph, Dataset, etc) modifications

For Print:

Use instead

print = Print[Style [#, White]] &

Or whatever color you like

For Plot and Graphics:

You can get the current background color with:

Note: ⎵=\[UnderBracket]

background⎵color = 
  If[CurrentValue[EvaluationNotebook[], Background] === None, White, 
   CurrentValue[EvaluationNotebook[], Background]];

If you want optimal contrast you can choose the font color to be the opposite of that color:

print⎵color = ColorNegate@background⎵color;

Then you can modify the options of Plot and Graphics:

SetOptions[#, AxesStyle -> print⎵color, 
    Background -> background⎵color, 
    BaseStyle -> print⎵color] & /@ {Plot, Graphics};

Note : BaseStyle in Plot changes the default color of curves, consider changing that to whatever you prefer. You might also want to change it in Graphics.

Note : Consider including ListPlot, ListLinePlot, ListLogPlot etc to that list.

You might want to change some of the options. You can check:

Options[Plot]//Association //Dataset

for example to see the options of Plot and change them as you want. If you want to use your own visualization you can use

Options[Plot]

then use whatever you want like Column for example

For DataSet:

The functions to customize Dataset were introduced in version 12.1.

One option you can change is :

SetOptions[Dataset, 
  HeaderBackground -> background⎵color];

See Options[Dataset] for other options.

For Graph

If you generate a graph directly with Graph then you can use:

SetOptions[Graph, VertexLabelStyle -> print⎵color, 
 Background -> background⎵color, 
 BaseStyle -> print⎵color]

However that will not affect the options using other functions that output a Graph like RandomGraph. You might want to use the options above for each graph function considered.

How to make the changes permanent

If you want these option changes to Plot etc to be permanent then you might have to change your init file. It might be best to hardcode the color choice rather than using CurrentValue[EvaluationNotebook[], Background] in the init file.

FrontEnd modifications

To remove some of the bars that might be a different color than your style sheet see this answer:

Note : See also the comment for how to revert back

https://mathematica.stackexchange.com/a/101062/86543

If you use Linux you can change the color of the menu with:

How to customise the appearance of the menubar and scrollbar on Linux?

My interface after slightly modifying DarkMode (linked in the stylesheet section) and changing the Qt file:

enter image description here

Not sure about my choice to use purple but it makes sense with my desktop theme.

I used this Qt configuration (I kept the popup menu for searching for files the same as I did not know how to control the colors well):

QScrollBar:vertical {
  background: black;
  width: 20px;
}
QScrollBar::handle:vertical {
  background:  #03a9f4;
  min-height: 0px;
}
QMenu {
  background-color: #03a9f4; /* sets background of the menu */
  border: 1px solid black;
  color: white
}

QMenu::item {
  /* sets background of menu item. set this to something non-transparent
        if you want menu color and menu item color to be different */
  background-color: transparent;
  color: white
}

QMenu::item:selected {
  /* when user selects item using mouse or keyboard */
  background-color: #bd15f4;
}

QMenuBar {
  background-color: black;
  spacing: 3px; /* spacing between menu bar items */
  color: white
}

QMenuBar::item {
  padding: 1px 4px;
  background: transparent;
  border-radius: 4px;
  color: white
}

QMenuBar::item:selected {
  /* when selected using mouse or keyboard */
  background: #a8a8a8;
}

QMenuBar::item:pressed {
  background: #888888;
}


* { font-size:16pt; font-family:"Griffy" }


Note:

If you are willing to accept loosing a lot of the functionality of the front end of Mathematica consider also using Jupyter or VScode with the Wolfram Kernel and use a dark theme. See my answer here : https://mathematica.stackexchange.com/a/274441/86543 for pictures of a dark theme with Jupyter and VScode

$\endgroup$

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.