(Type " warning off MATLAB:gui:array:InvalidArrayShape" to suppress this warning.) Markers Warning: Error creating or updating LineStrip So, for example, let’s modify the middle (30%-transparent) red line to something more colorful: (the data values themselves are kept as a 3xN matrix of single values in Edge.VertexData). Then we can modify Edge.ColorData from being a 4×1 array of uint8 (value of 255 corresponding to a color value of 1.0), to being a 4xN matrix, where N is the number of data points specified for the line, such that each data point along the line will get its own unique RGB or RGBA value. The tricky part is to change the Edge.ColorBinding value from its default value of ‘object’ to ‘interpolated’ (there are also ‘discrete’ and ‘none’). If anyone finds a documented reference anywhere, please let me know – perhaps I simply missed it.
In some rare cases (e.g., for patch objects) Matlab has separate Alpha properties that are fully documented, but in any case nowhere have I seen documented that we can directly set the alpha value in the color property, especially for objects (such as plot lines) that do not officially support transparency.
This Alpha element is not documented anywhere as being acceptable, but appears to be supported almost universally in HG2 wherever a color element can be specified. So, for example, means a 70%-transparent red. In other words, color in HG2 can still be specified as an RGB triplet (e.g., to symbolize bright red), but also via a 4-element quadruplet RGBA, where the 4th element (Alpha) signifies the opacity level (0.0=fully transparent, 0.5=semi-transparent, 1.0=opaque). Try GMPDC for yourself you'll be modifying your own startup files before you know it! let us know what you think, or leave a comment for Tim here.In the past few weeks, I discussed the new HG2 axes Backdrop and Baseline properties with their associated ability to specify the transparency level using a fourth (undocumented) element in their Color. In fact, I just added a line to my startup file to set my colororder to be distinguishable_colors(20). Note that the default "colororder" property can be readily modified. I hope this file is a harbinger of more good stuff to come from this author. Tim worked in the L*a*b* colorspace, which was designed to approximate human color perception. That your colors differ from the background, as well as from each other: As a bonus, one can specify a background color as an optional input to ensure Regardless of the number of colors you request. Tim makes it easy to standardize those colors the colors returned by GMPDC are consistent In the past, I've monkeyed about with customĬolor orders I made up on the fly. Sometimes, however, I want to be able to differentiate more than 7 lines or plots.
Isequal(lines(7),get(0, 'DefaultAxesColorOrder')) ans = % and you can verify that they are the same as the repeating sequence in % "lines" with % % You can see the default color order with: By default, MATLAB axes cycle through these seven different colors when plotting lines: One of those, "lines," is a repeatingĪrray of seven distinct colors. MATLAB ships with several built-in colormaps that are useful in different situations. So what does GMPDC do? It provides an easy way to generate distinct, differentiable colors in which to plot a long sequence In fact, I've often considered writing something like this myself-but have never gotten around to it.
(My download was the third.) However, I was excited to see this file, and I know it will come in handy. Maximally-Perceptually Distinct Colors" (GMPDC)-the author's first File Exchange submission (welcome!)-has been downloaded Today, I'm going out on a limb: I'm going to Pick a new file from a new File Exchange author. Brett's Pick this week is "Generate Maximally Perceptually-Distinct Colors,", by Tim Holy.