Turning off the axes box for marginal boxplots

3 ビュー (過去 30 日間)
z8080
z8080 2018 年 6 月 20 日
編集済み: Adam Danz 2020 年 12 月 17 日
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!
  2 件のコメント
Adam
Adam 2018 年 6 月 20 日
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
z8080 2018 年 6 月 20 日
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"

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

回答 (1 件)

Adam Danz
Adam Danz 2018 年 10 月 4 日
編集済み: Adam Danz 2020 年 12 月 17 日
h=scatterhist(__) returns a 1x3 vector of axis handles for the [scatter axis, marginal x axis, marginal y axis].
To turn off/on the visibility of the marginal histograms/boxplots
set(findall(h(1).Parent,'Parent',h(2)),'Visible','off') % or 'on'
set(findall(h(1).Parent,'Parent',h(3)),'Visible','off') % or 'on'
To turn the marginal axes off/on
By default, the marginal axes are off and the objects in the axes are still visible.
h = scatterhist(...);
h(2).Visible = 'off'; % or 'on'
h(3).Visible = 'off'; % or 'on'
To permanently delete the marginal axes
Note that a listener that responds to changes in the axes assumes the marginal axes exist and will throw a warning if your make certain changes to the figure after removing a marginal histrogram axes. For this reason, the first option above is better.
delete(h(2))
delete(h(3))

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

製品


リリース

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by