GNU Octave font size fix

If GNU Octave plot fonts are too small or the lines are too thin in GNU Octave plotting, typically the first of these methods will be adequate, the others are for reference.

Octave has multiple graphics “toolkits” or “backends”, and prefers QT. If you don’t want the graphical IDE, start Octave with octave -no-gui instead of octave-cli. Using octave-cli disables the QT backend.

Default plot settings are for qt backend. Avoid setting font sizes in the program itself. Tweaking plots for a aparticular computer display may reduce plot fidelity on other computers with different displays.

The “correct” way to scale plot fonts is thus to change your system defaults. Add this to ~/.octaverc instead of ~/Documents/MATLAB/startup.m so that you don’t disturb Matlab’s plotting defaults.

set(0, "defaulttextfontsize", 24)  % title
set(0, "defaultaxesfontsize", 16)  % axes labels

set(0, "defaulttextfontname", "Courier")
set(0, "defaultaxesfontname", "Courier")

set(0, "defaultlinelinewidth", 2)

adjust 16 to produce the most appealing text labels in:

  • axes tick labels
  • legend key
  • title text

defaultline is the root category for lines, so defaultlinelinewidth is not a typo.


The alternative methods below are not normally needed, but are for reference. PPI adjustments: find your PPI by Internet search or spec sheet. Octave’s PPI estimate is:

get(0, 'screenpixelsperinch')

If Octave’s PPI estimate is too small, this is probably why your plot text is too small–Octave thinks your resolution is much less than it really is.

If still a font size problem, try changing system DPI scaling. On Ubuntu, try Gnome Tweak Tool → Fonts → Scaling Factor Octave GUI settings:

  • → General → Interface → Icon Size: large
  • → Editor Styles → Octave: default
  • → Terminal → Font Size

You can also try changing the graphics toolkit. Usually Qt is the best and most modern.

Octave graphics toolkits available:

available_graphics_toolkits()

Active graphics toolkit:

graphics_toolkit()

Select graphics toolkit to see if font sizes are better. Be sure to open a new figure when trying different graphics toolkits.


GNU Octave default settings docs


Related: GNU Octave set defaults