Drawing a rectangle over existing plot
古いコメントを表示
I have a subplot in Matlab with two plots. (first picture) I want to draw boxes as seen in the second picture, for specific xvalue ranges. I tried annotation however it does not span all plots. Anybody able to help me?


3 件のコメント
Adam Danz
2020 年 7 月 28 日
" I tried annotation however it does not span all plots."
If that's the only problem, it sounds like you applied the annotation incorrectly. Annotation is the way to go.
gummiyummi
2020 年 7 月 31 日
That's a clearer problem; and a tough one.
The annotation function has been around for a long time and many people have requested that the function accept location values in data-units rather than normalized figure units. Obviously these wishes have never been granted.
See answer for a cleaner solution.
採用された回答
その他の回答 (1 件)
Vahidreza Jahanmard
2023 年 11 月 14 日
To plot the rectangles, you can use this:
% do all your plots
annotation('rectangle',[x y w h]);
for x, y, w, and h, you can plot one time and set the place of the rectangle manually and copy the position to your code
カテゴリ
ヘルプ センター および File Exchange で Axes Appearance についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

