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

43 visualizaciones (últimos 30 días)
TAUFIQ SAIDIN
TAUFIQ SAIDIN el 17 de Mayo de 2021
Comentada: TAUFIQ SAIDIN el 17 de Mayo de 2021
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 comentarios
David Fletcher
David Fletcher el 17 de Mayo de 2021
You might want to have a look at the fill command as well - a bit more versatile
TAUFIQ SAIDIN
TAUFIQ SAIDIN el 17 de Mayo de 2021
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

Iniciar sesión para comentar.

Respuesta aceptada

KSSV
KSSV el 17 de Mayo de 2021
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 comentario
TAUFIQ SAIDIN
TAUFIQ SAIDIN el 17 de Mayo de 2021
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 😊

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Annotations en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by