Gnuplot plot don't fill canvas

时间:2018-12-19 11:39:09

标签: shell gnuplot

I'm checking results of my simulation. I need to do 2d maps of a 3d surfaces. I did a lot of times in the past with gnuplot.

I created a script to do it faster:

#!/usr/bin/gnuplot
set term pdf size 600, 400
set output "Corr_57res_1bpi.pdf"
set view map
set xrange [0:20000]
set yrange [20:221]
set cbrange [-1:1]
set ylabel "Temperatures"
set xlabel "Number of seqs"
#set clabel "Delta correlation"
set title "Delta Correlation"
plot 'corr_57res_1bpi.dat' u 1:2:3  w image

The input file has this format:

10000 102 0.710468
1000 102 0.672530
20000 102 0.709955
5000 102 0.702273
10000 20 0.512186
1000 20 0.485288
20000 20 0.487161
5000 20 0.506256
10000 221 0.636247
1000 221 0.559779
20000 221 0.621900
5000 221 0.614103
...

Last time I used this script (like 1 month ago) i obtained a correct 2d maps that fill the border of the canvas.

Now I'm retry to do it and i obtained this result: Wrong results

I tried to fix the code, but nothing happens, also i tried to update gnuplot to 5.2.5 (i had 5.0 previously) but nothing happens. Also the other typse of plot work perfectly. I'm running out of ideas, so i hope you can help me. Regards Matteo

1 个答案:

答案 0 :(得分:1)

对于with image样式,生成的图像的“边界框”在src/graphics.c中初始化为:

  p_start_corner[0] = points[0].x;
  p_start_corner[1] = points[0].y;
  p_end_corner[0] = points[p_count-1].x;
  p_end_corner[1] = points[p_count-1].y;

这实际上意味着数据文件的第一个点和最后一个点确定了图的整个“范围”。通过不对数据文件本身中的记录顺序进行排序,可以首先对数据进行排序,从而使脚本更加健壮:

set view map
set xrange [0:20000]
set yrange [20:221]
set cbrange [-1:1]
set ylabel "Temperatures"
set xlabel "Number of seqs"
#set clabel "Delta correlation"
set title "Delta Correlation"
plot '<sort -k1,1n -k2,2n corr_57res_1bpi.dat' u 1:2:3 w image