Graphics |
Specifying Axes Colors
The default axes background color is set up by the colordef
command, which is called in your startup file. However, you can easily define your own color scheme.
See InvertHardCopy for information on how MATLAB automatically changes the color scheme for printing hardcopy.
Changing the Color Scheme
Suppose you want an axes to use a "black-on-white" color scheme. First, change the background to white and the axis lines, grid, tick marks, and tick mark labels to black.
Next, change the color of the text objects used for the title and axis labels.
set(get(gca,'Title'),'Color','k') set(get(gca,'XLabel'),'Color','k') set(get(gca,'YLabel'),'Color','k') set(get(gca,'ZLabel'),'Color','k')
Changing the figure background color to white completes the new color scheme.
When you are done, a figure containing a mesh plot looks like the following figure.
You can define default values for the appropriate properties and put these definitions in your startup.m
file. Titles and axis labels are text objects, so you must set a default color for all text objects, which is a good idea anyway since the default text color of white is not visible on the white background. Lines created with the low-level line
function (but not the plotting routines) also have a default color of white, so you should change the default line color as well.
To set default values on the root level, use.
set(0,'DefaultFigureColor','w' 'DefaultAxesColor','w',... 'DefaultAxesXColor','k',... 'DefaultAxesYColor','k',... 'DefaultAxesZColor','k',... 'DefaultTextColor','k',... 'DefaultLineColor','k')
MATLAB colors other axes children (i.e., image, patch, and surface objects) according to the values of their CData
properties and the figure colormap.
Colors Controlled by Axes | Axes Color Limits - The CLim Property |