To import data into Gnuplot, these are several guidelines that might be useful
- Understand your data
- Setting the current active folder location
- If necessary, recheck the current folder
- If necessary, change your datafile separator
Understanding your data
It is important that you understand your data. Things that you must be aware:
- File name, type and location of the file
- The contents of the file..
what is used to separate the columns.. e.g. “tab” or “space” or “comma” or “semicolon”
how many columns are there? and which column is important?
- Check the file if there are lines that is not suitable for plotting. e.g. a line of words.
Place “#” in front of that line to make it into a comment and gnuplot will ignore that line.
Change the folder location
- Launch Gnuplot and change the active folder location to where your file is using:
gnuplot > cd ‘c:\windows\user\desktop’
- If you wish, you can reconfirm the location using the command:
gnuplot > pwd
Set/Verify the column separator
- By default, the column separator between data for gnuplot is whitespaces.
“tab” and “spaces” are considered as whitespaces.
- You can change the data column separator using:
gnuplot > set datafile separator ‘,’ <<< this changes it to comma
- You can check the data column seperator using:
gnuplot > show datafile separator
Here is an example of different datafile separators:
# Data separated by comma
# Data separated by ;
# Data separated by whitespaces (e.g. spacebar)
# Data separated by whitespaces (e.g. tab)