30243

How to control xtics in gnuplot

Question:

As the title says, I want to control the range and the amount of xtics. I use gnuplot for plotting data files in which the horizontal axes is usually time (t) taking values in the interval [0, t_max]. OK, now let's suppose the following scenario:

The maximum value of time is 4086 and this particular value is not known beforehand. However, it can be found using

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

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

Many thanks in advance!

Answer1:

To round up to the closest hundred, just use the ceil function:

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

Regarding the xtics, you can only set the start, increment, end, and explicit tic position of the tics, but not the number of ticks. But since you set the 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

Recommend

  • Linux draw pixel buffer
  • how to unregister an OSGi service
  • animating with mayavi mlab.points3d
  • animating with mayavi mlab.points3d
  • Why the result of this code is the same when the arg is different?
  • optimize in clause queries cassandra?
  • C++/GCC: How to detect unhandled exceptions in compile time
  • How to include a parent Spring project (using Git submodule)?
  • Make TryParse compatible with comma or dot decimal separator
  • CSS fixed position movement under scrollbar in Firefox
  • django running unittest fail while one of my app named “apps”, but “runserver” works
  • How to Detect and Redirect from URL with Anchor Using mod_rewrite/htaccess?
  • C: How to get rid of conversion error?
  • Only label selected breaks
  • How to connect to Sqlite in Visual Studio and create database?
  • Android : Radio Buttons keep changing their state when List View Scrolled
  • how can i have scrollbar when position is negative?
  • How to change type datatable column [duplicate]
  • How create observable with parameters in Angular 6?
  • How to convert three columns into single one
  • getting exception when inserting events in android calendar
  • Retrieving saved checkboxes' name and values from database
  • Using Facebook Graph API with ASP.NET
  • when plotting a graph using bokeh, how to remove missing date while x_axis type is datetime ,
  • Python tk scrollbar becomes inactive once text is outside the screen
  • Handle query parameters recursively using htaccess
  • Get spring boot pagination number starts from 1 instead of 0
  • Could not resolve all files for configuration ':react-native-vector-icons:classpath'
  • Smarter Removing Unnecessary WhiteSpace CSV
  • VBScript InputBox and Help Files
  • How to use AJAX to upload large CSV file? [closed]
  • Typeahead.js does give me suggestions but doesn't select them
  • VSTS work items list through REST API
  • Debug `Unexpected end of JSON input Error` on content script
  • multiple button click in asp.net MVC 3
  • Sql - ON DUPLICATE KEY UPDATE