Colorbar is opposite of scatterplot

4 ビュー (過去 30 日間)
Jose
Jose 2023 年 5 月 6 日
コメント済み: Jose 2023 年 5 月 7 日
So I copied all of the steps found on the following documentation page: https://www.mathworks.com/help/stats/gmdistribution.mahal.html
but for some reason my graph is showing the color yellow at the top but the scatter plot shows it closest the origin. From the Documentation it looks like the graph should match the colorbar values and vice-versa. anyone know what Iam doing wrong? I have tried multiple different solutions such as colormap(flipud(hot)) with no success
r1 = mvnrnd(mu1,Cov1,1000);
r2 = mvnrnd(mu2,Cov2,1000);
X = [r1; r2];
gm = fitgmdist(X,2);
d2 = mahal(gm,X);
scatter(X(:,1),X(:,2),10,d2(:,1),'.')
c = colorbar;
ylabel(c,'Graph')

採用された回答

the cyclist
the cyclist 2023 年 5 月 6 日
It is more difficult to debug your result, when you have not given us the full code that generates your figure.
But, I see no problem here. Note that your code (like the example in the documentation), is displaying the Mahalanobis distance of each point from Cluster 1.
In your figure, Cluster 1 must be the cluster that is in the upper-right part of the figure (where all the points are the purplish color). The points you have put the red box around are the ones with the greatest distance from the center of that cluster.
I see no inconsistency in your results.
  1 件のコメント
Jose
Jose 2023 年 5 月 7 日
thanks for this, for some reason I thought furthest distance from the component would be in the upper right corner opposite of the origin.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeColormaps についてさらに検索

タグ

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by