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 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. 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: 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. 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. 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).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |