kit
kit

Reputation: 83

Matlab Plot with Customize color

does anyone know what's the command or way to plot with different colors besides the preset color, i.e., b,g,r,c,m,y,k? I would prefer to use my own customize colors instead of these....

Cheers

Upvotes: 8

Views: 63413

Answers (3)

edison1093
edison1093

Reputation: 23

I had the same problem with the limited set of preset colours MATLAB made available. So, I created this page on my website, where you can choose from a large palette of non-standard colours, and the colour code is pasted directly to your clipboard:

http://www.shirt-ediss.me/matlab-octave-more-colours/

Upvotes: 0

You
You

Reputation: 23824

Use the Color property with a ColorSpec triple:

plot(x, y, 'Color', [0.5, 1.0, 0.0], 'LineStyle', '--')

The vector here contains RGB values between 0.0 and 1.0. The Lineseries and ColorSpec documentation entries have more information about this.

Upvotes: 15

Isaac
Isaac

Reputation: 3616

From the matlab docs:

ColorOrder: m-by-3 matrix of RGB values

Colors to use for multiline plots. Defines the colors used by the plot and plot3 functions to color each line plotted. If you do not specify a line color with plot and plot3, these functions cycle through the ColorOrder property to obtain the color for each line plotted. To obtain the current ColorOrder, which might be set during startup, get the property value:

get(gca,'ColorOrder') Note that if the axes NextPlot property is replace (the default), high-level functions like plot reset the ColorOrder property before determining the colors to use. If you want MATLAB to use a ColorOrder that is different from the default, set NextPlot to replacechildren. You can also specify your own default ColorOrder.

All together, this means you want the commands:

figure();
axis();
set(gca, 'colororder', <color matrix>, 'nextplot', 'replacechildren');
plot(x,y);

Upvotes: 0

Related Questions