Search code examples
gnuplot

What is wrong with gnuplot data?


I have data: test.txt

6540.00 36040352.00
6540.02 36033872.00
6540.04 36027784.00
6540.06 36027784.00
6540.08 36021308.00
6540.10 36008740.00
6540.12 35983212.00

I have this error after using gnuplot:

plot 'test.txt'
                          ^
           all points y value undefined!

What is wrong please?

Code I used is for multiple plot:

set term pngcairo size 800,600 font "Times New Roman,12"
set output "f.png"
set border lw 1.4
set title offset 0,-0.5
set grid xtics ytics ls -1 lc "gray" 
set tics out nomirror


Row1 = "set tmargin screen 0.92; set bmargin screen 0.40"   
Row2 = "set tmargin screen 0.40; set bmargin screen 0.20"  
Col1 = "set lmargin screen 0.10; set rmargin screen 0.88"   

set multiplot layout 2,1 rowsfirst 

@Row1; @Col1         
set key out horiz bot width 5 reverse Left #box
set tics out nomirror
set xrange [6560.8:6564.8] 
plot 'test.txt' with lines linecolor rgb "black" lw 1.1 title "{/:Bold l}"

@Row2; @Col1           
set key out horiz bot width 5 reverse Left #box
set tics out nomirror
set xrange [6676:6680] 
plot 'test.txt' with lines linecolor rgb "black" lw 1.1 title "{/:Bold l}"

When I want to plot data, it works.


Solution

  • your x-data ranges from 6540.0 to 6540.12. If you fix your range by

    set xrange [6560.8:6564.8] 
    ...
    set xrange [6676:6680] 
    

    there will be no corresponding y-data. That's why gnuplot tells you all points y value undefined!. If you comment the lines:

    # set xrange [6560.8:6564.8] 
    
    # set xrange [6676:6680] 
    

    You will get the following. By the way, I would also add at the end:

    unset multiplot
    set output
    

    enter image description here