【问题标题】:Figure of data overlayed and corresponding plot of graph in MATLABMATLAB中的数据叠加图和对应图
【发布时间】:2017-08-01 23:25:41
【问题描述】:

我在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

【问题讨论】:

    标签: matlab plot matlab-figure


    【解决方案1】:

    所以这里是你想要的数字的代码:

    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{1}、data1{2}、... data1{11} 之间的转换。使用线条很难观察到对象以“孤岛”结尾的位置,无法区分数据前面的位置。
    • 3 号是我想制作的。谢谢。
    • 也很想知道您是如何制作 5 号的。谢谢。
    • @a.kk 使用所选选项的代码查看我的编辑。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-11-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-07
    相关资源
    最近更新 更多