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

2 views (last 30 days)
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 Comments
Saar Peles
Saar Peles on 23 Oct 2020
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 on 23 Oct 2020
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.

Sign in to comment.

Answers (1)

Adam Danz
Adam Danz on 23 Oct 2020
Edited: Adam Danz on 17 Dec 2020
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 Comments
Saar Peles
Saar Peles on 23 Oct 2020
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 on 27 Oct 2020
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.

Sign in to comment.

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!