0
votes

I have a script that generates a gnuplot file, I have edited so I have 2 sets of data in the same plot. One is multiplied by -1 to change color. However, only one set appears in the plot, the last one stated. The script is the following.

set arrow from  graph 0,first 0.61237, graph 0 to graph1,first0.61237,0 nohead front lt -1
set arrow from  graph 0,first 1.67303, graph 0 to graph 1,first 1.67303,0 nohead front lt -1
set arrow from  graph 0,first 2.53906, graph 0 to graph 1,first 2.53906,0 nohead front lt -1
set arrow from  graph 0,first 3.24616, graph 0 to graph 1,first 3.24616,0 nohead front lt -1
set arrow from  graph 0,first 3.74616, graph 0 to graph 1,first 3.74616,0 nohead front lt -1
set arrow from  graph 0,first 4.74616, graph 0 to graph 1,first 4.74616,0 nohead front lt -1
set pm3d at b
unset surf
set view 180,90
set palette defined (-1 "red",0 "white", 1 "blue");
set grid xtics mxtics ytics
unset border
set xrange [-10:40]
set xtics -10,((40+10)/5),40
set mxtics 3
set yzeroax lt 2
set ytics ("L" 0.0,"K" 0.61237,"G" 1.67303,"L" 2.53906,"W" 3.24616,"X" 3.74616,"G" 4.74616)

set cbrange resto
set cbrange[-1:1]
set colorbox
set terminal png enhanced  nocrop  size 1920,1080
set out "SPF_NO_SO.png"
splot "specfun.pm3d" u ($1*13.60569806):2:(1*$4/476.70750366666666666666),\
      "specfun.pm3d" u ($1*13.60569806):2:(1*$3/573.04673900000000000000)
unset out

Sample image:

Sample Image

The script produces the desired plot only for the negative set. If I flip the order I get the blue one.

Here is a sample data: data_sample FYI-these arrays are quite big

1
It's a little hard to see from the image, but aren't you just plotting many lines on a two-dimensional graph? If so it might be better to use plot instead of splot... - user8153
There's a weight to each point,the last coordinate. - Giovanni Baez
Hard to help without any test data at hand. - Christoph

1 Answers

1
votes

as @user8153 pointed out, I also don't see a reason why using splot. And as @Christoph pointed out it's difficult without knowing how the data looks like, for example, what's in columns $3 and $4? By the way, with your plot command ...u ($1*13.60569806):2 aren't you plotting the same function twice on top of each other, i.e. that's why you see either the red or the blue? Nevertheless, I tried to anticipate what you probably want to do. I scaled the second function and assumed something linear for columns $3 and $4. Please clarify.

With the code:

### start code
reset session

# generate some dummy data
undefine $Data
set print $Data append
do for [n=1:5] {
    a = rand(0)*10
    b = rand(0)*0.1+0.1
    c = rand(0)*20
    do for [i=1:100] {
        print sprintf("%g\t%g\t%g\t%g",i,(a*sin(b*i-c)),cos(b*i),cos(b*3*i))
    }
    print "" # insert empty line for data curve separation
}
set print
# print $Data   
# end generating dummy data

set palette defined (-1 "red",0 "white", 1 "blue")
set cbrange [-1:1]
plot $Data u 1:2:($3-$4) w l lc palette z
### end of code

You'll get the following:

enter image description here