You run a plot command, gnuplot pauses, and instead of a graph you get this:
warning: Skipping data file with no valid points
gnuplot> plot "data.dat" using 1:2 with lines
^
x range is invalid
The second message, x range is invalid, belongs to the same family: gnuplot accepted the command but ended up with zero usable (x, y) pairs, so there is nothing to set a range from.
What this message means
Gnuplot read your data file line by line, tried to extract the columns named in using, and could not turn a single line into a valid point. Lines that are blank, start with #, or fail to parse are silently skipped — when every line is skipped, you get this warning. The plot command itself is rarely the problem; the mismatch is between what is actually in the file and what the command assumes.
Causes, most likely first
- Wrong separator. Your file is comma- or semicolon-separated, but gnuplot splits on whitespace by default. A line like
1.5,2.3is read as one unparseable field, not two numbers. usingcolumns out of range. You asked for column 3 of a two-column file, or the columns are in the opposite order to what you assumed.- The file gnuplot opened is empty or is not the file you think. A wrong path or a failed export can leave gnuplot reading a zero-byte file or an old placeholder.
- Time/date data without
set xdata time. Dates in a column do not parse as numbers unless gnuplot is told the column holds time values and which format they use.
Fixes, step by step
1. Match the separator
Look at the raw file first (head data.dat on Linux/macOS, or open it in a text editor). If fields are comma-separated, tell gnuplot before plotting:
set datafile separator comma
plot "data.csv" using 1:2 with linespoints
For semicolons use set datafile separator ";". If the export came from a European-locale spreadsheet, watch for decimal commas too — set decimalsign locale may also be needed.
2. Check the columns really exist
Print a line count and the field count of a sample line. On Linux/macOS:
head -3 data.dat
awk 'NR==2{print NF}' data.dat
If the file has two columns, using 1:3 can never produce a point. Adjust using to columns that exist, and remember that using 1:2 means “x from column 1, y from column 2”.
3. Confirm gnuplot opens the file you edited
Check the file size and, inside gnuplot, where it is looking from:
pwd
!ls -l data.dat
A zero-byte file, or a pwd that points at a different folder than the one holding your edited file, explains the warning immediately. See our guide on gnuplot file paths and the working directory for the details.
4. Declare time data before plotting it
If column 1 holds dates or timestamps, set the mode and the format first:
set xdata time
set timefmt "%Y-%m-%d"
set format x "%b %Y"
plot "series.dat" using 1:2 with lines
The timefmt string must match the file exactly — %d/%m/%Y data with a %Y-%m-%d format parses nothing. Our date and time plotting tutorial walks through the format codes.
A minimal script that works
Save this as demo.dat:
# x y
1 2.0
2 3.5
3 3.1
4 5.2
Then plot it:
reset
set terminal pngcairo size 800,600
set output "demo.png"
plot "demo.dat" using 1:2 with linespoints title "demo"
set output
If this produces a plot, your installation is fine and the problem is in your real file or command — reintroduce your separator, using spec and any time settings one at a time until the warning returns; the last thing you added is the culprit. You can also paste the same commands into the online gnuplot terminal to confirm.
Still stuck?
The official documentation at gnuplot.info includes the full command reference, and the gnuplot-info mailing list linked there is the best place to ask when a script misbehaves in a way this page does not cover — include the exact error message and a small sample of your data when you post.
