formatgnuplot

Set tick labels format automatically


There are new requirements at my work regarding the format of tick labels on the graph. Formerly they used to be indifferent to a format, so it could be like "1,5e-7", but now they demand to use, for example, "1; 1,5; 2..." if possible and "1·10-7; 1,5·10-7; 2·10-7" otherwise. But in a gnuplot script I can use only one kind of formatting for the axis at the same time, like %g or %t^{%T}. Is there a way to set the format like %g but to change "eX" to "·10X"?


Solution

  • Not sure if set format "%h" is the solution you are looking for. Check the different formats for x- and y-axes.

    From help format_specifiers:

    %h or %H %g with "x10^{%S}" or "*10^{%S}" instead of "e%S" 
    

    Script:

    ### different tic formats
    reset session
    
    set xrange[1e-9:1e9]
    
    set logscale x
    set logscale y
    
    set format x "%g"
    set format y "%h"
    
    plot x
    ### end of script
    

    Result:

    enter image description here