What is MATLAB Color Plot?
Table of Contents (click to navigate)
- Introduction to the MATLAB Plot Function
- What is MATLAB Color Plot?
- Tutorial: MATLAB Color Plot Function
Introduction to the MATLAB Plot Function
In the world of mathematics, science and engineering, the graphical representation is key to successful presentations. If you loved coloring in your heyday as a child, then this is the grown and sophisticated version of that experience. Everything ultimately starts with a dream, and an innate curiosity and passion. Let’s project that feeling into today’s tutorial on the MATLAB Plot Function. Let us suspend reality, suspend our logical minds, and simply tap into that intuitive creative side, which often gets suppressed in a scientific and engineering frame of mind.
As humans, (and maybe a sentient robot might read this one day), our minds are visually driven. Therefore it is absolutely critical that any work that we do, is presented in a way that is appealing to our target audiences. In this tutorial, once we start exploring the possibilities that exist in the world of MATLAB, you will realize the potential that exists for your current research or analytical activities.
As a refresher, we will begin with the basics of the mathematical functions that form the graphs that are generated by the background MATLAB matrix-based algorithm. Usually, in mathematics, science, and engineering, the analyst would like to know what the relationship is between one or more independent variables, and a final resultant output or dependent variable. This function, usually defined as f, is defined as a set of ordered pairs or triplets of the dependent and independent variables. When a pool of data, utilizing the same function is pooled, the entire data set is known as the domain of that function.
When the relationship between the dependent variable and dependent variables is graphically represented, two and three-dimensional graphs can be generated by the MATLAB system. The beauty of MATLAB, is that you’ll be able to generate beautiful images like the starting image of this article. Not only that, but as a controller, you’ll be able to determine what the color scheme of the figure, and the associated figure auxiliaries that you would like to focus on…should be. This is the classic case of color by number, except in this instance it will be relevant for you to know the code which enables the color-coding.
MATLAB has harnessed the ability to facilitate the plotting of various lines from straight lines, curves and three-dimensional graphical outlays. During this tutorial, the 3-D plot will be the plot of focus. It will allow us to utilize the color plot function, which is the primary focus of the discussion. The image above is a surface plot, identifying a progression in a system model. Three variables – x, y, z all are changing with time. The MATLAB GUI, facilitated a simultaneous plot of these changes in 3-Dimensional space, thereby allowing the user to see how best the different variables are moving in time. With the various color manipulations, we will enable MATLAB to differentiate the different segments, and allow the visual appeal to be grammaticized. In all things that we do, we need to stand out, so learning how to ensure that your graphics are the top of the line, will ensure that you get noticed not only as an analyst, but as an expert in your field
Mathematics, science, engineering and engineering are so diverse, yet they all share the need to present data in a way that the mind can readily absorb via graphs and trends. With anything from the process dynamics of a chemical reaction, to the electrical flow through a motherboard, to population fluxes used to calculate insurance premiums, graphs will help to identify opportunities for gains in a system.
Now that you’re excited to plot graphs and relay your newly found skills, let us jump into the theory of MATLAB.
What is the MATLAB Color Plot Function?
The MATLAB Color Function is denoted predominantly by the syntax outlined below. MATLAB as a command center gives the user control, in order to enable them to determine color changes in graphical outputs that represent systems that are being modelled. MATLAB utilizes the following codes for enabling the user to manipulate the graph’s colors. The most commonly used syntaxes are:
For the sake of understanding, let us briefly define the first two of these functions.
colormap(map) MATLAB has a built in library of colors including hue ranges such as bone, autumn and copper. The colormap is the body of colors in a collection that will be used by the system in order to represent the changes in the progressions of the 3-D plot. It is focused primarily on the figure itself. This function determines what the color range will be, and MATLAB will coat your image in the desired hues.
colormap(target,map) Once the graph itself is plotted, the relevant color map application can be specified for the auxiliaries of the graphical figure as well as the figure itself.
Let us now apply the principles to our MATLAB environment!
Tutorial: MATLAB Color Plot Function
As with all projects, we will start our tutorial off with a fresh MATLAB command page. The version used for this tutorial is the R2019a. Now that we’re excited about the possibilities of graphing, and the associated color changes we will conduct a series of attempts as a means for introducing more the advanced possibilities in the color mapping of the MATLAB system.
When a graph is plotted, one of the critical questions to ask ourselves, is whether or not the current color scheme is one that we are satisfied with. The basic code for MATLAB for a surface curve is highlighted as follows:
The first line of code is the graph data, while the second line of code is the color map. MATLAB has a library of about twenty color maps that you can use to determine the color scheme of your project. Searching their database at the referenced link will provide you with the finer details of the plot hues.
The MATLAB system with the code entered into the GUI is shown below:
MATLAB also automatically generates the relevant output, in a separate figure. This figure is outlined below. As you can see, the color scheme bone is a greyscale that that facilitates the peaks and the troughs being shaded and highlighted in order to clearly show the dimensions of the graph.
Bone is ideal for instances such as writing a research article, or in instances where there’s a need for a monochrome presentation. Usually, the more mature you are, is the more you want more peace and quiet. If you’re into the more exciting flows, you can change the colormap in the code above to winter or some other hype and exciting color to give the same graph, but different flavor below:
If you’re presenting to some venture capitalists, the progress of your reports, this second graph is the one you’d want to opt for! It has more pizzazz…and just the high energy that is needed to capture the minds and eyes of your target audience. I’m sure once you start plotting…that the hue winter will be among your favorites!
As a summary for the first example, the MATLAB system enables the user to have the ability to generate a multitude of options for the color map. As long as you the user identifies the color series, you will be able to have the graph be displayed in that fashion. With the initial color-changing skills under our belts, let us take the time to ensure that we are in a position to facilitate the color changes for different aspects of the figure.
If you are in a position where you desire to change the color scheme of twin plots, you can use a simple example. One way to learn code is to modify that which exists and find the segments that you want to manipulate. Using modified code from the MATLAB system, the following will be entered into the Command Center. The changes for this example were in the third line of code. The colormaps were modified to prism and spring. Since MATLAB has a baseline programming aspect, you’ll be able to find the code needed for your relevant application. You don’t always have to re-invent the wheel.
ax1 = subplot(2,1,1);
ax2 = subplot(2,1,2);
The code entered into the R019a user interface is highlighted below:
The twin plots are highlighted below after MATLAB works its magic:
As you can see, the graphical output is as desired. As you can see from the above, with respect to the peaks, there are different color highlights for the peaks, which differentiates them from the graph’s troughs, as well as the other areas which are relatively level with the base plane of the image. As you practice with the system, you’ll be able to identify what hues work with your various projects.
Whether you’re a scientist, engineer or financial planner, one thing that will be critical to your operations is good graphical representations. Graphs provide the visual approach to your data analysis needs. With the advent of systems like MATLAB, you’ll be able to visualize your systems, and allow yourself to see your mathematical progressions with ease, and with the color differentiation that is desired to highlight your main data trends. The power of MATLAB can be harnessed in order to facilitate this need. For further details, feel free to access the Mathworks site at: