How to manage xtics in gnuplot

As the name says, I want to control the range and number of xtics . I use gnuplot to build data files in which the horizontal axes are usually time (t) taking values ​​in the interval [0, t_max]. Ok, now let's say the following scenario:

The maximum time value is 4086, and this specific value is not known in advance. However, it can be found using

 stats "data.out" u 1 set xrange [0:STATS_max] 

My question is, how can I round the maximum value of t to the nearest hundred (in this case 4100)? Also, is there a way to tell gnuplot to print only 5 ticks on the horizontal axes regardless of its range (rounding the maximum value to the nearest hundred, or a decade that will always be divided by 5)?

Thank you very much in advance!

+1
source share
1 answer

To round to the nearest hundred, just use the ceil function:

 set xrange[0: 100*ceil(STATS_max/100.0)] 

As for xtics , you can only set the start, incremental, end and explicit tick positions of ticks, but not the number of ticks. But since you set xrange manually, you can use this information to calculate the tic frequency:

 x_lim = 100*ceil(STATS_max/100.0) set xrange[0: x_lim] set xtics x_lim/4.0 
+1
source

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


All Articles