MATLAB常用函数及出图代码(备用)
%
x = 1:7;
y = [1479 1645 2188 1062 1130 1241 1552];
bar (y,.75,‘grouped’);
colormap winter;
for i = 1:length(y)
text(x(i),y(i),num2str(y(i)),…
‘HorizontalAlignment’,‘center’,…
‘VerticalAlignment’,‘bottom’)
end
xlabel(‘年’,‘FontSize’,16);
ylabel(‘记录数’,‘FontSize’,16);
set(gca,‘XTickLabel’,{‘2011’,‘2012’,‘2013’,‘2014’,‘2015’,‘2016’,‘2017’});
set (gca,‘XColor’,‘k’,‘YColor’,‘k’,‘LineWidth’,1.5,‘FontSize’,12);
%
%特点:XY轴互换
x = 1:350:3500;
y = [3079 2195 1187 826 730 710 698 618 573 560];
bar (x,y,.75,‘grouped’);
colormap summer;
view(90,-90);
for i = 1:length(y)
text(x(i)-50,y(i)+150,num2str(y(i)),…
‘HorizontalAlignment’,‘center’,…
‘VerticalAlignment’,‘bottom’)
end
set (gca,‘XColor’,‘k’,‘YColor’,‘k’,‘LineWidth’,1.5,‘FontSize’,12);