MATLAB plot 畫圖大全


距離上一次打開Matlab已經過去了半年多,再次上手,畫圖時諸多不熟悉,促使我寫下這篇blog,自己以后可以快速查看,也分享給大家~

二維線圖  plot

 plot(X1,Y1,LineSpec1,...,Xn,Yn,LineSpecn) 設置每個線條的線型、標記符號和顏色。

指定線型、顏色和標記

x = 0:pi/10:2*pi;
y1 = sin(x);
y2 = sin(x-0.25);
y3 = sin(x-0.5);

figure
plot(x,y1,'g',x,y2,'b--o',x,y3,'c*')

 

指定線寬、標記大小和標記顏色

x = -pi:pi/10:pi;
y = tan(sin(x)) - sin(tan(x));

figure
plot(x,y,'--gs',...
    'LineWidth',2,...
    'MarkerSize',10,...
    'MarkerEdgeColor','b',...
    'MarkerFaceColor',[0.5,0.5,0.5])

添加標題和軸標簽

figure
plot(x,y,'Color',[0,0.7,0.9])

title('2-D Line Plot')
xlabel('x')
ylabel('cos(5x)')
axis([xmin xmax ymin ymax])

指定線圖的坐標區

ax1 = subplot(2,1,1); % top subplot
x = linspace(0,3);
y1 = sin(5*x);
plot(ax1,x,y1)
title(ax1,'Top Subplot')
ylabel(ax1,'sin(5x)')

ax2 = subplot(2,1,2); % bottom subplot
y2 = sin(15*x);
plot(ax2,x,y2)
title(ax2,'Bottom Subplot')
ylabel(ax2,'sin(15x)')

 

 

 

LineSpec - 線型、標記和顏色

線型 說明 表示的線條
'-' 實線

 

'--' 虛線

 

':' 點線

 

'-.' 點划線

 

'none'

無線條

無線條
標記 說明
o 圓圈
+ 加號
* 星號
.
x 叉號
s 方形
d 菱形
^ 上三角
v 下三角
> 右三角
< 左三角
p 五角形
h 六角形

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

顏色 說明

y

黃色

m

品紅色

c

青藍色

r

紅色

g

綠色

b

藍色

w

白色

k

黑色

 

 

 

 

 

 

 

 

 

 

 

 

 'Marker' - 標記符號

說明
'o' 圓圈
'+' 加號
'*' 星號
'.'
'x' 叉號
'square' 或 's' 方形
'diamond' 或 'd' 菱形
'^' 上三角
'v' 下三角
'>' 右三角
'<' 左三角
'pentagram' 或 'p' 五角星(五角形)
'hexagram' 或 'h' 六角星(六角形)
'none' 無標記

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  

 

 

 

 

 

 

'MarkerEdgeColor' - 標記輪廓顏色

'MarkerFaceColor' - 標記填充顏色

'MarkerSize' - 標記大小

grid on/off  網格開關

box on/off  圖象的右上角和左上角邊界開關

figure('NumberTitle', 'off', 'Name', 'S Parameter (dB) - Cartesian')     figure的名稱

 

極坐標系 ploarplot

load(fullfile(matlabroot,'examples','matlab','antennaData.mat'))

figure
polarplot(theta,rho)

 

為極坐標圖添加注釋

legend('Original','With Noise')
title('Antenna Radiation Pattern')

更改極坐標區范圍

rmin = min(rho);
rmax = max(rho);
rlim([rmin rmax]);
thetalim([0 180]);

 

 

創建極坐標直方圖

polarhistogram(direction)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM