Grouping 2d data with different bins for each dimension.

3 ビュー (過去 30 日間)
Riccardo Tronconi
Riccardo Tronconi 2021 年 10 月 26 日
コメント済み: Cris LaPierre 2021 年 10 月 26 日
Dear guys I'm trying to group my 2d data but with poor results.
My input are x and y. At first I divide them into bins with different dimensions as it follows:
a=(min(x):0.2:max(x))'; %17x1
b=(min(y):0.2:max(y))'; %34x1
At this point through I asses the distributions in each bin:
N=histcounts2(x,y,a,b);
Finally, I subplot my data in order to have at the left side the scatter of points while at the other an heatmap:
subplot(1, 2, 1);
scatter(x, y, 'r.');
subplot(1, 2, 2);
imagesc(a, b, N);
Unfortunately this is my result
The right side is correct but somehow in the wrong side. How can I correct this?

採用された回答

Cris LaPierre
Cris LaPierre 2021 年 10 月 26 日
An image axis has the origin and the top left while a cartesian axis has the origin at the bottom left.
Counsider using histogram2 with the 'DisplayStyle' set to 'tile' instead of histcounts2 and imagesc. See this example.
  2 件のコメント
Riccardo Tronconi
Riccardo Tronconi 2021 年 10 月 26 日
@Cris LaPierre thank you very much. Just an extra question. For each bin instead of display the absolute number, would it be possible using relative numbers?
Lets say the bin 10 has =50 values but the total values recorded are 100 so the relative number related to that bin is 50/100= 0.5. Is there a way to do that?
Cris LaPierre
Cris LaPierre 2021 年 10 月 26 日
I'm not sure if that specific option exists, but look into the Normalization options. This is one of the name-value pair arguments for histogram2. Options are
  • 'count' (default)
  • 'probability'
  • 'countdensity'
  • 'pdf'
  • 'cumcount'
  • 'cdf'

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by