美文网首页
Matlab画图入门课

Matlab画图入门课

作者: 爱学习的张小路 | 来源:发表于2017-05-26 10:02 被阅读0次

    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');

    由于点太密集,所以线条变粗

    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); %设置线宽
    xlabel('Angle'); %设置横坐标名称
    ylabel('Amplitude'); %设置纵坐标名称
    legend('sin(x)','sin(x-0.5)'); %设置图例
    axis([0,2
    pi,-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'});%设置刻度标签

    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);

    河南省三大产业

    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);

    河南省三大产业堆叠图

    相关文章

      网友评论

          本文标题:Matlab画图入门课

          本文链接:https://www.haomeiwen.com/subject/jmetfxtx.html