I need to make plot like this:
1.JPG
I know how to plot each individually but dont know how to plot them next to each other like the image.

10 件のコメント

Philippe Lebel
Philippe Lebel 2020 年 1 月 15 日
編集済み: Philippe Lebel 2020 年 1 月 15 日
inlcude the code that produces the box plots you want to merge please.
Adam Danz
Adam Danz 2020 年 1 月 15 日
編集済み: Adam Danz 2020 年 1 月 15 日
Hint:
hold on
bar(. . .)
plot(1.25, y, 'ko')
errorbar(. . .)
Zeynab Mousavikhamene
Zeynab Mousavikhamene 2020 年 1 月 15 日
it is simply like this:
boxplot(T{(find_groups == No_class_images(k)),var(i)},'widths',0.1)
Thanks I tried it like what you mentioned before but it did not work.
Zeynab Mousavikhamene
Zeynab Mousavikhamene 2020 年 1 月 15 日
@Walter Roberson any suggestion?
Adam Danz
Adam Danz 2020 年 1 月 15 日
Sure it does,
What did you try and what didn't work?
200115 145536-Figure 1.png
Zeynab Mousavikhamene
Zeynab Mousavikhamene 2020 年 1 月 15 日
I tried
figure (1)
boxplot(y)
hold on
plot(2,y)
hold off
but it did not work.
I used 2 in x-axis of the second plot because the default for boxplot's x-axis is 1 (you can see in the image) so I tried to be next to the boxplot.
Adam Danz
Adam Danz 2020 年 1 月 15 日
" it did not work" doesn't tell me much.
Here are some more tips.
  • y should be a vector.
  • Specify black circle markers using 'ko'.
  • you still need to use errorbar() if you want the magenta errorbar.
Zeynab Mousavikhamene
Zeynab Mousavikhamene 2020 年 1 月 15 日
As I said in the question, each plot is produced individually so the points mentioned above (being vector, using 'ko',...) does not change the issue I have.
Yes 'it did not work' is not clear. Let me tell more about it: Using above code the boxplot was produced but the nex plot (the plot after hold on) was not shown. it was only boxplot.
Adam Danz
Adam Danz 2020 年 1 月 15 日
" so the points mentioned above (being vector, using 'ko',...) does not change the issue I have"
It's hard to address the issue you're having when you haven't explained what the issues are.
This line from your code plot(2,y) will definitely not produce the plot you want since it will produce lines, not black circular markers. So the 'ko' does address that problem. If y were a matrix, it would also produce undesired effects which is why y must be a vector - but again, we don't know what the issues are.
'Using above code the boxplot was produced but the nex plot (the plot after hold on) was not shown"
Ahhhh... there we go. The points created by plot() are plotted but you just can't see them.
Here's your fix:
xlim([0,3])
Zeynab Mousavikhamene
Zeynab Mousavikhamene 2020 年 1 月 15 日
xlim worked. Thank you. Can you move your comment to answers so that I can accept?

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

 採用された回答

Adam Danz
Adam Danz 2020 年 1 月 16 日
編集済み: Adam Danz 2020 年 1 月 17 日

1 投票

Summary of comments under the question
The problem was that the x axis limit was [0,1] while the plotted data were at x=2.
The solution:
xlim([0,3])

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeData Distribution Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by