Colormap on values related to bins
17 views (last 30 days)
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:
4 sum of R related to a unique couple of bins
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.
Bjorn Gustavsson on 4 Nov 2021
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):