Scatterhist function not allowing for boxplot on the y-axis to stay

2 ビュー (過去 30 日間)
Saar Peles
Saar Peles 2020 年 10 月 16 日
編集済み: Adam Danz 2020 年 12 月 17 日
Hi I'm trying to run a scatterhistogram (scatterhist()) but whenever I run the function the figure will pop up with the boxplot correctly displayed for a brief second on the y-axis and then disappear immediately. I'm not sure why. I also want to be able to color in the points and I'm not sure how to do that. Any help will be appreciated.
k = scatterhist(swine2, ready.rr_la, 'Group', swine);
hold on;
j = get(k(1),'colororder');
boxplot(k(3),ready.rr_la,swine2, 'Labels', {'10','11', '12', '13'}, 'color', j);
view(k(2),[270,90]);
xlabel('Subject');
ylabel('Err_la');
The figure displayed is atttached
  5 件のコメント
Saar Peles
Saar Peles 2020 年 10 月 23 日
Sure, when adding all the view functions suggested this is what I get. When it first loads, the boxplot pops up but then immediatedly disappears.
Adam Danz
Adam Danz 2020 年 10 月 23 日
That's helpful but it's not a "MWE" (something we can copy-paste and run on our end to reproduce the problem).
It looks like you're not specifying the axes. I'll add an answer but if it doesn't solve the problem you'll need to give a MWE.

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

回答 (1 件)

Adam Danz
Adam Danz 2020 年 10 月 23 日
編集済み: Adam Danz 2020 年 12 月 17 日
It looks like you're trying to add a boxplot to the y-historgram axes. Recall that the y-histogram in scatterhist is reversed. Also, you're rotating the scatter axes so that x and y are switched but the histograms aren't switched. Why not just switch x and y in the scatterhist function?
h = scatterhist(y,x,___);
To add a boxplot to the y-histogram axis,
hold(h(3), 'on')
boxplot(h(3), ___)
Use h(2) for the x-histogram or h(1) for the scatter axes.
Update: see this example in the Matlab documentation.
  4 件のコメント
Saar Peles
Saar Peles 2020 年 10 月 23 日
I appreciate you taking the time to do this, but how would I put the boxplots onto the data. I tried doing it with the example you sent in my other post, however the erro it gave me was strange to say the least
Adam Danz
Adam Danz 2020 年 10 月 27 日
I don't understand how your boxplots are supposed to map onto the histograms. But their x & y values need to be within range of the histogram's x & y values.
That will be very hard to do.

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

タグ

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by