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
PDF hecho con ❤ en https://www.htmlapdf.com. ¿Quieres convertir un sitio web completo a PDF? Mira el tutorial aquí!
8. MATLAB- Plot with
Colours, Markers and
Line Specifications ►
9. MATLAB- 2D Plot
Do you want to make you MATLAB plot more colorful and descriptive?
Earlier we have seen How to draw a Graph in MATLAB?. Those were a typical single
color graph as shown below.
PDF hecho con ❤ en https://www.htmlapdf.com. ¿Quieres convertir un sitio web completo a PDF? Mira el tutorial aquí!
This graph still looks good as you are drawing a single graph on the MATLAB
display.
Table of Contents
Why does everyone like to Plot MATLAB Graph with different Colors?
The syntax for plotting graph to add color, marker, and line specification:
PLC Programming
How to Plot MATLAB Graph with different colors, markers, and line specifier?
Online Quiz
Electric Calculator Why does everyone like to Plot MATLAB Graph with
different Colors?
Career
What if you are plotting multiple graphs on a single MATLAB display…
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.
PDF hecho con ❤ en https://www.htmlapdf.com. ¿Quieres convertir un sitio web completo a PDF? Mira el tutorial aquí!
Reports you want to use
Optimize every stage of your team’s work ow and easily share
progress with stakeholders
Atlassian OPEN
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.
PDF hecho con ❤ en https://www.htmlapdf.com. ¿Quieres convertir un sitio web completo a PDF? Mira el tutorial aquí!
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.
PDF hecho con ❤ en https://www.htmlapdf.com. ¿Quieres convertir un sitio web completo a PDF? Mira el tutorial aquí!
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’
PDF hecho con ❤ en https://www.htmlapdf.com. ¿Quieres convertir un sitio web completo a PDF? Mira el tutorial aquí!
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.
PDF hecho con ❤ en https://www.htmlapdf.com. ¿Quieres convertir un sitio web completo a PDF? Mira el tutorial aquí!
In the below table, I am sharing the 12 marker style functions and its useful code
for MATLAB graph.
1 Star *
2 Plus +
3 Point .
4 Circle o
5 Square s
6 Diamond d
7 Pentagram p
8 Hexagram h
PDF hecho con ❤ en https://www.htmlapdf.com. ¿Quieres convertir un sitio web completo a PDF? Mira el tutorial aquí!
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 -.
PDF hecho con ❤ en https://www.htmlapdf.com. ¿Quieres convertir un sitio web completo a PDF? Mira el tutorial aquí!
These codes are placed inside single inverted comma.
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)
Solution:
PDF hecho con ❤ en https://www.htmlapdf.com. ¿Quieres convertir un sitio web completo a PDF? Mira el tutorial aquí!
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)).
PDF hecho con ❤ en https://www.htmlapdf.com. ¿Quieres convertir un sitio web completo a PDF? Mira el tutorial aquí!
MATLAB PLot Colors code you can copy paste:
PDF hecho con ❤ en https://www.htmlapdf.com. ¿Quieres convertir un sitio web completo a PDF? Mira el tutorial aquí!
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:
PDF hecho con ❤ en https://www.htmlapdf.com. ¿Quieres convertir un sitio web completo a PDF? Mira el tutorial aquí!
What’s Next:
PDF hecho con ❤ en https://www.htmlapdf.com. ¿Quieres convertir un sitio web completo a PDF? Mira el tutorial aquí!
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.
DipsLab is the fastest growing and most trusted community site for Electrical
and Electronics Engineers. All the published articles are available FREELY to all.
PDF hecho con ❤ en https://www.htmlapdf.com. ¿Quieres convertir un sitio web completo a PDF? Mira el tutorial aquí!
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.
PDF hecho con ❤ en https://www.htmlapdf.com. ¿Quieres convertir un sitio web completo a PDF? Mira el tutorial aquí!
Facebook LinkedIn Twitter
PDF hecho con ❤ en https://www.htmlapdf.com. ¿Quieres convertir un sitio web completo a PDF? Mira el tutorial aquí!
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
PDF hecho con ❤ en https://www.htmlapdf.com. ¿Quieres convertir un sitio web completo a PDF? Mira el tutorial aquí!
Dipali Chaudhari
February 11, 2021 at 9:58 pm
Thanks
Reply
Leave a Comment
Name *
Email *
Website
PDF hecho con ❤ en https://www.htmlapdf.com. ¿Quieres convertir un sitio web completo a PDF? Mira el tutorial aquí!
Post Comment
PDF hecho con ❤ en https://www.htmlapdf.com. ¿Quieres convertir un sitio web completo a PDF? Mira el tutorial aquí!