gnuplot - GNU set heatmap axis limits around a dynamically computed point -
i'm plotting heatmap in gnuplot text file in matrix format:
z11 z12 z13 z21 z22 z23 z31 z32 z33
and forth, using next command (not including axis labelling, etc, brevity):
plot '~/some_text_file.txt' matrix notitle image
the matrix quite large, in excess of 50 000 elements in bulk of cases, , it's due size of y-dimension (#rows). know if there's way alter limits in y-dimension set number of values around maximum, while keeping x , z dimensions same. e.g. if maximum in matrix @ [4000, 33], want y range centred @ 4000 +- let's 20% of length of y-dimension.
thanks.
edit:
the solution below right idea, works in illustration not in general because bug in how gnuplot uses stats
command matrix files. see comments after reply farther info.
you can using stats
indices correspond maximum value dynamically.
consider next file named data
:
0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1 5 3 4 0 1 2 3 4
if run stats
i get:
gnuplot> stats "data" matrix * file: records: 25 out of range: 0 invalid: 0 blank: 0 info blocks: 1 * matrix: [5 x 5] mean: 2.1200 std dev: 1.5315 sum: 53.0000 sum sq.: 171.0000 minimum: 0.0000 [ 0 0 ] maximum: 5.0000 [ 3 2 ] cog: 2.9434 2.0566
the maximum value in position [ 3 2 ]
meaning row 3+1 , column 2+1 (in gnuplot first row/column number 0). after running stats
variables created automatically (help stats
more info), stats_index_max_x
, stats_index_max_y
among them, store position of maximum:
gnuplot> print stats_index_max_x 3.0 gnuplot> print stats_index_max_y 2.0
which can utilize automatically set ranges. now, because stats_index_max_x
gives y (instead of x) position, you'll need careful. total number of rows obtain range can obtained scheme phone call (there might improve built-in function, not know):
gnuplot> range = system("awk 'end{print nr}' data") gnuplot> print range 5
so you'll do:
stats "data" matrix range = system("awk 'end{print nr}' data") range_center = stats_index_max_x d = 0.2 * range set yrange [range_center - d : range_center + d]
which center yrange
@ position of maximum value , stretch +-20% of total range.
the result of plot "data" matrix w image
now
instead of
gnuplot heatmap
No comments:
Post a Comment