How to change the size / ratio of a figure

14 views (last 30 days)
Hendrik
Hendrik on 11 Jan 2026
Edited: Matt J on 11 Jan 2026
Hi there,
I've plotted a simple icon for a little project I'm working on. The first picture is what it looked like before, the aspect ratio is around 9:11. After some changes to the design itself it is now more like 13:24. However when I use the old design again it's still the 13:24 ratio.
I prefer the 9:11 ratio and I dont need so much empty space at the sides.
Is there a way to change it back or set a fix size of the exportet figure?
r = 10; % Radius Kreis
s = 0.5*r; % Linienstärke
hb = 0.2*r; % Höhe Boot
gb = 0.6*r; % Größe Boot
f = 0.0; % Farbe
f = [f f f];
figure("Name","Ortsfeste Slipstelle 2","numbertitle","off")
hold on
axis equal
axis off
viscircles([0 0],r,"LineWidth",s,"Color",f); %Kreis
p1 = [0 r/cosd(22.5)];
p2 = [-r*cosd(67.5) r*sind(67.5)];
p3 = [r*cosd(67.5) r*sind(67.5)];
ausrichtung_l = p2 - p1;
ausrichtung_r = p3 - p1;
laenge = 3;
links = p1 + ausrichtung_l * laenge;
plot([p1(1),links(1)],[p1(2),links(2)],"LineWidth",s,"Color",f) %Ortsfest links
rechts = p1 + ausrichtung_r * laenge;
plot([p1(1),rechts(1)],[p1(2),rechts(2)],"LineWidth",s,"Color",f) %Ortsfest rechts
plot(0,p1(2),".","MarkerSize",2.8 * s,"Color",f) %Punkt Spitze
plot(links(1),links(2),".","MarkerSize",2.8 * s,"Color",f) %Punkt links
plot(rechts(1),rechts(2),".","MarkerSize",2.8 * s,"Color",f) %Punkt rechts
plot([-gb gb],[hb hb],"LineWidth",s,"Color",f); %Oberseite Boot
xmp = 0;
ymp = hb;
a=linspace(0,-pi, 100);
x = gb * cos(a) + xmp;
y = gb * sin(a) + ymp;
plot(x, y,"LineWidth",s,"Color",f); %Unterseite Boot
plot(-gb , hb,".","MarkerSize",2.8*s,"Color",f) %Punkt Boot links
plot(gb , hb,".","MarkerSize",2.8*s,"Color",f) %Punkt Boot rechts

Answers (1)

Matt J
Matt J on 11 Jan 2026
Edited: Matt J on 11 Jan 2026
Perhaps as follows?
axis tight
dx=diff(xlim); dy=diff(ylim);
xmax=dy/(9/11)/2;
xlim([-xmax,+xmax])

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Products


Release

R2025a

Community Treasure Hunt

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

Start Hunting!