Solution: Colormap missing during MATLAB figure export to Illustrator

I usually export my MATLAB figures to Adobe Illustrator .AI format. However, I have noticed that if my figure contains a colorbar, the colormap is blank when I open the AI file in Illustrator.

To fix this, I found that you can instead save the figure as an EPS file (*.eps, standing for Encapsulated PostScript). This file can be opened in Illustrator, and still contains all the layer and path information I need.

Another useful trick I use before exporting a figure with colormaps is to increase the step size of the colormap. By default, the colormap contains 64 colors, but you can usually see the edge between each color. To smooth out the colormap, I like to use:

colormap(gray(256))

This tells the colormap to use 256 colors instead of only 64. Of course, the colormap gray can be replaced by any other colormap name, e.g., hsv or jet.