Hitesh Sahu
Hitesh SahuHitesh Sahu
  1. Home
  2. ›
  3. posts
  4. ›
  5. …

  6. ›
  7. 2 2 Matlab Plotting

Loading ⏳
Fetching content, this won’t take long…


💡 Did you know?

🦈 Sharks existed before trees 🌳.

🍪 This website uses cookies

No personal data is stored on our servers however third party tools Google Analytics cookies to measure traffic and improve your website experience. Learn more

Loading ⏳
Fetching content, this won’t take long…


💡 Did you know?

🦥 Sloths can hold their breath longer than dolphins 🐬.
AI-Math

    AI-AgenticAI

    AI-DeepLearning

    AI-GenAI

    AI-Infrastructure

    AI-Machine-Learning

    AI-Math
    • ️Advance MultiVariant Linear Algebra

    • Linear Algebra for Machine Learning

    • MATLAB Crash Course

    • MATLAB Plotting & Visualization

    • AI-Math Index


    AWS

    Azure

    Hobbies

    kubernetes

    Management

    Programming

    Terraform

    Z_Appendix

    0-root

Cover Image for MATLAB Plotting & Visualization
AI-Math

MATLAB Plotting & Visualization

Complete guide to plotting in MATLAB including line plots, subplots, matrix visualization, styling options, legends, axis control, and exporting figures.

MATLAB
Data Visualization
Plotting
Scientific Computing
Matrix Visualization
Engineering
← Previous

MATLAB Crash Course

Next →

Terraform Configuration Management

Graphics

Plotting

  • Plots Y against X

Line Specification

Line Style

'-'    Solid line (default)
'--'   Dashed line
':'    Dotted line
'-.'   Dash-dot line

Marker Symbol

'.'    Point
'x'    Cross
'+'    Plus sign
'o'    Circle
'*'    Asterisk
'^'    Upward-pointing triangle
'v'    Downward-pointing triangle
'>'    Right-pointing triangle
'<'    Left-pointing triangle
's'    Square
'd'    Diamond
'p'    Five-pointed star (pentagram)
'h'    Six-pointed star (hexagram)

Color

r    Red
g    Green
b    Blue
c    Cyan
m    Magenta
y    Yellow
k    Black
w    White

Plotting Commands

plot(x, y)
plot(x, y, "r*")          % red asterisk, no line

hold on                    % plot on same axes as before
hold off                   % plot on different axes

clf                        % clear figure
close                      % close figure

figure(1); plot(x, y)     % save a named figure

subplot(n, m, o)          % divide plot into n×m grid, activate slot o
subplot(1, 2, 1)          % 1×2 grid, draw in first subplot

plot(Vector)              % auto-plot vector on Y axis
plot(x, y, "red--o", "LineWidth", 4)

Axis Limits

xlim([n, m])   % limit x range
ylim([n, m])   % limit y range

Plot Matrix

Color Plot

A = magic(5);
imagesc(A)

Result: Plot Color Matrix

Grey Scale Plot

A = magic(5);
imagesc(A), colorbar, colormap grey

Result: Plot Grey Scale


Labels & Legend

title('Title of Plot')
xlabel('X Axis Label')
ylabel('Y Axis Label')
legend('plot1', 'plot2')
axis([x1, x2, y1, y2])    % set axis range
grid on                    % enable grid

Example: FFT Plot

plot(f, yfft)
xlim([0, 1000])
title("Audio Range")
xlabel("Frequency")
ylabel("FFT")
legend("fft")

Result:

Plot FFT


Export Figure

print -dpng "<image_name>.png"
Hitesh Sahu
Written by Hitesh Sahu, a passionate developer and blogger.

Wed Feb 25 2026

Share This on

← Previous

MATLAB Crash Course

Next →

Terraform Configuration Management

AI-Math/2-2-Matlab-Plotting
Let's work together
+49 176-2019-2523
hiteshkrsahu@gmail.com
WhatsApp
Skype
Munich 🥨, Germany 🇩🇪, EU
Playstore
Hitesh Sahu's apps on Google Play Store
Need Help?
Let's Connect
Navigation
  Home/About
  Skills
  Work/Projects
  Lab/Experiments
  Contribution
  Awards
  Art/Sketches
  Thoughts
  Contact
Links
  Sitemap
  Legal Notice
  Privacy Policy

Made with

NextJS logo

NextJS by

hitesh Sahu

| © 2026 All rights reserved.