简体   繁体   中英

how to draw rectangle Matlab?

I have coordinates, centroid, bounding box. I want to draw a colorful rectangle, but not jsut a frame like this:

rectangle('Position', stats(i).BoundingBox, ...
          'Linewidth', 3, 'EdgeColor', 'r', 'LineStyle', '--');

I want this rectangle to be red, blue..

Any ideas?

How about this function?

function h = plotRectangle(PosVector, color)

X = PosVector;

x = [X(1) X(1)+X(3) X(1)+X(3)  X(1)        X(1)];
y = [X(2) X(2)      X(2)+X(4)  X(2)+X(4)   X(2)];

h = fill(x,y,color);

end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM