« 上一篇: 在条状图上画短线表示标准方差 下一篇: 用带字符串的标注画的label刻度 »
萝卜 @ 2008-02-03 07:59

程序如下:

function xbar(D,N,w);
% bar is placed x-axis;
% N is the number for the variable t;
% w is the width of bar.
% Example:
%   M1: t1=2;t3=4;
%   M2: t2=1;t5=7;t8=4;t6=4;
%   M3: t4=3;t7=2;t9=4;
%   M4: t10=3;t11=3;t12=2;
%   Then D and N are equal to
%   D=[2,4,0,0;
%      1,7,4,4;
%      3,2,4,0;
%      3,3,2,0];
%   N=[1,3,0,0;
%      2,5,8,6;
%      4,7,9,0;
%      10,11,12,0];
% calling the file 'xbar.m' is
% xbar(D,N,0.2);
n=size(D,1);m=size(D,2);
if n>9;
    error('The row number of D and N must be less 10');
end
for kn=1:n;
    xs=0;
    for km=1:m;
        if N(kn,km)~=0;
            plot([xs,xs+D(kn,km),xs+D(kn,km),xs,xs],...
                [1+n-kn+w,1+n-kn+w,1+n-kn-w,1+n-kn-w,1+n-kn+w],'k');
            hold on;
            C=rand(1,3); %C is random color. It is also controlled by a certain data Nx3.
            fill([xs,xs+D(kn,km),xs+D(kn,km),xs,xs],...
                [1+n-kn+w,1+n-kn+w,1+n-kn-w,1+n-kn-w,1+n-kn+w],C);
            text(xs+D(kn,km)/2,1+n-kn,['{itt}_{',num2str(N(kn,km)),'}'],...
                'fontsize',14);           
        end
        xs=xs+D(kn,km);
    end
end
set(gca,'ytick',0:n);
S=[' 0'];
for k=1:n;
    S(k+1,:)=['M',num2str(k)];
end
set(gca,'Yticklabel',S);
xlabel('makespan','fontsize',16);

图形如下:



评论 / 个人网页 / 扔小纸条
* 昵称

已经注册过? 请登录

新用户请先注册 以便能显示头像及追踪评论回复

Email
网址
* 评论
表情
 


 

分类小组论坛
杂谈 , 娱乐、八卦 , 文学、艺术 , 体育 , 旅游、同城 , 象牙塔 , 情感 , 时尚、生活 , 星座 , 科技

请注意遵守中华人民共和国法律法规, 如威胁到本站生存, 将依法向有关部门报告, 同时本站的相关记录可能成为对您不利的证据.

相关法律法规
全国人大常委会关于维护互联网安全的决定
中华人民共和国计算机信息系统安全保护条例
中华人民共和国计算机信息网络国际联网管理暂行规定
计算机信息网络国际联网安全保护管理办法
计算机信息系统国际联网保密管理规定