Search code examples
gnuplotscientific-notation

Can gnuplot use non-normalised scientific notation to label axis ticks?


I have a plot generated by gnuplot 4.4 on Centos 6.6, whose Y axis has auto-generated ticks with the following labels:

1.9e-05
1.8e-05
1.7e-05
1.6e-05
1.5e-05
1.4e-05
1.3e-05
1.2e-05
1.1e-05
  1e-05
  9e-06

Is it possible to request, in the gnuplot script, that the axis have consistent exponents? Like this:

19e-06
18e-06
17e-06
16e-06
15e-06
14e-06
13e-06
12e-06
11e-06
10e-06
 9e-06

I think it would make the values easier to read and understand at a glance.

I do realise that scientific notation is conventionally normalised such that the coefficient sits in the range [0,1]. I'd like to turn that off.


Solution

  • Gnuplot can't do this automatically. You would need to select the desired exponent, scale your data appropriately and add the exponent manually to the format:

    exponent = -6
    set format y '%.0f'.sprintf('e%d', exponent)
    scale = 10**(-exponent)
    plot 'data.dat' using 1:($2*scale)
    

    Edit: For your specific example you could use gnuplots ability to use scientifc powers (multiple of three):

    set terminal pngcairo enhanced font 'DejaVu Sans'
    set encoding utf8
    set format y '%.0s✕10^{%S}'
    set xrange [9:19]
    plot 1e-6*x
    

    Note, that the utf8 encoding is required here only for the multiplication sign ✕ (U+2715). Output with gnuplot 4.4.4 is

    enter image description here