User Tools

Site Tools


software:octave:start

Octave

Installation

To always get the last version, install Octave through Flatpak, from Flathub.

Resize figure

To resize a figure, change its property position which is a four-element vector of the form:

[x-lower-left-corner y-lower-left-corner width-figure height-figure]

x = (1:10);
y = (1:10);
plot(x, y);
xlim([1 10]);
ylim([1 10]);
xlabel("x");
ylabel("y");

f = gcf();

pos = get(f, "position");
pos(3:4) = pos(3:4) * .5;
set(f, "position", pos);

print(["resize-figure"], "-dpdfcrop");
Figure 1: Figure shrinked changing its paramenter position.

Change axes margin

To change the margins around the axes, vary the last two parameters of the vectors position.

x = [1:10];
y = x.^2;
plot(x, y);
xlabel("x");
ylabel("y");

f = gcf();
set(f, "units", "pixels");
pos_figure = get(f, "position")

a = gca();
set(a, "units", "pixels");
pos_axes = get(a, "position")
pos_axes(3) = pos_figure(3) - pos_axes(1) - 10;
pos_axes(4) = pos_figure(4) - pos_axes(2) - 10;
set(a, "position", pos_axes);
Figure 2: Margins around axes are changed according to the dimensions of the figure.
software/octave/start.txt · Last modified: 2023/05/28 16:37 by 127.0.0.1