Opening the book…
The plot function is very common, but MATLAB includes many other plotting functions. The best plot depends on what you want to show.
|
Plot type |
MATLAB function |
Best used for |
|
Line plot |
plot |
Continuous trends or relationships between x and y. |
|
Vertical bar plot |
bar |
Comparing categories or discrete values. |
|
Horizontal bar plot |
barh |
Comparing categories when labels may be long. |
|
Area plot |
area |
Showing accumulated values or filled trends. |
|
Stem plot |
stem |
Discrete data points, especially sequences. |
|
Histogram |
histogram |
Showing how often values occur in ranges or bins. |
|
Pie chart |
pie |
Showing parts of a whole. |
|
Scatter plot |
scatter |
Showing relationships between two variables without connecting points. |
Visualize the same data using a simple plot, bar plot, horizontal bar plot, area plot, and stem plot.
clear; clc; clf;
x = 1:6;
y = [33 11 5 9 22 30];
subplot(2,3,1)
plot(x, y)
title('Regular Plot')
subplot(2,3,2)
bar(x, y)
title('Bar Plot')
subplot(2,3,31)
barh(x, y)
title('Horizontal Bar Plot')
subplot(2,3,4)
area(x, y)
title('Area Plot')
subplot(2,3,5)
stem(x, y)
title('Stem Plot')
Solution

This page titled 10.6: Other Common 2D Plot Types was last modified on Tue, 30 Jun 2026 02:11:46 GMT and is shared under a CC BY-NC-SA license and was authored, remixed, and/or curated by Zara Noroozi.
The book could not be loaded just now.