Question

I found this very helpful post here on plotting a heat-map on a non-uniform grid: Heatmap with Gnuplot on a non-uniform grid

Now everything works great if I put the suggested commands manually in gnuplot. However, I want to automate the graph by writing a shell-script that I can call directly in my fortran code.

This is the script (Map_Ent.sh):

#!/bin/bash
gnuplot <<- EOF

set pm3d map corners2color c1
set autoscale fix
set ytics 1
splot 'Career_Choice.txt' using 1:($2-0.5):3  

EOF

eog Ent_map.png &

And this is how I call it in Fortran:

call SYSTEM('bash ./Map_Ent.sh')

However my graph is completely white when I do it this way. Any ideas on what I am doing wrong? I would be very thankful for any suggestions!

Était-ce utile?

La solution

The $2 is interpreted by bash and evaluates to nothing. Therefore, gnuplot plots only -0.5. $2 is a shortcut for column(2). Just use the latter and it should work fine:

#!/bin/bash
gnuplot <<- EOF

set pm3d map corners2color c1
set autoscale fix
set ytics 1
splot 'Career_Choice.txt' using 1:(column(2)-0.5):3  

EOF

There is no need to use bash as intermediate step, just use a gnuplot script:

file.gp:

set pm3d map corners2color c1
set autoscale fix
set ytics 1
splot 'Career_Choice.txt' using 1:(column(2)-0.5):3 

And then

call SYSTEM('gnuplot -persist file.gp')

(I'm not sure about the fortran call, just copied from the question).

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top