Colormaps
MATLAB's default colormaps are thought to be overly bright (they print poorly) and are difficult for the colorblind to interpret. Since 5-8% of men and ~0.5% of women are colorblind, it is worth the effort to use better colors for figures in publications and talks. The default colormaps are also (in my opinion) aesthetically unappealing and difficult to interpret quantitatively. Fortunately, good solutions have been elucidated by Light and Bartlein in an EOS paper (PDF), and I feel compelled to share it.
A brief summary of their suggestions is here, and a short table of suggested "good" color schemes is here. Most other plotting routines (NCL, GMT, and so on) have caught on and use divergent schemes by default, but Mathworks appears to have kept the same limited set of colormaps since the stone age.
This matlab package is a good implementation of the ideas in this paper, and is easy to use.
Lastly, for quick tweaks to the brightness of a colormap, use (with a figure open):
brighten(0.5)
brighten(-0.5)
respectively to brighten and darken the color scale.
A brief summary of their suggestions is here, and a short table of suggested "good" color schemes is here. Most other plotting routines (NCL, GMT, and so on) have caught on and use divergent schemes by default, but Mathworks appears to have kept the same limited set of colormaps since the stone age.
This matlab package is a good implementation of the ideas in this paper, and is easy to use.
Lastly, for quick tweaks to the brightness of a colormap, use (with a figure open):
brighten(0.5)
brighten(-0.5)
respectively to brighten and darken the color scale.
Fix Various Figure-Export Bugs
![Picture](/uploads/6/8/0/6/6806886/403122_orig.png?1)
MATLAB occasionally has compatibility issues with certain graphics drivers, and will sometimes save corrupted figures when exporting to eps, png, etc... The problem ranges from a loss of transparency to figures being completely blank to MATLAB locking the system _hard_. I've found a few things to be helpful, particularly with my 2010 Macbook Pro on 10.6:
- Disconnect any external displays while saving the problematic figure (obviously only if you have a laptop).
- Use gfxCardStatus to manually force your laptop to use the integrated (intel) video.
- Try forcing MATLAB to use different painters:
- set(gcf,'renderer','zbuffer')
- set(gcf,'renderer','painters')
- I've found that using these tricks while saving as png using export_fig allows me to keep transparency and save at arbitrarily high resolution. Saving large pngs with the nVidia driver activated would invariably lock things up. Example result:
DYLD_LIBRARY_PATH Fix
In recent versions of MATLAB (R2012a on Mountain Lion, at least), an old dynamic library search tool is still required despite it having been deprecated for some time and apparently completely removed in 10.8. This manifests itself in several ways, but I came across it when saving EPS and Postscript figures using export_fig after upgrading OS X. The problem is that pdftops and ghostscript cannot be run properly as system calls from within MATLAB (even if they work fine from terminal!). The simple (albeit potentially hazardous) fix is:
setenv('DYLD_LIBRARY_PATH', '/usr/local/bin/');
Hopefully Mathworks will fix this ASAP.
setenv('DYLD_LIBRARY_PATH', '/usr/local/bin/');
Hopefully Mathworks will fix this ASAP.
Misc. commands
Move object to top in a figure:uistack(h, 'top')