Search code examples
plotgnuplotgnuxticks

How to control tic marks and their values in gnuplot tics


My plot has logx axis. So I want to show the tic marks. But due to the size of the tic values they overlap. For example: enter image description here

But if I reduce the tic marks by the command

set xtics (1.0e-7,1.0e-5, 5.0e-4);

It becomes like enter image description here

I want those logarithmic tics(like the first picture) but only three values written(like the second picture) without compromising the size. Is it possible?


Solution

  • As I understand you basically want keep all the auto tics and grid lines, but remove 1e-6 and 1e-4 tic labels and add a 5e-4 tic label.

    You could do it the following way. Check help xtics and help format specifiers.

    Code:

    ### set custom tics
    reset session
    
    set xrang[1e-7:5e-4]
    set logscale x
    set grid x,y
    set format x "%.0t x 10^{%T}"
    set rmargin 5
    
    set xtics add ('' 1e-6, '' 1e-4, 5e-4)
    plot x
    ### end of code
    

    Result:

    enter image description here