Printed Figure Font Size

Hello,
I have for example the following code:

figure()
axes()
plot([1 5],[2 20],'r')
ylabel('Something 2')
xlabel('Something 1')
set(gca, 'FontSize', 16)
set(gca, 'Position', [0.1 0.12 0.8 0.8])
print('Test.png')

The figure generated by this commands looks like the uploaded image “Scrennshot.png”. However, the print command gives the result shown in the uploaded image “Print.png”. As you can see the FontSize is much bigger than in the actual figure and as a result the x- and ylable are partly outside the image boundary. Do you guys have any idea how to fix this?

Thanks and best regards,
Scooba

My system

  • OS: Windows 10 Pro 10.0.18363
  • Octave version: Version 6.1.0
  • Installation method: Downloaded and installed “octave-6.1.0-w64-installer.exe” from https://www.octave.org/download.html

The font size onscreen being smaller than in printout is a known issue (see this bug). Now for the problem at hand, when you change the position property you also make it a constraint, and text labels are pushed outside the limits when the fonsize increases. The workaround is to reset the positionconstraint (which used to be activepositionproperty in older versions) to outperposition:

figure()
axes()
plot([1 5],[2 20],'r')
ylabel('Something 2')
xlabel('Something 1')
set(gca, 'FontSize', 16)
set(gca, 'Position', [0.1 0.12 0.8 0.8], 'positionconstraint', 'outerposition')
print('Test.png')

image

Hey, thanks for your reply. Good to know! However, the ‘outerposition’ constraint for me only works for the xlabel.

figure()
axes()
plot([1 5],[2 20],'r')
ylabel('Something 2')
xlabel('Something 1')
set(gca, 'FontSize', 16)
set(gca, 'Position', [0.1 0.12 0.8 0.8], 'activepositionproperty', 'outerposition')
print('Test2.png')

Yes, sorry after setting the position, the outerposition ends up with negative origin.
If your aim is to add a margin, then another workaround is to directly change the outerposition:

figure()
axes()
plot([1 5],[2 20],'r')
ylabel('Something 2')
xlabel('Something 1')
set(gca, 'FontSize', 16, 'outerposition', [0.03 0.03 0.94 0.94])
print('Test3.png')

Ah okay, thank you! That helps a lot!