1
votes

I would like to use splot and add 2D curve on my pm3d map. So I use this code which almost works.

I have a problem with the 2D line.

splot 'gnu8' u 2:1:3 w pm3d notitle,\
  '' u 2:(-$1):3 w pm3d notitle,\
  'allaxi80.005.dat' u 2:1:0 w l lw 3 lc "black" notitle,\
  '' u 2:(-$1):0 w l lw 3 lc "black" notitle

This It's my 2D line. When I use plot i don't have any problem.

gnuplot> plot 'allaxi80.005.dat' u 2:1 w l, '' u 2:(-$1) w l

enter image description here

And now I want the same thing with splot but as you can see I get a different curve.

gnuplot> splot 'allaxi80.005.dat' u 2:1:0 w l lw 3 lc "black" notitle,\
>      '' u 2:(-$1):0 w l lw 3 lc "black" notitle

enter image description here

Then I unset view map knowing that my data is 2D.

unset view

And I get this :

enter image description here

I use :

G N U P L O T
Version 5.2 patchlevel 2

A part of my data file :

0 32.0109
0.3125 32.0379

0.3125 32.0376
0.625 32.119

0.625 32.1221
0.78125 32.1835

0.78125 32.1837
0.788924 32.1875

0.790724 32.1875
0.9375 32.2602

0.9375 32.26
0.947399 32.2656

0.945217 32.2656
1.01562 32.3064

1.01562 32.3066
1.07344 32.3438

1.07505 32.3438
1.09375 32.3552

1.09375 32.3554
1.25 32.4697

1.25 32.4708
1.28557 32.5

1.287 32.5
1.40625 32.6034

1.40625 32.6065
1.45767 32.6562

1.46141 32.6562
1.5625 32.7658

1.5625 32.7667
1.60196 32.8125

1.60243 32.8125
1.64062 32.8601

1.64062 32.8613
1.66339 32.8906

1.66505 32.8906
1.71875 32.9636

1.71875 32.9672
1.71984 32.9688

1.7216 32.9688
1.77482 33.0469

1.77503 33.0469
1.79688 33.0805

1.79688 33.0813
1.82527 33.125

1.82647 33.125
1.875 33.2065

1.875 33.2084
1.91838 33.2812

1.91899 33.2812
2.00165 33.4375

2.00201 33.4375
2.03125 33.5005

2.03125 33.5023
2.07369 33.5938

2.07384 33.5938
2.13673 33.75

2.13802 33.75
2.1875 33.9013

2.1875 33.9033
2.18852 33.9062

2.18935 33.9062
2.23597 34.0625

2.23618 34.0625
2.27742 34.2188

2.2774 34.2188
2.31287 34.375

2.3128 34.375
2.34271 34.5312

2.3428 34.5312
2.34375 34.5373

2.34375 34.5384
2.36727 34.6875

2.36713 34.6875
2.38697 34.8438

2.38683 34.8438
2.40246 35

2.40242 35
2.41423 35.1562

2.41422 35.1562
2.42229 35.3125

2.42226 35.3125
2.42668 35.4688

2.42665 35.4688
2.42753 35.625

2.42754 35.625
2.42493 35.7812

2.42491 35.7812
2.41881 35.9375

My entire file :

https://github.com/Suntoryy/gnuplot/blob/master/allaxi80.005.dat

2
This is not enough information to easily reproduce your issue. Can you please show your data or at least a few example lines? Do have special characters, comma as decimal separator, regional settings, etc... ?theozh
I edit my post. I don't have special characters ...Suntory

2 Answers

1
votes

Actually, data is always helpful, because after plotting your data I saw what's wrong. With your code it takes the pseudocolumn 0 as z-coordinate, which is basically the line number starting from zero. Check help pseudocolumns.

Your code should read like this. Mind the 0 in (0), which means constant value of 0 (not line number).

splot 'allaxi80.005.dat' u 2:1:(0) w l lw 3 lc "black" notitle, \
      '' u 2:(-$1):(0) w l lw 3 lc "black" notitle 

Addition: (after looking at your full data in more detail)

Here is a minimal example to your problem.

  • your data is not monotonic in column 2 (here column 1)
  • you won't see this with plot because after every two data lines there is an empty line. So, the lines will not be connected. But splot will connect datapoints if there is a single empty line.

You have the options:

  1. sort your data by the column which represents your x

or

  1. instead of one empty line add two empty lines then it will also work with splot.

Code: (edit: data more similar to your data)

### plot and splot with non monotonic data
reset session

$Data0 <<EOD
0 0 
2 1
6.3 2.3
7 0
1.1 0.9
4 2
3.9 2.3
6 2
EOD

$Data1 <<EOD
0 0 
2 1

6.3 2.3
7 0

1.1 0.9
4 2

3.9 2.3
6 2
EOD

$Data2 <<EOD
0 0 
2 1


6.3 2.3
7 0


1.1 0.9
4 2


3.9 2.3
6 2
EOD

set offsets 1,1,1,1
set multiplot layout 2,3

    plot $Data0 u 1:2 w lp pt 7 ti "0 empty lines"
    plot $Data1 u 1:2 w lp pt 7 ti "1 empty lines"
    plot $Data2 u 1:2 w lp pt 7 ti "2 empty lines"

    splot $Data0 u 1:2:(0) w lp pt 7 ti "0 empty lines"
    splot $Data1 u 1:2:(0) w lp pt 7 ti "1 empty lines"
    splot $Data2 u 1:2:(0) w lp pt 7 ti "2 empty lines"
unset multiplot
### end of code

Result:

enter image description here

0
votes

To sort 1st columns function to 2nd columns in gnuplot just do :

splot '< sort -u -k1,1 file.dat | sort -k2,2'