Matlab中的项目进度图

时间:2017-02-15 21:22:28

标签: matlab plot scatter-plot

我想用我的大四学生在Java中做的一些改变。由于我不懂那种语言,我想在Matlab中做。我在这里附上了数据(文本格式)和情节。它是项目进度表的输出,其中值表示与任务(链接)相关的成本及其持续时间(比如任务2从第6个月到第9个月完成,成本为0.665m $)。

值0表示特定任务(行)在该时间段内没有工作。 Java中的图表显示了每项任务的时间和成本变化。

我一直试图在Matlab中制作类似的情节(圆圈情况下为条形),但不能。

java plot

Link#   1   2   3   4   5   6   7   8   9   10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30
1   0   0   0   0   0   0   0   0   0   0   0   0   0.34    0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
2   0   0   0   0   0   0.665   0.665   0.665   0.665   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
3   0   0   0.34    0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
4   0.36    0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
5   0.14    0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
6   0   0   0   0   0   0   0   0   0   0   0.58    0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
7   0   0   0   0.57    0.57    0.57    0.57    0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
8   0.64    0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
9   0.58    0.58    0.58    0.58    0.58    0.58    0.58    0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
10  0.24    0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
11  0.56    0.56    0.56    0.56    0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
12  0.2 0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
13  0   0   0   0   0   0   0   0   0.56    0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
14  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0.62    0   0   0   0   0   0   0   0   0   0   0
15  0   0   0   0.582857143 0.582857143 0.582857143 0.582857143 0.582857143 0.582857143 0.582857143 0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
16  0.536   0.536   0.536   0.536   0.536   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
17  0.2 0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
18  0   0.6 0.6 0.6 0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
19  0   0   0   0   0.0000  0   0   0   0   0   0   0   0.606666667 0.606666667 0.606666667 0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
20  0   0   0   0.633333333 0.633333333 0.633333333 0.633333333 0.633333333 0.633333333 0.633333333 0.633333333 0.633333333 0.633333333 0.633333333 0.633333333 0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
21  0   0   0.606666667 0.606666667 0.606666667 0.606666667 0.606666667 0.606666667 0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
22  0   0   0.643076923 0.643076923 0.643076923 0.643076923 0.643076923 0.643076923 0.643076923 0.643076923 0.643076923 0.643076923 0.643076923 0.643076923 0.643076923 0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
23  0   0   0   0   0   0   0   0.58    0.58    0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
24  0   0   0   0   0   0   0   0   0   0.651428571 0.651428571 0.651428571 0.651428571 0.651428571 0.651428571 0.651428571 0   0   0   0   0   0   0   0   0   0   0   0   0   0
25  0   0   0.62    0.62    0.62    0.62    0.62    0.62    0.62    0.62    0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
26  0   0   0   0   0   0   0.62    0.62    0.62    0.62    0.62    0.62    0.62    0.62    0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
27  0.546666667 0.546666667 0.546666667 0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
28  0   0.655   0.655   0.655   0.655   0.655   0.655   0.655   0.655   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
29  0.5 0.5 0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
30  0   0   0   0   0   0   0   0   0   0.44    0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
31  0.54    0.54    0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
32  0   0.64    0.64    0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
33  0   0   0   0   0   0   0   0   0   0.611428571 0.611428571 0.611428571 0.611428571 0.611428571 0.611428571 0.611428571 0   0   0   0   0   0   0   0   0   0   0   0   0   0
34  0   0   0   0   0   0   0   0.62    0.62    0.62    0.62    0.62    0.62    0.62    0.62    0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
35  0.36    0.36    0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
36  0   0   0   0   0   0   0   0   0   0   0.65    0.65    0.65    0.65    0.65    0.65    0.65    0.65    0   0   0   0   0   0   0   0   0   0   0   0
37  0.38    0.38    0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
38  0.613333333 0.613333333 0.613333333 0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
39  0.58    0.58    0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0
40  0   0   0   0   0.647272727 0.647272727 0.647272727 0.647272727 0.647272727 0.647272727 0.647272727 0.647272727 0.647272727 0.647272727 0.647272727 0.647272727 0.647272727 0.647272727 0.647272727 0.647272727 0.647272727 0.647272727 0.647272727 0.647272727 0.647272727 0.647272727 0   0   0   0

java plot

1 个答案:

答案 0 :(得分:1)

以下是解决方案的示例,假设data图表中的所有内容(即没有轴刻度标签):

Links_num = size(data,1);
[y,x] = ndgrid(1:Links_num,1:size(data,2));
c = repelem(1:Links_num,size(data,2),1).';
scatter(x(:),y(:),data(:)*100+1,c(:),'filled')
clr = lines(Links_num);
colormap(clr)
title('Time Period')
ax = gca;
ax.XAxisLocation = 'top';
ax.XAxis.TickValues(1) = [];
clr = lines(Links_num); % make a color map
ax.YAxis.Direction = 'reverse';
links = [repmat('Link ',Links_num,1) num2str((1:Links_num).')];
x = repelem(ax.XAxis.Limits(1)-0.05,Links_num); % make an x position vector
for k = 1:Links_num
    text(ax.XAxis.Limits(1)-0.05,k,links(k,:),'Color',clr(k,:),...
        'HorizontalAlignment','right');
end
ax.YAxis.Visible = 'off'; % remove the original labels

结果:

project schedule