

Or without the for, better: load spectra.mat Īll them unfortunately prior the plotting. Answers (1) Brendan Hamm on 5 Link One thing you could do is just change the ColorOrder property of the axes itself: Theme Copy f figure colors 0 0 0.7 0.7 0 0 0 0 0 0 0.7 0 0 b,r,k,g a axes ('ColorOrder',colors) plot your lines and they will be plotted with these colors in order. I have a plot with 4 different colors, and I want to change the green (light green) to deep green, so it would be like: plot (x,y,color, 0 0.7 0) if m 1 color. Title('Near Infrarred Spectra for Gasoline Samples') Changing color of plot when value is increasing Hi, I need to make plot that has two colors of line red and blue, and the line should be red when value is increasing and blue when value is decreasing and when I use dotted line it works 'b' but without this it doesn't work 'b' I think I should define first point of plot but I'm not sure.
#CHANGING PLOT COLOR MATLAB CODE#
This is pseudocode which will not run if you don't have t, x and c defined.ĭata, and the code shown here, cooked, just ready for you: load spectra.mat Update: Matlab 6 and above includes the SCATTER function, which does the job (in a similar way). Trivially, and ignoring most -if not all- performance etiquette, through a for call you can set colours while building a plot, plotting each column inside the loop, and setting/applying the colormap 'on the fly', just as suggested by the pointed post, but which is not the question: for i=1:n X linspace (-2pi,2pi) a sin (X) b cos (X) Defining 100 equally distant points Defining our first function: sin function Defining our second function: cos function Note: For this example, we will be creating our functions in the following colors: 1 st function in Green and 2 nd function in Blue. Using Basic Colors in Graphs Changing Colors Using RGB triplets to change colors Changing colors in 3D Graphs m-file that created this page BACK TO MAIN PLOTTING PAGE This document gives BASIC ways to color graphs in MATLAB.

Following this, i've plotted a matrix of signals t (m by 1) and x (m by n): plot(t,x) Īnd, after that, i am wishing to apply a coloured scheme on colormap matrix c (n by 3).
