Search code examples
gnuplot

Plotting sections of 2D plot (data) in GNUPLOT


I am trying to plot a 'heatmap' and 'a cut of that heatmap' at a specific position using the data at the bottom. I would like to use use the every command in gnuplot to do so, but I fail. every ::13::17: is supposed to plot data from the line 13 to line 17. I am getting an error from gnuplot.

reset
set terminal pngcairo 
set output 'stack.png'
set palette defined (0 "white", 1 "red")
unset key
set style fill solid
#----------------- 2D plot ---------------
plot 'stack.dat' using 1:2:(log10($3))  with boxes linecolor palette notitle 
# ---- PLot a section of the 2D plot ----------
set output 'oups.png'
plot 'stack.dat' using 2:(log10($3)) every ::13::17: with lines notitle 

'stack.dat' is the datafile name

1 1        0.081051938235759735
1 2        0.039051856845617294
1 3        0.017708625644445419
1 4        0.053782138973474503
1 5        0.069525197148323059

2 1        0.046054631471633911
2 2        0.005992549471557140
2 3        0.010819308459758759
2 4        0.001308800885453820
2 5        0.032604649662971497

3 1        0.078480839729309082
3 2        0.000435109512181953
3 3        0.073167815804481506
3 4        0.052882101386785507
3 5        0.016808584332466125

4 1        0.060769289731979370
4 2        0.028200428932905197
4 3        0.031424820423126221
4 4        0.052520859986543655
4 5        0.078694045543670654

5 1        0.029850590974092484
5 2        0.027807384729385376
5 3        0.036195535212755203
5 4        0.026242787018418312
5 5        0.048620097339153290

How can I make it works? Is there a better way to plot sections of heatmap?


Solution

  • The short answer is to use

    plot 'stack.dat' using 2:(log10($3)) every :::2::2 with lines notitle

    When you have multiple blocks of records there is a distinction between lines in a datafile and records. So in order to specify a data sequence, you need the block and record indexes. Check the docs for more info (see Every): http://gnuplot.sourceforge.net/docs_5.2/Gnuplot_5.2.pdf