colormap does not work on histogram2
조회 수: 5 (최근 30일)
이전 댓글 표시
Hello, I have created a custom colormap which is just turbo but with more indices, and the first entry is white.
cmapturbo=turbo(25600);
cmapturbo(1, 1) = 1;
cmapturbo(1, 2) = 1;
cmapturbo(1, 3) = 1;
I try to implement this custom colormap to a histogram2:
histogram2(x, y, [10, 10], 'normalization', 'probability', 'DisplayStyle','bar3', 'FaceColor','flat')
colorbar
colormap(cmapturbo)
However, it results in a figure as shown in histogram2.jpg. I am hoping to make it so that it can look like something in hist3.jpg.
The reason why I am not using hist3 to graph my data is because hist3 does not support graphing the frequency as a probability.
Thank you.
댓글 수: 0
채택된 답변
Star Strider
2023년 2월 10일
X = randn(1000,1);
Y = randn(1000,1);
[N,XEdges,YEdges] = histcounts2(X,Y,[10 10]);
XCntrs = XEdges(1:end-1) + diff(XEdges/2);
YCntrs = YEdges(1:end-1) + diff(YEdges/2);
figure
hb3 = bar3(N);
colormap(turbo)
for k = 1:numel(hb3)
zdata = hb3(k).ZData;
hb3(k).CData = zdata;
hb3(k).FaceColor = 'interp';
end
.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
