【问题标题】:MatLab: hist - fading colors depending on sizeMatLab:hist - 根据大小褪色
【发布时间】:2014-07-26 16:11:08
【问题描述】:

是否可以像 hist3-plot 一样为 hist-plot 的条形设置褪色(参见下面的屏幕截图)?

【问题讨论】:

    标签: matlab colors histogram


    【解决方案1】:

    hist3 与您的一维数据一起使用:

    y=randn(1,1e2);
    bins = 10;
    hist3([y(:) y(:)],[1 bins]);
    view(90,0)
    set(gcf,'renderer','opengl');
    set(get(gca,'child'),'FaceColor','interp','CDataMode','auto');
    


    编辑:要标准化直方图,只需根据numel(y)重新缩放标签,这意味着添加以下行:

    set(gca,'ZTickLabel',str2num(get(gca,'ZTickLabel'))/numel(y));
    

    【讨论】:

    • 太棒了!非常感谢。
    • 还有一个问题:我需要标准化直方图。我这样做: [f, x] = hist(y(:), bins);对于 i = 1:numel(f(1,:)) 对于 j = 1:numel(f(:,i)) f(j,i) = f(j,i)/numel(y);结束 bar3(x, f);但是,您的解决方案不适用于 bar3()。有解决办法吗?
    猜你喜欢
    • 1970-01-01
    • 2018-12-21
    • 2023-01-02
    • 2021-09-03
    • 2012-09-03
    • 1970-01-01
    • 2013-03-23
    • 2020-08-14
    • 2012-10-24
    相关资源
    最近更新 更多