J. Doe
J. Doe

Reputation: 33

Gnuplot segmentation fault

I use ubuntu 16.04 LTS and gnuplot 5.0 patchlevel 3. This is the data file I have and I want to plot it like a heatmap. When I enter this in gnuplot:

set terminal png size 1200,1000 
s=101
set size square
unset tics
unset border
set view map
do for [i=0:0]{
set autoscale fix
set output sprintf("esatad%.0f.png", i)
plot 'itp.txt' u 1:2:3 every:::(i*s)::(s+i*s) notitle w image
}

I get the following error "segmentation fault (core image recorded)" and then gnuplot is closed. But when I change 2 lines of the code and try to plot it as a surface:

set terminal png size 1200,1000 
s=101
set size square
unset tics
unset border
set hidden3d
do for [i=0:0]{
set autoscale fix
set output sprintf("esatad%.0f.png", i)
splot 'itp.txt' u 1:2:3 every:::(i*s)::(s+i*s) notitle w l
}

I get this image, which is what I want except that it is not a "heatmap". I guess that's it, I have no idea of what is happening... sorry, I'm really a newbie. Also, I've been warned (in this website) about pm3d and dgrid3d plots in which "the colors in your image will not correspond directly to the data in your file." Therefore w image should be prefered. I don't even know if that is relevant, but anyway, what should I do?

Edit: I forgot to say that the "w image" code generates an image with labels and axis but the plot frame is entirely black...

Upvotes: 0

Views: 2389

Answers (2)

Mahdi Shafiei
Mahdi Shafiei

Reputation: 1

I had the same problem.

Let's say you have a grid of 10 x 20 data. If the number of all data lines are not equal, for example, one set has 9 lines and the rest have 10 lines, it will generate a segmentation fault (it shouldn't, however).

Maybe double check data if any line is missing.

Upvotes: 0

user8153
user8153

Reputation: 4095

I don't know why you are getting a segmentation fault; that should not happen. It might be worth trying to update to a more recent version of gnuplot.

It seems to me that you might be off by one in your every statement. The following works for me (gnuplot 5.2.2):

set terminal png size 300,250
s=101
set size square
unset tics
unset border
set view map
do for [i=0:4]{
set autoscale fix
set output sprintf("esatad%.0f.png", i)
plot 'itp.txt' u 1:2:3 every:::(i*s)::(i*s+s-1) notitle w image
}

enter image description here enter image description here enter image description here enter image description here enter image description here

Upvotes: 0

Related Questions