3

I want to plot a data file (speed11.data) in Linux. the data file looking like:

1,4.45823517e+01
2,4.45873528e+01
3,4.45923538e+01
4,4.45973549e+01

I used gnuplot, but I got error.

 gnuplot> plot "speed11.data"


gnuplot> 1,4.45823517e+01
         ^
         "speed11.data", line 1: invalid command

How to plot this graph?

The output of locale is:

LANG=en_CA.UTF-8
LC_CTYPE="en_CA.UTF-8"
LC_NUMERIC="en_CA.UTF-8"
LC_TIME="en_CA.UTF-8"
LC_COLLATE="en_CA.UTF-8"
LC_MONETARY="en_CA.UTF-8"
LC_MESSAGES="en_CA.UTF-8"
LC_PAPER="en_CA.UTF-8"
LC_NAME="en_CA.UTF-8"
LC_ADDRESS="en_CA.UTF-8"
LC_TELEPHONE="en_CA.UTF-8"
LC_MEASUREMENT="en_CA.UTF-8"
LC_IDENTIFICATION="en_CA.UTF-8"
LC_ALL=
Willem Van Onsem
  • 443,496
  • 30
  • 428
  • 555
h747
  • 61
  • 1
  • 5
  • 3
    Worked fine for me after replacing the commas with spaces. – Lee Daniel Crocker Dec 31 '14 at 21:26
  • I put tabs instead of ",", but I could not plot. gnuplot> 1 4.45823517e+01 ^ "speed13b.data", line 1: invalid command – h747 Dec 31 '14 at 21:53
  • All I can suggest is perhaps re-installing gnuplot. – Lee Daniel Crocker Dec 31 '14 at 21:54
  • Also please post version info. Ex: `uname -a && gnuplot --version && dpkg -l | grep "^i.*gnuplot"` – spinkus Jan 01 '15 at 00:51
  • Also please post `gnuplot <(echo "show terminal")`. – spinkus Jan 01 '15 at 01:11
  • if you're created your data file or transfered it thru a Windows machine, likely it has `\r\n` line-endings. Use `dos2unix speed11.data` . Good luck. – shellter Jan 01 '15 at 03:47
  • @shellter: That's not true in general. On linux, gnuplot can read windows files with `\r\n`. However, it can not read Mac-files (`\r`). next point: gnuplot can also read files with commas as separators, use `set datafile separator ','` for this. And about the question: The error message is: invalid _command_, which occurs when doing `load "speed11.data"`. Maybe, gnuplot is defect and needs a reinstall. Or gnuplot is used the wrong way. Question: What are the exact (all) steps from starting a command line to entering the plot command? – sweber Jan 02 '15 at 12:49

1 Answers1

1

For gnuplot, you might want to look at this post that deals with using comma separated values (CSV) in gnuplot.

Alternatively , you might want to try using R instead of gnuplot. R has the ability to import csv data files and is able to do some sophisticated graphing.

Community
  • 1
  • 1
RichardC
  • 45
  • 6