Hello,
I'd like to use sprintf's functionality to take the precision as an argument. In bash, this looks like following (German locale with comma as decimal symbol)):
for i in {1..10}; do printf '%.*f \n' "$i" "1,234567890123"; done
The equivalent in gnuplot should be:
do for [i=1:10] {print sprintf("%.*f",i,1.234567890123)}
However, this takes i as the input for %f and therefore displays 1.0, 2.0 etc. Am I missing something, or is this an issue with the implementation?
I should mention that I use Version 5.3 patchlevel 0 last modified 2018-11-02
Gnuplot's sprintf implementation does not cover the full range of the current glibc implementation. In particular it does not include format variants that were added for C99 or POSIX, and it does not include the dynamic field width options that you ask about.
You could, however, have gnuplot perform that step for you when constructing the format:
The nested sprintf calls work just like I wanted, thank you! Luckily I don't have too many of these so that the performance of plotting is not affected too much.