I have a data file with matrices split into different gnuplot indices. I wanna do an animation of a density plot evolving with time (=index).
The problem is that I want to keep the maximum and minimum of the cbrange symmetric while allowing it to change with time.
In the code below, the first stats command simply gives me the number of blocks for the loop. The second stats command with prefix "B" should give me the max and min values for the matrix at each index, so I can set cbrange properly.
The first time the code enters the loop it works (for i=1) and stats gives me the proper numbers. Starting on the second loop (i=2) stats gives me wrong numbers...
I've tried to set cbrange and zrange to [*:*] before the stats command, but it doesn't help.
Here's the code:
set terminal gif animate delay 0.5
set output 'foobar.gif'
stats 'dat-rw2d.dat' nooutput
set pm3d map
set palette defined (-1 "blue", 0 "white", 1 "red")
print STATS_blocks
do for [i=1:int(STATS_blocks)] {
print i
stats "dat-rw2d.dat" index (i-1) matrix nooutput prefix "B"
max = (B_max > -B_min)?(B_max):(-B_min)
set cbrange [-max:max]
print B_max, B_min
splot 'dat-rw2d.dat' matrix index (i-1)
}
If I don't plot anything (code below), the stats give me the correct numbers. So it is actually the splot that is causing the problem. It's fixing some scale and getting in the way of stats? I've tried to set cbrange [*:*] before the stats, but it doesn't solve the problem.
do for [i=1:int(STATS_blocks)] {
print i
stats "dat-rw2d.dat" index (i-1) matrix nooutput prefix "B"
max = (B_max > -B_min)?(B_max):(-B_min)
set cbrange [-max:max]
print B_max, B_min
}
This is not a bug. If you use
statswith thematrixoption you must explicitely specify which column to use to get the correct values. If you don't, then gnuplot probably uses one of the matrix dimensions, which doesn't change between blocks and you always get the same values.In the loop use