Reputation:
How do I change x axis window range in gnuplot for dynamic run time changing data. Presently my range shows a window size from 0 to t, where t keeps increasing. But I want the range to be [t - 2000, t]. I have been looking into how to use xrange, but couldn't get it working.
I also looked at the link, but it didn't help. Dynamically changing the range of a histogram in gnuplot?
Any help would be appreciated.Thanks
Upvotes: 1
Views: 1230
Reputation: 2442
In linux you can obtain the last 2000 lines of a file with the tail
command:
tail -n2000 file.dat # if data is sorted
sort file.dat | tail -n2000 # if data is not sorted
The output of these commands can be plotted within gnuplot as:
plot "< tail -n2000 file.dat"
plot "< sort file.dat | tail -n2000"
This is equivalent to plot the data in the range [xmax-2000:xmax]
.
In windows, there exists a Sort
command, and there is a Tail
command in the Windows Server 2003 Resource Kit Tools. You can also download the unix-commands for windows from the package GNUWin32. The syntax to call these programs are similar to the ones I have described above.
Upvotes: 0
Reputation: 2187
You can either plot the datafile twice in your script, after the first (dummy) plot the variable GNUPLOT_DATA_X_MAX
contains what it's name says.
Or you use the stats
command on your data before plotting, afterwards there is a variable STATS_max_x
that you can use to set the desired range for your plot.
Upvotes: 1