MATLAB Answers

Turning off the axes box for marginal boxplots

22 views (last 30 days)
z8080 on 20 Jun 2018
Edited: Adam Danz on 4 Oct 2018
I followed this example to create a scatterplot with marginal box plots. I would like for both box plots to not have an axis box, but the command 'box off' seems to only apply to the scatterplot itself. How can I achieve this effect for the boxplots?
Also, what commands can I use to control (1) the aspect ratio of the boxplots, and (2) their distance to the main scatterplot?
Thank you!


Adam on 20 Jun 2018
I'm not familiar with box plots, as such, but command like
box off
hold on
have function equivalents that you should get more used to using, which allow you to specify an axes handle, e.g.
box( hAxes, 'off' )
for the axes handle hAxes.
z8080 on 20 Jun 2018
Thanks. I know that, but in this case boxplot does not seem to return any handles, and if I nonetheless do
hAxes = boxplot(..
and then
box( hAxes, 'off' )
I get the error: "Axes handle must be a scalar"

Sign in to comment.

Answers (1)

Adam Danz
Adam Danz on 4 Oct 2018
Edited: Adam Danz on 4 Oct 2018
The scatterhist() function returns a vector of axis handles to the scatter plot, the x box plots, and the y box plots, respectively. Here's how to turn off the axes for the marginal box plots.
h = scatterhist(...);
h(2).Visible = 'off';
h(3).Visible = 'off';
You can also control the box property this way.


Sign in to comment.





Community Treasure Hunt

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

Start Hunting!