Matlab畫(huà)圖入門(mén)課

basic plot

x=0:0.01:2*pi;
y=sin(x);
figure;
plot(x,y);

basic plot

line style

x=0:0.01:2*pi;
y=sin(x);
y1=sin(x-0.5);
y2=sin(x-1);
y3=sin(x-1.5);
figure;
plot(x,y,'-',x,y1,'--',x,y2,':',x,y3,'-.');

line style

LineSpec(Color)

x=0:0.01:2*pi;
y=sin(x);
y1=sin(x-0.5);
y2=sin(x-1);
y3=sin(x-1.5);
figure;
plot(x,y,'-y',x,y1,'--m',x,y2,':c',x,y3,'-.g');

Color

LineSpec(Marker)

x=0:0.01:2pi;
y=sin(x);
y1=sin(x-0.5);
figure;
plot(x,y,'-
r',x,y1,'--db');

由于點(diǎn)太密集,所以線條變粗

Solution

x=0:0.01:2pi;
y=sin(x);
y1=sin(x-0.5);
mInds=round(linspace(1,length(x),10));
figure;
plot(x,y,'-r',x,y1,'--b');
hold on;
plot(x(mInds),y(mInds),'
r',x(mInds),y1(mInds),'db');

Marker

others

x=0:0.01:2pi;
y=sin(x);
y1=sin(x-0.5);
figure;
plot(x,y,'-r',x,y1,'--b','LineWidth',1.5); %設(shè)置線寬
xlabel('Angle'); %設(shè)置橫坐標(biāo)名稱
ylabel('Amplitude'); %設(shè)置縱坐標(biāo)名稱
legend('sin(x)','sin(x-0.5)'); %設(shè)置圖例
axis([0,2
pi,-1,1]); %設(shè)置坐標(biāo)軸寬度
grid on; %添加網(wǎng)格線
title('My second MATLAB olot'); %添加圖名
set(gca,'FontSize',18); %設(shè)置字體大小
set(gca,'Xtick',linspace(0,2*pi,5),'XtickLabel',{'0','0.5\pi','\pi','1.5\pi','2\pi'});%設(shè)置刻度標(biāo)簽

mapping

bar Chart

figure;
bar(industry);
axis([0,19,0,900]);
set(gca,'XTick',1:18);
title('three industry of He Nan');
xlabel('district');
ylabel('output value');
legend('primary industry','secondary industy','tertiary industry');
set(gca,'FontSize',18);

河南省三大產(chǎn)業(yè)

Stacked Bar Chart

figure;
bar(industry,'stacked');
axis([0,19,0,2100]);
set(gca,'XTick',1:18);
title('three industry of He Nan');
xlabel('district');
ylabel('output value');
legend('primary industry','secondary industy','tertiary industry');
set(gca,'FontSize',16);

河南省三大產(chǎn)業(yè)堆疊圖
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容