Professional Documents
Culture Documents
com
by Dipali Chaudhari
PLC MATLAB Electrical Career Abbreviation Electric Calculators Quiz About Me Subscribe Our Services
MATLAB Simulink
How to Plot MATLAB Graph with
1. MATLAB- Simulink
Colors, Markers and Line
Toolbox Specification?
by Dipali Chaudhari
2. MATLAB- Creating M-
File
4. MATLAB- Math
Expressions
5. MATLAB- Matrix
6. MATLAB- Vector
7. MATLAB -Plotting
Do you want to make you MATLAB plot more colorful and descriptive?
9. MATLAB- 2D Plot
10. MATLAB- 3D Plot Earlier we have seen How to draw a Graph in MATLAB?. Those were a typical single
color graph as shown below.
11. MATLAB- Simulink
Model
Sta Using
Neo4j Aura
Today
Experiment and
run Neo4j
databases
without
managing the
underlying This graph still looks good as you are drawing a single graph on the MATLAB display.
infrastructure
yourself
Why does everyone like to Plot MATLAB Graph with different Colors?
MATLAB Plot Colors to draw the Graph Hey, are you interested in Electrical
Engineering? Let's connect...
MATLAB Plot Marker | Different Style to Draw the Graph
MATLAB Plot Line Specification | Code for MATLAB Graph
Other Tutorials The syntax for plotting graph to add color, marker, and line specification:
How to Plot MATLAB Graph with different colors, markers, and line specifier?
Electrical Study
Online Quiz Why does everyone like to Plot MATLAB Graph with
different Colors?
Electric Calculator
For plotting multiple graphs in a single window, it very difficult to distinguish one
graph from another graph.
You are plotting graphs for multiple mathematical equations like a sin wave, cos
wave, exponential function on the same MATLAB display. After the running MATLAB
program, you will get a number of graphs on the single MATLAB display. The end
user will get more confused and will find it more difficult to understand and
distinguish multiple graphs.
So you need to decorate each graph differently, like assigning a different color to
each curve.
Each color describes one graph and that makes the graph self-descriptive.
In this tutorial, you will learn to plot the colorful graphs in MATLAB.
We will also see what are the most important and useful color coding functions,
marker style and line-specification designing functions available in MATLAB.
By using these functions, you can draw the graph or waveform as per your color
and plotting style choice. And you can easily understand the particular equation’s
graph.
Let’s begin by considering the top three essential components to decorate your
graph more meaningful.
Colour
Marker Style
Line Specification
Likewise, for plotting the graph on MATLAB, we have different colors code or
functions.
Widely, eight colors are used for MATLAB graph. And each color has the
corresponding color code.
The below table shows color specification with the color code.
Hexadecimal Colour
Colour Colour Short RGB Code
Sr.No.
Name Name Triplet [Useful in MATLAB
Program]
1 Black k [0 0 0] ‘#000000’
2 Blue b [0 0 1] ‘#0000FF’
3 Green g [0 1 0] ‘#00FF00’
4 Cyan c [0 1 1] ‘#00FFFF’
5 Red r [1 0 0] ‘#FF0000’
6 Magenta m [1 0 1] ‘#FF00FF’
7 Yellow y [1 1 0] ‘#FFFF00’
8 White w [1 1 1] ‘#FFFFFF’
You can use these eight colors code to draw the colorful waveforms in MATLAB.
There are different marker style functions. For example, star format function, point
format function, square format function, plus format function and so on.
In the below table, I am sharing the 12 marker style functions and its useful code
for MATLAB graph.
Marker Style Code
1 Star *
2 Plus +
3 Point .
4 Circle o
5 Square s
6 Diamond d
7 Pentagram p
8 Hexagram h
How does the graph look different after using these marker styles? This we will see
later in this tutorial example.
1 Solid –
2 Dotted :
3 Dashed —
4 Dash-Dot -.
Now its time to implement all three essentials components (color, marker, and line
specifier) for decorating the MATLAB graph.
Let’s take these two mathematical equations to plot the MATLAB graph.
1) y(x)=sin(2x)
MATLAB code:
Here is MATLAB code you can write to plot the graph for the function of f(x) and its
d/dx (f(x)).
x=[0:0.01:10];
y1 = sin(2*x);
y2=2.*cos(2.x);
plot(x,y1,'r * -');
hold on
plot(x,y2,'k . :');
legend('sin', 'cos');
In this program, I have used the ‘legend’ function to label data series plotted on a
graph. You can see in the below MATLAB output.
We are using different colors, markers and line specifications for plotting two
different graphs.
MATLAB Output:
What’s Next:
I hope you learn to decorate our MATLAB graph with different colors, marker and
line specifiers with the simple example of MATLAB graphs.
Now try MATLAB plot colors, marker styles and line specification on different
MATLAB versions. Let’s make your graph more colorful.
Do you have any query? You can ask me by comment below.
DipsLab is the fastest growing and most trusted community site for Electrical
and Electronics Engineers. All the published articles are available FREELY to all.
If you like what you are reading, please consider buying me a coffee ( or 2 ) as
a token of appreciation.
Dipali Chaudhari
I have completed master in Electrical Power System. I work and
write technical tutorials on the PLC, MATLAB programming, and
Electrical on DipsLab.com portal.
Payal Zade
July 6, 2020 at 3:01 am
Thanks, Mam
Reply
Dipali Chaudhari
July 6, 2020 at 12:54 pm
Reply
Oussama
February 11, 2021 at 9:14 am
Reply
Dipali Chaudhari
February 11, 2021 at 9:58 pm
Thanks
Reply
Leave a Comment
Name *
Email *
Website
Post Comment