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); %设置线宽
xlabel('Angle'); %设置横坐标名称
ylabel('Amplitude'); %设置纵坐标名称
legend('sin(x)','sin(x-0.5)'); %设置图例
axis([0,2pi,-1,1]); %设置坐标轴宽度
grid on; %添加网格线
title('My second MATLAB olot'); %添加图名
set(gca,'FontSize',18); %设置字体大小
set(gca,'Xtick',linspace(0,2*pi,5),'XtickLabel',{'0','0.5\pi','\pi','1.5\pi','2\pi'});%设置刻度标签
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);