Gnuplot how to lower the number of tics in x axis

前端 未结 4 413
故里飘歌
故里飘歌 2020-12-06 18:42

The figure has too many xtics and ytics. Can I have half of them?

I know I can manually set tics in a way similar to this:

set xtics (1,2,4,8,16,32,6         


        
4条回答
  •  我在风中等你
    2020-12-06 19:14

    I had a similar problem that I wanted to handle a little more generically in case the data changes while still using somewhat round looking numbers. Therefore I made a helper function:

    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))
    

    Then I just have to pass in the range for the axis, the most increments I want on it, and a very lower bound guess about what I would expect the smallest possible increment to be. To keep the rounded looking numbers my functions assume the guess is expressible in the form 1eN or 5eN for some value N. Ie (50 is good, so is 0.0000001, 505 is not). With this function you just have to do something like

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

    will return an incr of less than 6 tics, and there should be several of them assuming STATS_MAX > 1e-9.

提交回复
热议问题