How to normalize a histogram2 along one dimension?
4 次查看(过去 30 天)
显示 更早的评论
I have a large set of datapoints, say in vectors X and Y containing the real variables x and y. To study the dependency of these variables, I can draw something like scatter(X,Y). But a disadvantage of scatter is that if the amount of samples is very high, it will just draw a uniformly colored area.
Histogram2 provides an alternative, where bin heights or colors show the amount of counts or probability (or corresponding density) to have events in a given region.
Now, just doing histogram2(X,Y) does not provide a satisfying picture of 'what y values are expected to what extent for every x value', because X itself is not uniformly distributed; the histogram2 is peaked both in x and y instead of peaked along a trend line as function of x.
Is there a way to compensate for this? I mean so that for each value of x there is a separate normalized probability that y should be found in one of the entries. The standard bin width, which is constant, remains fine to me.
0 个评论
回答(1 个)
Steven Lord
2018-5-30
It sounds like you want a binscatter plot. This function was introduced in release R2017b. Look at the "Change Color Map of Binned Scatter Plot" example on that documentation page and see if that looks like what you want.
Or if you're using release R2017a or later, perhaps a heatmap will show you the data in a form similar to what you described. You mentioned normalizing in one dimension, and for that see the "Normalize Colors Along Each Row or Column" example on the heatmap documentation page.
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!