Theo Hopman wrote:
> Hi all. Why does `set format y "%5f"` not work like `set format y
> "%5g"`?
Because it doesn't. Nor is it supposed to.
It would be rather silly to have commands be different if they did the
exact same thing, wouldn't it?
> I'm dealing with numbers between 0 and 5, so I would expect both
> to produce tic labels with right justified floating point numbers in a
> field of five characters, with no trailing zeros. %5g does, but %5f
> doesn't: it produces tic labels with six decimal places and trailing zeros.
I'm afraid your expectation is based on reading the wrong documentation.
First of all, the '5' in %5f doesn't mean that the output should be
exactly 5 characters wide. It says that it shall be *at least* 5. And
it did that.
Second, if you wanted the output to fit into exactly 5 chars, you would
have to fix the precision, too. As is, you left that choice to the C
compiler that made your version of gnuplot. It picked 6, but you want 2:
set format '% 5.2f' # keep that ' ' after the '%'!
|