Colormap on values related to bins

6 vues (au cours des 30 derniers jours)
Riccardo Tronconi
Riccardo Tronconi le 4 Nov 2021
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.

Réponses (1)

Bjorn Gustavsson
Bjorn Gustavsson le 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):
scatter(binX(:),binY(:),23,nCounts(:),'filled')
HTH

Catégories

En savoir plus sur Data Distribution Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by