Colormap on values related to bins

조회 수: 6 (최근 30일)
Riccardo Tronconi
Riccardo Tronconi 2021년 11월 4일
답변: Bjorn Gustavsson 2021년 11월 4일
Dear guys I'm dealing with a minor issue but I'm struggling to find what to me seems a simple task
Starting from values in X and Y and definition for each dimension of bins thanks to histcounts2 I'm able to asses to which couple of bins my points belong to. At this point, to each couple of bins I add a given value lets call it R. So my matrix is:
A=[BinX BinY R];
Using straightforward matlab function I'm able to asses the frequency and the sum of R related to a unique couple of bins. For this purpose my new matrix has the following columns:
1- binX
2-binY
3- frequency
4 sum of R related to a unique couple of bins
5- sum(R)/frequency
In doing so my target is to color using a colormap and specific shades of color each couple of bins base on this value: sum(R)/frequency . Though, the problem is that I can't use histogram2 beacuse my input are not x and y values but the number of bins in x and y. Alternatively, I used the heatmap but it's impractical due to several reason:
1- Empty couple of bins where the values is zero assumes NaN values or evenly not shown at all in my output
2- When I explicit all combination of values i receive the errror because I have duplicate values.
Is there an approach to overcome such drawbacks or problems?
Thanks to you all in advance for your time and efforts.

답변 (1개)

Bjorn Gustavsson
Bjorn Gustavsson 2021년 11월 4일
Perhaps you could use scatter to plot this. According to your description itseems as if you have a 2-D histogram type of data, but with all bins with zero count removed, that should be possible to plot with scatter (use the 'filled' argument to get filled blobs):
scatter(binX(:),binY(:),23,nCounts(:),'filled')
HTH

카테고리

Help CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by