Thanks for the help. That's what I'm trying do, although this is kind of a brute force way of doing it. I was sort of hoping that there would be a way to set the color map directly to the histogram. I guess I'll need to make a function for this.
Using a colormap to match a contour to a histogram
조회 수: 9 (최근 30일)
이전 댓글 표시
I am regenerating cscan TOF data ( contourf(xscale, yscale, cscan, 40,'linestyle','--') ) and I would am trying to display a histogram of the data such that the bar colors will be the same a shown in the histogram (say red in the contour = 400 ns would have the histogram bar at 400 also be red). Is there an easy way to assign the bars using the colormap?
댓글 수: 0
채택된 답변
추가 답변 (1개)
Jess Lovering
2019년 10월 3일
편집: Jess Lovering
2019년 10월 3일
Here is an example of what I think you are trying to do. It doesn't calculate the bar values for the contours - I assume you have an associated value for each contour already available. Please let me know if this example is what you are looking for.
figure
subplot(2,1,1)
Z = peaks;
[M c]=contour(Z);
cmap = colormap;
crange = caxis;
cmin = crange(1);
cmax = crange(2);
m = length(cmap);
subplot(2,1,2)
hold on
contour_levels = -6:8;
bar_vals = rand(1,length(contour_levels)); % I assume you have these calculated
for ii = 1:length(contour_levels)
contour_i = contour_levels(ii);
cp = (contour_i-cmin)/(cmax-cmin);
ci = round((length(cmap)-1)*cp)+1;
color(ii,1:3) = cmap(ci,:);
bh = bar(contour_levels(ii),bar_vals(ii))
bh.FaceColor = cmap(ci,:);
end
댓글 수: 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!