How do I stop patch from making my squares into rectangles?
Ältere Kommentare anzeigen
Hi all,
I am trying to call patch multiple times to draw multiple squares. I am using patch because even though I am currently drawing squares, I am planning to draw a more complex polygon later on.
However I am facing a problem: even though the coordinates should create a 1x1 size square, matlab is stretching my polygon and drawing a rectangle. Additionally, I want my squares to be bigger, but changing my 1x1 square to a 2x2 square does not change the size. How can I adjust the polygon drawn by patch? It's ok for my squares to resize if I maximize/ stretch the figure, but I want some control over the initial size and shape.
Here is some code which produces the unexpected result:
x1 = [0 1 1 0];
y1 = [0 0 1 1];
x2 = [1.2 2.2 2.2 1.2];
y2 = [0 0 1 1];
x3 = [2.4 3.4 3.4 2.4];
y3 = [0 0 1 1];
patch(x1,y1, 'red')
patch(x2,y2, 'blue')
patch(x3,y3, 'green')
Here is the figure:

I can tell by reading the axes of the chart that my 'squares' are 1x1, but the figures drawn are rectangles. I want to make them squares.
I would really appreciate help with this. I have tried both 'truesize' and set(gcf,'Resize','off') but they stop the figure from resizing and do not force my squares to be 1 pixel by 1 pixel as I expected.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Polygons finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
