

Note that this function allows you to input either a string of characters or an N-by-3 numeric or logical array (with RGB values from 0 to 1 or 0 to 255) and it returns the opposite color representation. 'Input must be a character or numeric array.') 'RGB input must define one of the colors ''rgbcmywk''.') Share Follow answered at 18:33 You 22. RGB color has a range 0 255 for each of the 3 colors (red/green/blue) each color is divided by 255 to keep it within the 0 1 range that MATLAB requires in. The Lineseries and ColorSpec documentation entries have more information about this. InColor(scaleIndex,:) = inColor(scaleIndex,:)./255 %# Scale by 255 3 Answers Sorted by: 15 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. Lets see an exemple considering only one. You can use those numbers and divide the vector by 255 to use within MATLAB. So currently I have 'y-' but again I dont want to use yellow 0 Comments Sign in to comment. Usually RGB colors have values from 0 to 255. How can I make my own color I also want this line to have asterisks along it. ScaleIndex = max(inColor,2) > 1 %# Find rows with values > 1 It consist of a table of 64 RGB different colors associated from the maximum value (red) to the minimum one (blue). 1 Link Moved: Image Analyst on Accepted Answer: Chad Greene I have 7 lines on a single plot.

InColor = double(inColor) %# Convert input to type double Estos colores no tienen nombres asociados con ellos. 'Numeric input must be an N-by-3 matrix') A continuacin, se indican los tripletes RGB y los cdigos de color hexadecimales de los colores predeterminados que MATLAB utiliza en muchos tipos de grficas. In MATLAB we use pre-defined color codes to get plots of desired colors. 'String input can only contain the characters ''rgbcmywk''.') Įlseif isnumeric(inColor) || islogical(inColor) %# Input is a numeric orĪssert(size(inColor,2) = 3,'convert_color:badInputSize'. The official color for Loyola Green is given as RGB:0-104-87, and Loyola Gray. = ismember(inColor(:),charValues) Īssert(all(isColor),'convert_color:badInputContents'. If ischar(inColor) %# Input is a character string Enter your values in either form, as shown in the. RgbValues = Īssert(~isempty(inColor),'convert_color:badInputSize'. Direct RGB Open the Command Window (Window: Command Window) or Script Window (Window: Script Window). 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.

single characters): function outColor = convert_color(inColor) If you're only concerned with conversions for the default 8 color strings, here's a function I wrote myself that I use to convert back and forth between RGB triples and short color names (i.e. I found this general alternative on the MathWorks File Exchange which will even handle color strings other than the default 8 in MATLAB:
