Reputation: 143
I would like to be able to overlay a number of graphs using multiplot. I would like to enable auto-scaling to get the maximum resolution but I find that each dataset is independently scaled. Does anyone know how I might be able to scale all the graphs by the same amount so that they are all correct relative to each other ?
My data is being supplied via a pipe from an external system but here is a simple example. If I plot these two signals I would like the plot scale to be +/- 2.0 (from the cos) and then the sin to be scaled appropriately so that it is only half the height of the cos, rather than both the same height.
set multiplot
plot sin(x) with lines ls 1 linecolor rgb "blue"
plot 2*cos(x) with lines ls 1 linecolor rgb "red"
unset multiplot
Upvotes: 2
Views: 1152
Reputation: 48440
No, inside a multiplot you cannot automatically rescale a previous plot based on the data of the current plot. The data of a previous plot aren't available for later manipulations (zooming, replotting, rescaling etc). Run your minimal script and try to zoom in; you'll get only the zoomed last plot.
It could be done running the stats
command for every data set to determine the maximum range.
max(x, y) = (x > y ? x : y)
min(x, y) = (x < y ? x : y)
do for [i=1:6] {
stats '-' using 1 nooutput
if (i == 1) {
ymin = STATS_min
ymax = sTATS_max
} else {
ymin = min(STATS_min, ymin)
ymax = max(STATS_max, ymax)
}
}
set yrange[ymin:ymax]
But since you are piping your data, you would need to send all data sets twice. Or you must determine the maximum range in your application and send a set xrange[...]
command to gnuplot.
Upvotes: 1