Boxplot inside a bar graph.

9 ビュー (過去 30 日間)
Rub Ron
Rub Ron 2020 年 12 月 8 日
回答済み: Cris LaPierre 2020 年 12 月 8 日
Say I have a bar graph with two groups, and 4 bars in each group:
bar(rand(2,4))
I would ike to plot a boxplot (or else a bunch of points) in the second bar of each group (the second bar and the boxplot have to be centered in the x axis). Is it possible? I have found no clue.
Thanks in advance.

採用された回答

Cris LaPierre
Cris LaPierre 2020 年 12 月 8 日
Use hold on to place multiple plots on the same axes. Always pair it with hold off when you are complete.
If you want to add points, that sounds like a job for scatter, not boxplot.
You will need to tweak your solution to work with the specific approach you take. Here's some code to perhaps get you started.
b = bar(rand(2,4));
hold on
x = ones(10,2).*b(2).XEndPoints;
boxchart(x(:),rand(20,1),"BoxWidth",0.15)
hold off

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by