MATLAB 中的数据叠加图和相应的图形图
Figure of data overlayed and corresponding plot of graph in MATLAB
我在 data1
中保存了 11 binary datasets 所有大小为 297x258 的图像,我想生成一个具有这些数据重叠的图像,每个图像都分配了不同的颜色并删除了背景(白色)。此图中显示了所需输出的示例:
我使用以下方法生成这些数据集的图形:
figure, imshow(data1{1}),axis image, colormap(jet)
此外,任何有助于找到每个 x 值增量的 data1{1}
和 data1{11}
之间的平均大小增加(y 轴增加)的帮助也将受到赞赏。每组数据 data1{1}
、data1{2}
、...data1{11}
分别代表时间 0、1、...11,我想绘制一张平均增长图y 轴相对于 x 轴 (1:297)。非常感激您的帮忙。谢谢。
到目前为止我的想法是:
for x=1:x_dim % where xdim is 297 (along the X-axis)
for y=1:ydim % where ydim is 258 (along the y-axis)
% execute code to determine increase in y-direction between
% binary datasets data1{1}, data1{2},...data1{11}.
% Then compute average for growth in the y-direction between each time
end
% Plot figure of average increase in y-axis against x-axis.
end
所以这是你想要的数字的代码:
all_data = cell2mat(flipud(data1.'));
all_data = diag(repelem(linspace(1,70,11),size(data1{1},1)))*logical(all_data);
% option 1:
figure('Position',[450 100 200 900],'Color',[1 1 1]);
C = colormap('jet');
C = [1 1 1;C];
colormap(C)
imagesc(all_data)
axis image
axis off
% option 2:
all_data(1:size(data1{1},1):size(all_data,1),:) = nan(11,size(all_data,2));
stack = nan(size(all_data));
toprow = zeros(1,size(all_data,2));
for k = 1:size(all_data,2)
tmp = nonzeros(flipud(all_data(:,k)));
stack(1:numel(tmp),k) = tmp;
toprow(k) = numel(tmp);
end
figure('Position',[650 100 200 900],'Color',[1 1 1]);
C = colormap('jet');
C = [1 1 1;C];
colormap(C)
image(stack(1:max(toprow.'),:))
axis xy
axis off
这给出了这个:
左边没有选项1,右边没有选项2。
我在 data1
中保存了 11 binary datasets 所有大小为 297x258 的图像,我想生成一个具有这些数据重叠的图像,每个图像都分配了不同的颜色并删除了背景(白色)。此图中显示了所需输出的示例:
我使用以下方法生成这些数据集的图形:
figure, imshow(data1{1}),axis image, colormap(jet)
此外,任何有助于找到每个 x 值增量的 data1{1}
和 data1{11}
之间的平均大小增加(y 轴增加)的帮助也将受到赞赏。每组数据 data1{1}
、data1{2}
、...data1{11}
分别代表时间 0、1、...11,我想绘制一张平均增长图y 轴相对于 x 轴 (1:297)。非常感激您的帮忙。谢谢。
到目前为止我的想法是:
for x=1:x_dim % where xdim is 297 (along the X-axis)
for y=1:ydim % where ydim is 258 (along the y-axis)
% execute code to determine increase in y-direction between
% binary datasets data1{1}, data1{2},...data1{11}.
% Then compute average for growth in the y-direction between each time
end
% Plot figure of average increase in y-axis against x-axis.
end
所以这是你想要的数字的代码:
all_data = cell2mat(flipud(data1.'));
all_data = diag(repelem(linspace(1,70,11),size(data1{1},1)))*logical(all_data);
% option 1:
figure('Position',[450 100 200 900],'Color',[1 1 1]);
C = colormap('jet');
C = [1 1 1;C];
colormap(C)
imagesc(all_data)
axis image
axis off
% option 2:
all_data(1:size(data1{1},1):size(all_data,1),:) = nan(11,size(all_data,2));
stack = nan(size(all_data));
toprow = zeros(1,size(all_data,2));
for k = 1:size(all_data,2)
tmp = nonzeros(flipud(all_data(:,k)));
stack(1:numel(tmp),k) = tmp;
toprow(k) = numel(tmp);
end
figure('Position',[650 100 200 900],'Color',[1 1 1]);
C = colormap('jet');
C = [1 1 1;C];
colormap(C)
image(stack(1:max(toprow.'),:))
axis xy
axis off
这给出了这个:
左边没有选项1,右边没有选项2。