The displayed axis labels are strings formatted independently from the command window numerical display (which the format
command controls). The way to change this is to get
the xaxis values, create a char array with the format you actually want, then set
that to a new set of xlabels. See below, modified from a matlab central answer for an older version of matlab:
>> hist (sin(1:40)) ## generate a sample histogram
which will generate:
>> xt = get (gca, 'xtick') ## get numbers used to make current labels
xt =
-1.0000 -0.5000 0 0.5000 1.0000
Now we can convert to a character array that will have the format you want:
xt_label = num2str (xt.') ## convert to column vector, then to character vectors
>> xt_label = num2str (xt.')
xt_label =
-1
-0.5
0
0.5
1
Get a format you want using formatting codes:
>> xt_newlabel = num2str (xt.', '%.3f')
xt_newlabel =
-1.000
-0.500
0.000
0.500
1.000
See https://docs.octave.org/latest/Output-Conversion-Syntax.html for a description of the format codes.
Once you have a format you want, display it using the set
command.
>> set(gca, 'xticklabel', xt_newlabel)
which will cause the modified labels to be displayed: