To my understanding there should be one empty space between numbers and units.
However, in gnuplot the prefix %c
(see help format specifiers
) for numbers from 1-999 apparently seems to be ' '
instead of ''
.
So, in the example plot below neither the xtic labels nor the ytic labels are all correct.
Either you have some tic labels with zero space or with two spaces, but not all with one. It's a detail and maybe some people won't even notice, but if possible I would prefer to do it the correct way.
Quite some time ago I placed a bug report, but no response so far.
Is there maybe an immediate workaround?
Code:
### wrong prefix for %c 1-999
reset session
set size ratio -1
set logscale xy
set format x "%.0s%cΩ" # no space
set format y "%.0s %cΩ" # one space
set xrange [1e-3:1e12]
set grid x, y
plot x
### end of code
Result:
Addition:
Based on the answer of @maij pointing to the source code, here is a gnuplot attempt to "fix" this, which should be easily transferred to C.
Code:
### gnuplot "fix" for prefix for %c 1-999
prefix(power) = "yzafpnum kMGTPEZY"[(power+24)/3+1 : (power+24)/3 + sgn(abs(power))]
do for [power=-24:24:3] {
print sprintf("% 3g '%s'", power, prefix(power))
}
### end of code
Result:
-24 'y'
-21 'z'
-18 'a'
-15 'f'
-12 'p'
-9 'n'
-6 'u'
-3 'm'
0 '' # zero length
3 'k'
6 'M'
9 'G'
12 'T'
15 'P'
18 'E'
21 'Z'
24 'Y'
question from:
https://stackoverflow.com/questions/65863357/gnuplot-how-to-get-c-zero-space-for-numbers-1-999 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…