Gnuplot, how to reduce the number of ticks on the x axis

There are too many xtics and ytics in the figure. Can I have half of them?

I know that I can manually set ticks in a way like this:

set xtics (1,2,4,8,16,32,64,128,256,512,1024)

But I believe that this is not a general solution. You cannot manually set ticks for all shapes. I have a lot of them, and gnuplot code is automatically generated using Java.

Here is the code for the picture: https://dl.dropboxusercontent.com/u/45318932/gnuplot2.plt

Can you help reduce x and y tics?

enter image description here

+5
source share
3 answers

There is no way in gnuplot to explicitly indicate the number of ticks you want on the axis, and gnuplot decides where to put them. (I really wanted them to be.)

- stats ( gnuplot 4.6+), :

ntics = 4

stats 'data.dat' using 1 name 'x' nooutput
stats 'data.dat' using 2 name 'y' nooutput
stats 'data.dat' using 3 name 'z' nooutput

set xtics x_max/ntics
set ytics y_max/ntics
set ztics z_max/ntics

, , , , .

+10

, . 2, 32:

set xrange [0:32]
set xtics 0,2,32
plot sin(x)

enter image description here

,

set xrange [0:32]
set for [i=0:5] xtics (0,2**i)
plot sin(x)

enter image description here

( 2):

set xrange [1:32]
set logscale x 2
plot sin(x)

enter image description here

+7

, , . :

endsinone(n) = strstrt(gprintf("%g", incrguess), "1")
getincr(range, maxincr, guess) = range/guess < maxincr ? guess : \
    (endsinone(guess) ? getincr(range, maxincr, 5*guess) : getincr(range, maxincr, 2*guess))

, , , , , . , , 1eN 5eN N. .. (50 , 0,0000001, 505 ). -

set xtics getincr(STATS_max, 6, 1e-9)

incr 6 , STATS_MAX > 1e-9.

0

Source: https://habr.com/ru/post/1537079/


All Articles