Matlab Tip: Change the color-scheme to be easier on your eyes

Screen Shot 2013-02-08 at 1.01.07 PMHey Matlab users, here's a quick tip that I hope is helpful.  If you stare at MATLAB for long hours, espically late at night, then changing your color scheme is a quick an easy way to reduce eye strain (and maybe help you sleep better).

Our eyes never evolved to stare at a bright white light all day, and research shows that looking at bright light before going to bed is bad for sleep.

Screen Shot 2013-02-12 at 3.37.59 PMJust head to "Matlab-> Preferences" and select the colors menu to get started!  I prefer a green text on a dark background, but even a sepia background will be easier on the eyes than Bright White.  A great scheme is called "Solarized" which you can set MATLAB to match.  It offers a warm look that looks great with dark or light backgrounds. A great thing about this theme is when switching from Dark to Light backgrounds, you don't need to change any of the other colors: They're designed to look good on both backgrounds.

To change the colors via the terminal, you can use commands outlined in another cool MATLAB blog.  To get you started on the Solarized color scheme that I like, use:

com.mathworks.services.Prefs.setBooleanPref('ColorsUseSystem',0);
com.mathworks.services.Prefs.setColorPref('ColorsBackground',java.awt.Color(7/255,54/255,66/255));
com.mathworks.services.Prefs.setColorPref('ColorsText',java.awt.Color(133/255,153/255,0/255));
com.mathworks.services.Prefs.setColorPref('Colors_M_Comments',java.awt.Color(181/255,137/255,0/255));
com.mathworks.services.Prefs.setColorPref('Colors_M_Keywords',java.awt.Color(38/255,139/255,210/255));
com.mathworks.services.Prefs.setColorPref('Colors_M_Strings',java.awt.Color(42/255,161/255,152/255));

(Note: You'll have to restart Matlab after running these commands for them to take effect)

Related Posts:

This entry was posted in Uncategorized and tagged , , , , , . Bookmark the permalink.
  • ThSGM

    Dear Mike,

    Thank you for the tip to create a dark color scheme. Did you know that when your editing window contains cells, i.e. multiple parts separated by double %%, then the background color is the usual Matlab beige? Do you know how this is fixed?

    Thanks!

    • mrsoltys

      Hey,
      Yeah I do know how this is fixed:
      when you go to the matlab preferences, the Colors menu has a drop-down. Under it there is an option Programming Tools. If you select that, you can adjust the color selection under "Selection Display" highlights or disable this feature by unchecking the box.

      Screenshot

  • suvir

    really useful theme. Thanks for the tip.

  • Alexey

    Mike, thank you for the post!
    It helps me to find a more elegant solution by another man for "solarizing" code colors in Matlab - https://github.com/wme7/aero-matlab/blob/master/setupEditorColors.m .
    Don't run it untouched!
    Or you lose your nice color scheme, that can be saved with some more coding as .mat file for example.

  • puffin

    Thanks Bro, that's really helpful!

  • Andre

    Thanks for the tip !

  • Patricio Parada Gutiérrez

    Thanks for the post!