

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) 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 Let us first define an array to create a Bar plot:
Matlab plot colors how to#
How to Set the Color of Bar Plots?įor this example, we will create a bar plot with bars of green color. 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. You can learn more about this topic at matwork.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’) Use the following code to try it out x = -pi:pi/10:pi 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. The axes are counted along the top row of the Figure window, then the second row, etc. plot(x, y) plot x and y using default line style and color plot(x, y. H = subplot(m,n,p), or subplot(mnp), breaks the Figure window into an m-by-n matrix of small axes, selects the p-th axes for the current plot, and returns the axes handle.

Subplot helps have plots side by side on the same sheet. Plot(x,y2,'b','LineWidth',2) Matlab subplot One of the many ways to plot multiple functions on the same plot is to use hold on or insert the corresponding equations in the plot code. The Graph Plotting multiple graphs on the same plot Here is another example which you can learn a lot from Here is how to change the thickness of the line of your plot in Matlab
Matlab plot colors plus#
point o circle x x-mark + plus * star s square d diamond v triangle (down) ^ triangle (up) triangle (right) p pentagram h hexagram - dashed. ( You can get that information with help plot) Then, it cycles through the colors again with each additional line style. plot cycles through the colors with the first line style. MATLAB can be used to plot our data for visualizing and intuitively understanding it. Here is the code you can use to change the line style. plot uses colors and line styles based on the ColorOrder and LineStyleOrder properties of the axes. Let’s go ahead a plot the following code x=-100:0.5:100 This function creates an Nx3 array of N R B G colors.

It is based off the research of professor Cynthia Brewer (colorbrewer) but amazingly easy to use. This function creates distinguishable colors by spacing them out equally in perceptive space, not in RGB space. Just like it is to change the color of your plot in Matlab, the same goes for changing the line style, increasing the thickness of the line or some other aspect of it The default Matlab default line spec and colormaps are astoundingly crude. You must surely have grasped how to add the color code to get your graph to the wanted color, and notice at the beginning of this post the different color and code you can make use of while using this technique Matlab plotting line style Let’s twist the code a little to change the plot color
