How to hide zero values in bar3 plot in MATLAB

后端 未结 3 580
暗喜
暗喜 2020-12-02 00:26

I\'ve got a 2-D histogram (the plot is 3D - several histograms graphed side by side) that I\'ve generated with the bar3 plot command. However, all the zero values show up

3条回答
  •  温柔的废话
    2020-12-02 00:31

    My problem was not zero values, but NaN values (which are converted into zero values inside of bar3). I wanted to keep displaying elements with values zero, but not the elements with value nan. I adjusted the code slightly, and it worked perfectly:

    for i = 1:numel(h)
      index = logical(kron(isnan(z(:,i)),ones(6,1)));
      zData = get(h(i),'ZData');
      zData(index,:) = nan;
      set(h(i),'ZData',zData);
    end
    

    Thanks!

提交回复
热议问题