

Matlab plot colors plus#
It is possible to specify color, line styles, and markers (such as plus signs or circles) when you plot your data using the plot command:Ĭolor_style_marker is a string containing from one to four characters (enclosed in single quotation marks) constructed from a color, a line style, and a marker type: To get the default ColorOrder for new axes, get(0,'DefaultAxesColorOrder')Įxample of setting new global ColorOrder with 10 colors on MATLAB start, in startup.Specifying Line Styles and Colors :: Graphics (Getting Started) Getting Started To get the ColorOrder RGB array used for the current axis, get(gca,'ColorOrder') Set(ha,'ColorOrder',mpdc10) % - set ColorOrder HERE.

The process is simplified, requiring no for loop, with the ColorOrder axis property: Mpdc10 = distinguishable_colors(10) % 10x3 color list For example, to generate 10 "maximally perceptually-distinct colors" and use them for 10 plots on the same axis ( but not using ColorOrder, thus requiring a loop): % Starting with X of size N-by-P-by-2, where P is number of plots The default ColorOrder array contains seven colors. The ColorOrder property contains an array of RGB triplets, where each RGB triplet defines a color. Of course, you can set the ColorOrder for a single axis or simply generate a list of colors to use in any way you like. MATLAB assigns colors to plot objects (such as Line, Scatter, and Bar objects) by cycling through the colors listed in the ColorOrder property of the axes. They even made the excellent suggestion to set MATLAB's ColorOrder on startup to, distinguishable_colors(20) The GMPDC submission was chosen on MathWorks' official blog as Pick of the Week in 2010 in part because of the ability to request an arbitrary number of colors (in contrast to MATLAB's built in 7 default colors). Given an initial large list of possible colors, it iteratively chooses the entry in the list that is farthest (in Lab space) from all previously-chosen entries.įor example, when 25 colors are requested:

Specify the colors at those vertices to make the faces red. Four of the nine vertices determine the colors of the faces. Create matrix C that maps the colormap colors to the nine vertices. This function generates a set of colors which are distinguishable by reference to the "Lab" color space, which more closely matches human color perception than RGB. Create coordinate vectors X and Y and a colormap called mymap containing five colors: red, green, blue, yellow, and black. It is best described in the author's own words: For 10 plots, you obviously cannot rely on the default ColorOrder.Ī great way to define N visually distinct colors is with the "Generate Maximally Perceptually-Distinct Colors" (GMPDC) submission on the MATLAB Central File File Exchange. However, by default MATLAB only specifies a short list of colors ( just 7 as of R2013b) to cycle through, and on the other hand it can be problematic to find a good set of colors for more data series.
Matlab plot colors how to#
The ColorOrder axes property allows MATLAB to automatically cycle through a list of colors when using hold on/all (again, see Appendix below for how to set/ get the ColorOrder for a specific axis or globally via DefaultAxesColorOrder).
