File Exchange Pick of the Week

Our best user submissions

What’s Your Color Scheme? 5

Posted by Brett Shoelson,

Brett‘s Pick this week is MATLAB Schemer, by Scott Lowe.

Contents

Easy manipulation of your MATLAB color scheme!

I’m curious: what color scheme do you use when you write code in MATLAB? Do you stick with the default, or have you customized the colors in your editor? And are those of you who use Linux more likely to use light text on a dark background than are those of use who work in Windows?

MATLAB is customizable!

Did you know that you can easily change the colors of your text in MATLAB? In the Preferences dropdown from the Home tab, you can specify the colors of text, background, keywords, strings, comments, errors, hyperlinks, warnings, etc. Check out: Preferences->Colors to see what I mean:

If you want to change the defaults for any reason–to mitigate eye strain, to help with color-blindness issues, or just to create a more pleasing environment, you can do that! (And if you like the defaults, you can keep them, too!)

I confess: I have been using MATLAB for so long that the default color scheme seems “right” to me, with one exception. Since I often share my screen with others, I find that the default pale yellow for section highlighting doesn’t work well for me, and I have changed mine in my preferences to be a light cyan; I think it’s easier to see.

That said, the ease with which I can change my color schemes using Scott’s “Schemer” code has me rethinking my preferences…. or at least, considering alternatives. To start, I Googled “preferences for coding color schemes,” and found lots of discussions about the topic. Many people indicated that they liked the “monokai” scheme. So I simply executed the command:

schemer_import

and launched a file selector. Browsing to Scott’s directory of pre-saved schemes, I selected “monokai.prf,” and voila! my text changed to white on a black bacground; strings changed to a pale yellow, highlights changed to blue,…. you get the point!

Scott provided “monokai” and about 10 other color schemes.

If you’ve spent any time customizing your own, please remember to save them:

schemer_export

before you change things!

This is very useful, though; I get to kick the tires before I buy the car, and I can easily return the car after I’ve bought it if I decide that I don’t like it!

Very nice work, Scott! (It’s evident that many others agree; Schemer has been downloaded 35,000 times [as of this writing]–including nearly 1400 downloadsthis month–and has 213 ratings averaging 5 stars [out of 5]!) Outstanding!

As always, I welcome your thoughts and comments.

Get the MATLAB code

Published with MATLAB® R2019a

Note

Comments are closed.

5 CommentsOldest to Newest

Ander Biguri replied on : 1 of 5
The schemer is great! However it has a drawback, and its not Scott's fault. I dare to say that most users want to it set up a dark scheme. However, there are a lot of things that can not get the color changed, such as the line numbers in the scripts, or side bars, and generally all the frames around all the objects in the GUI. This means that while you can set up a dark scheme, they are quite ugly, and I personally find the white borders distracting, comparing to most of the other profesional text editors in the market. Request to MATLAB: let us change the color of those things too! the MATLAB GUI is great, but needs some updating!
Brett Shoelson replied on : 3 of 5
@Ander: Very good feedback--thank you! I have shared it with our Development team. Brett
Yair Altman replied on : 4 of 5
Scott's utility is excellently written (in terms of functionality, documentation and code quality) and has an almost-perfect review rating of 5.00 from over 200 reviewers - this feat is quite extraordinary in the File Exchange and worth mentioning separately. Few File Exchange authors have posted utilities that have such a near-perfect rating from so many independent reviewers. It is also another example of utilities originally posted on GitHub and reported on File Exchange (there are too few of these, unfortunately). Kudos are well in order. That said, users should be aware that Scott's utility is based entirely on undocumented aspects, namely the preservation of color settings in the matlab.prf file, and the Java classes and methods that process them. My cprintf utility also relies on these features, which I originally published in 2009 - http://undocumentedmatlab.com/blog/changing-system-preferences-programmatically [Scott references this post in his utility], as well as in my blog's very first post: https://undocumentedmatlab.com/blog/changing-matlab-command-window-colors. I find it refreshing to see that increasingly in recent years you are not shying away from highlighting utilities that rely on undocumented features, as long as they provide added value to users, as Scott's utility evidently does. The number and quality of independent reviews clearly shows that many users find such utilities enormously useful. It is amazing, and to MathWorks' credit, that such undocumented features have remained working for over a decade. However, they may well stop working at any upcoming Matlab release. So I believe that at the very least, a corresponding warning to this effect should be posted for the benefit of users. With such a warning notice, users will not complain to MathWorks when these undocumented features will [one day] eventually break. I have already seen indications of this, with settings in the legacy matlab.prf file (including the color settings that Scott's utility uses) being duplicated [presumably as a precursor to being replaced in the near future] by XML settings in the matlab.settings file, both of them located in the user's prefdir folder. So caveat emptor...
Brett Shoelson replied on : 5 of 5
@Yair, Thanks for the note, Yair. Truth be told, I didn't look at Scott's code before I "Picked" it; I was focused on the functionality instead. (You know that we typically try not to pick submissions that rely on undocumented MATLAB, as they are not guaranteed to work in some future version.) So...yes, caveat emptor... Brett