basic plot
x=0:0.01:2*pi;
y=sin(x);
figure;
plot(x,y);
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,'-.');
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');
LineSpec(Marker)
x=0:0.01:2pi;
y=sin(x);
y1=sin(x-0.5);
figure;
plot(x,y,'-r',x,y1,'--db');
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');
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,2pi,-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)簽
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);
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);