![]() ![]() 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). There is a great tool on the MATLAB Central File Exchange to generate any number of visually distinct colors, if you have the Image Processing Toolbox to use it.For information on how to change the 'ColorOrder' property and how to set a global default with 'DefaultAxesColorOrder', see the "Appendix" at the bottom of this post.Now, MATLAB alternates through different colours and different line styles using colour as most frequent attribute. The following commands set both colour and line style orders: set(0, 'DefaultAxesColorOrder', ) When a set of colours is exhausted, MATLAB starts from the first colour in the colour order. The following command sets a new colour order to black, red and blue, respectively: set(0, 'DefaultAxesColorOrder', ) Īs you can see, MATLAB alternates only through colours because line style order is set to a solid line by default. To set a new colour or a new line style orders, we call set function with a global handle 0 followed by an attribute DefaultAxesXXXXXXX XXXXXXX can either be ColorOrder or LineStyleOrder. When all line styles and colours are exhausted, obviously MATLAB begins to cycle from the beginning using the first colour and the first line style.įor this example, I have defined an input vector and an anonymous function to make plotting figures a little bit easier: F = -0.2*x(:).^2, a) That means MATLAB will begin to alternate through all colours again but using the next line style in its order. When all colours are exhausted, MATLAB applies the next line style from a defined line style order and set a colour index to 1. ![]() The first change MATLAB applies is a colour. Once we have decided to set a custom colour order AND line style order, MATLAB must alternate through both. We can obtain the default colour order by calling get with a global handle 0 followed by this attribute DefaultAxesColorOrder: > get(0, 'DefaultAxesColorOrder') Therefore, if plot is called to draw multiple lines, MATLAB alternates through a colour order to draw lines in different colours. The new settings remains until MATLAB session is closed or new settings has been made.īy default, MATLAB uses a couple of different colours and only a solid line style. That means new orders will be applied to any figure that is created after these settings have been applied. In MATLAB, we can set new default custom orders, such as a colour order and a line style order. Ordinary Differential Equations (ODE) Solvers.Fourier Transforms and Inverse Fourier Transforms. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |