How do I plot rectangles with filled color on a 2D plot?

43 ビュー (過去 30 日間)
TAUFIQ SAIDIN
TAUFIQ SAIDIN 2021 年 5 月 17 日
コメント済み: TAUFIQ SAIDIN 2021 年 5 月 17 日
Hi all,
Seeking helps from esteemed Matlab users/experts.
I need help on how to plot rectangles with filled color on a cartesian coordinate (2D) plot. Please see attached figure below the expected plot I am looking forward to.
Regards,
Taufiq
  3 件のコメント
David Fletcher
David Fletcher 2021 年 5 月 17 日
You might want to have a look at the fill command as well - a bit more versatile
TAUFIQ SAIDIN
TAUFIQ SAIDIN 2021 年 5 月 17 日
Thank you @David Fletcher 😊 for recommending an alternative to rectangle method, which looks me to a little bit more simple and more flexible as you said

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

採用された回答

KSSV
KSSV 2021 年 5 月 17 日
Read about fill, patch. You need to have coordinates of the vertices.
Example:
% Vertices of rectangle
P = [0 0 ;0 1; 1 1; 1 0] ;
patch(P(:,1),P(:,2),'r','EdgeColor','k')
  1 件のコメント
TAUFIQ SAIDIN
TAUFIQ SAIDIN 2021 年 5 月 17 日
Thank you @KSSV for recommending an alternative method to rectangle i.e. patch. As suggested by @David Fletcher earlier, now I know at least these are 3 methods I could use to accomplish my objective:
Truly appreciate it guys 😊

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by