How can I show the max. and/or the min. value(s) of of a graph in a plot at their appropriate position automatically?
The set xrange command sets the horizontal range that will be displayed. A similar command exists for each of the other axes, as well as for the polar radius r and the parametric variables t, u, and v. where 5#5min6#6 and 5#5max6#6 terms are constants, expressions or an asterisk to set autoscaling.
To plot functions simply type: plot [function] at the gnuplot> prompt. Discrete data contained in a file can be displayed by specifying the name of the data file (enclosed in quotes) on the plot or splot command line. Data files should have the data arranged in columns of numbers.
5.9 Does gnuplot support multiple y-axes on a single plot? Yes. 2D plots can have separate x axes at the bottom (x1) and top (x2), and separate y axes at the left (y1) and right (y2).
splot is the command for drawing 3-d plots (well, actually projections on a 2-d surface, but you knew that). It can create a plot from functions or a data file in a manner very similar to the plot command. See plot (p. ) for features common to the plot (p. ) command; only differences are discussed in detail here.
You can do this "semi-automatically" using the stats
command. This command can extract some statistical values from a data set, but requires some reworking:
Extract the minimum and maximum y-values, assuming that your data file has two columns, the x-value in the first, the y-values in the second column
stats 'file.dat' using 2 nooutput name 'Y_'
This gives you the min/max y-values in the variables Y_min
and Y_max
, but not the corresponding x-value.
The previous step gives you only get the respective indices, which requires you to run stats
again in order to get the x-values:
stats 'file.dat' using 1 every ::Y_index_min::Y_index_min nooutput
X_min = STATS_min
stats 'file.dat' using 1 every ::Y_index_max::Y_index_max nooutput
X_max = STATS_max
Set labels and/or points at the respective coordinates
set label 1 sprintf("%.2f", Y_min) center at first X_min,Y_min point pt 7 ps 1 offset 0,-1.5
set label 2 sprintf("%.2f", Y_max) center at first X_max,Y_max point pt 7 ps 1 offset 0,1.5
...
plot ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With