Here we discuss an introduction to Matlab Plot Colors, along with color code table and respective examples. There could be instances when we have to plot multiple functions in a single plot, in such cases, colors become very handy to differentiate between different functions. MATLAB can be used to plot our data for visualizing and intuitively understanding it. Observe in the output that we have obtained a scatter plot of red color, as passed by us in the input argument. Observe in the code that we have passed pre-defined color code for red as an argument (Please refer to the table at the end of the article for pre-defined color codes) The plot gets created as x-y plane flat surface with x and y co-ordinates as vertices (corners) of faces.
You can use those numbers and divide the vector by 255 to use within MATLAB. Usually RGB colors have values from 0 to 255. Observe in the code that we have passed pre-defined color code for green as an argument (Please refer to the table at the end of the article for pre-defined color codes)įor this example, we will scatter plot of red color In MATLAB, pcolor () is the plotting function which is designed to represent the input matrix data in the form of an array of colored cells creating a pseudo color plot. One can specify colors using a vector that gives the RGB triple where in MATLAB, each of the three values are numbers from 0 to 1. Let us first define an array to create a Bar plot: The default line color styles are hard to distinguish and.
How to Set the Color of Bar Plots?įor this example, we will create a bar plot with bars of green color. Matlabs default Jet colormap will obscure real patterns while showing you imaginary ones example. Observe in the code that we have passed pre-defined color codes as arguments (Please refer to the table at the end of the article for pre-defined color codes) How our input and output will look like in MATLAB console?Įxplanation: As we can see in our output, we have got our functions in the colors as passed by us in the input. For more information, see Change Color Scheme Using a Colormap. You can let MATLAB ® control this correspondence, or you can customize it.
The correspondence between the colors and your data values depends on the type of visualization you create. Note: For this example, we will be creating our functions in following colors: 1 st function in Green, 2 nd function in Blue and 3 rd function in Yellow] example: plot(X, a, ‘g’, X, b, ‘b’, X, c, ‘y’) Colormaps are three-column arrays containing RGB triplets in which each row defines a distinct color.