Colors

Matlab plt

Colors






All the arguments below identified by rgb refer to a color specified in the usual Matlab way, i.e. as a 3 element row vector where each element is between zero and one. However for convenience, you may also use two alternative formats when specifying colors with plt.
  • The first alternative is to specify the color values as percents instead of fractions. For example the Matlab color triple [.23 .45 .67] may also be written as [23 45 67]. Whenever you include a number bigger than one in a color triple, plt assumes that you are using this entry style.
  • The second alternative is to specify the red, green, and blue components as a single number with two digits assigned to each value. For example the color triple shown above could also be written as 234567. For clarity, you may choose to always use six digits by using leading zeros when necessary, although the leading zeros are not required.
Using the second alternative shown above, you might expect that the largest fraction you can enter is 0.99 since only two digits are allowed for each color. However actually you can use 1.00 because the digits "01" (treated as a special case) is interpreted to mean 1.00. This means that you can't specify the fraction 0.01 using this entry method, although that will rarely if ever be a problem. So for example, a TRACEc argument that would specify a 10 color trace sequence using the first 10 colors shown in the default color list below, a concise way of specifying such an argument would be as follows:

plt(...,'TRACEc',[100; 10001;    101; 10000; 206001;
                10101; 16020; 303001; 12060; 200160])



TRACEc

plt(...,'TRACEc',ct);
Specify trace colors. Usually you will have at least as many rows in ct as there are traces, however if ct doesn't have enough rows, plt will start over from the beginning. For example if you specify: TRACEc,[1 0 0; 1 1 0; 1 1 1] then plt will use red, yellow, and white respectively for traces 1,2, and 3. If you had a fourth trace, plt would use red for that trace and continue cyclically. If ct is a single 3 element vector, plt will use that color for all traces. If the TRACEc parameter is not included and color files are not being used (see 'ColorFile' below), then the following default colors are used:

Default (for the first 40 lines):
   [0  1  0;   1  0  1;   0  1  1;   1  0  0;  .2 .6  1;  
    1  1  1;   1 .6 .2;  .3 .3  1;   1 .2 .6;  .2  1 .6;  
   .8  1 .5;  .6 .2  1;   1  1  0;   0 .5  0;  .5  0 .5;  
    0 .6 .6;   0  0 .9;   0 .3 .3;  .5  0  0;  .3 .3  0;  
   .7 .2 .2;  .2 .7 .2;  .3 .3 .3;  .4 .4 .7;   0 .6 .3;  
   .8 .5 .5;  .4 .6 .3;  .5 .5  0;  .7 .7 .2;  .5 .5 .5;  
   .7 .2 .7;   1 .4 .4;  .4  1 .4;  .4 .9  0;  .5 .1 .3;  
   .3  0 .8;   0  0 .5;  .5 .5  1;   0 .3 .8;  .7 .2  0];
You will find a picture showing what these 40 colors look like in the Default colors section.

The defaults for lines 41 to 80 are the same as the colors listed above for lines 1 to 40 except that they are 26% dimmer. The defaults for the lines 81 to 99 are again 26% dimmer than the trace colors for lines 41 to 59. Default colors are defined only for up to 99 traces. If you have more than 99 traces, plt will start assigning colors cyclically as described above.

CURSORc

plt(...,'CURSORc',rgb);
Specify the cursor color. Here, and on the rest of this page,rgb must be a 3 element row or column vector.

Defaults:
    Only one trace (dark plot backgrounds): [1 1 .5]
    Only one trace (light plot backgrounds):  [0 0 .5]
    More than one trace:     Cursor color is set to match trace color

DELTAc

plt(...,'DELTAc',rgb);
Specify color indicating the delta cursor.
Default: [1 0 0]

PltBKc

plt(...,'PltBKc',rgb);
Specify the plot area background color.
Default: [0 0 0]

FigBKc

plt(...,'FigBKc',rgb);
Specify the figure window background color.
Default: [.25 .15 .15]

xyAXc

plt(...,'xyAXc',rgb);
Specify the color of the x and y axes.
Default: [1 1 1]

xyLBLc

plt(...,'xyLBLc',rgb);
Specify the color of the x and y axis labels.
Default: [.64 .78 .94]

GRIDc

plt(...,'GRIDc',rgb);
Specify the color of the grid lines. (See also GridStyle.) Normally the grid lines are drawn in exclusive-or erase mode, however if any of the rgb values are negative (e.g. 'GRIDc',[0 -.2 .4] ), then the grids are drawn in normal mode (which is often preferable especially if the right hand axis is not being used). The actual grid color used in the above example is [0 .2 .4]).

Default:
If no right hand axis is enabled then the default is [-.13 .13 .13] i.e. a very dim gray line using normal erase mode. (The grid lines will be solid unless the GridStyle parameter is included). If a right hand axis is enabled the defaults (again assuming that the GridStyle parameter is not specified), depend on the Matlab version. For Matlab versions earlier than R2014b the default GRIDc is [.13 .13 .13], and the default GridStyle is - i.e. a very dim solid gray line drawn using xor erase mode. For Matlab version R2014b or later the default GRIDc is [-.26 .26 .26], and the default GridStyle is : i.e. a dim gray dotted line in normal erase mode (which actually is the only erase mode supported in the newer Matlab versions).

The defaults described above apply only if a very dark plot background is being used, including of course the default plot background (black). If a bright background has been selected (by using either the 'PltBKc' or 'COLORdef',0 parameters) then the defaults above are inverted (i.e. subtracted from one). These defaults may sound complicated but they have been chosen to be pleasing to most people under the various circumstances.

TIDc

plt(...,'TIDc',rgb);
Specify the background color of TraceID box.
Default: If this parameter is not included, the color specified by the PltBKc parameter (or its default) is used.

COLORdef

plt(...,'COLORdef',c);
Sets the PltBKc, FigBKc, xyAXc, and xyLBLc colors mentioned above to be consistent with Matlab's current default colors.
Trace colors are set as follows:

c = 0 or 'default' Matlab's current default trace colors are used.
i.e.  TRACEc = get(0,'DefaultAxesColorOrder')
c is a 3 column array c is used instead of Matlab's default trace color order. Note that you may use the traditional Matlab color triple entry or one of the alternate styles described above. The example program subplt8.m demonstrates how to use both the traditional and alternate color entry styles for this argument.
c is a 3 column array with a special first entry [.99 .99 .99] The special case for the first entry (which is 999999 if using the alternate style) means that the remaining colors in the array will be appended to the current Matlab default trace colors. This is useful if you like Matlab's default colors, but the color sequence is not quite long enough and you just want to add a few colors to that sequence.

If TRACEc so defined has fewer rows than the number of traces to be plotted the colors will be used cyclically as described above.

ColorFile

plt(...,'ColorFile','filename');
The normal behavior of plt (i.e. when the ColorFile argument is not included) is as follows.
  • If plt is called from the Matlab command line, when plt initializes it looks for a file called pltcolor.mat in the folder where you installed plt. If this file isn't found, no action is taken. If it is found, the file is loaded causing all the default colors and the colors specified by all the other parameters shown on this page to be overwritten with the data saved in the .mat file. When you select the "Save figure colors" selection under the Color menu, plt saves the current colors to this same file (pltcolor.mat).
  • If plt is called from a Matlab function or script file, the behavior is similar except that the file name used is fnameColor.mat where fname is the name of the top level Matlab command or script. Again, plt looks for this file in the folder containing the .m file defining fname (or in the folder containing the fname.exe file for compiled applications).
When the 'ColorFile' parameter is included in the plt argument list, the above behavior is modified as follows:

'ColorFile','filename' If the filename is specified without any path, plt uses the specified file name both on startup (to load the color scheme) and when "Save figure colors" is selected. plt looks for this file in the folder containing the .m file defining fname (or in the folder containing the fname.exe file for compiled applications). The extension used is always .mat and you may not include an extension or a period in the filename string.
'ColorFile', 'drive:\path\filename' As above, plt uses the specified file both on startup (to load the color scheme) and when "Save figure colors" is selected. However when path information is supplied, plt will look for the file only in the location given. As before, you may not include an extension in the filename string
'ColorFile','' plt will use its default colors, and any colors specified by the other parameters in this section. A color file will never supersede them on startup, even if fnameColor.mat exists. If you select "Save figure colors", plt will allow you to save the current colors to any file of your choosing (by opening a file selection box), but these colors will not be loaded unless you change to one of the above 'ColorFile' options, or remove the 'ColorFile' parameter altogether.