From the gnuplot 5.0 official online documentation:
The command language of gnuplot is case sensitive, i.e. commands and function names written in lowercase are not the same as those written in capitals. All command names may be abbreviated as long as the abbreviation is not ambiguous. Any number of commands may appear on a line, separated by semicolons
;
. (T. Williams, C. Kelley - gnuplot 5.0, An Interactive Plotting Program)
Some examples of these basic rules are
1. A case sensitive language
Typing lowercase-defined commands in uppercase will generate an invalid command
warning.
gnuplot> set xlabel "x"
gnuplot> Set xlabel "x"
^
invalid command
Also the N
variable will be different from the n
one.
2. Abbreviations
You can find an almost complete list of abbreviations here. Anyway the first three letters of any command in gnuplot work always as abbreviations. Some commands allows also a more powerful contraction. A little example is given below.
gnuplot> p sin(x)
gnuplot> rep
gnuplot> q
where p
stands for plot
, rep
for replot
and q
for quit
.
3. Separators
The symbol used to separate commands on a singe line is ;
set title "My First Plot"; plot 'data'; print "all done!"
5. Comments
Comments are supported as follows: a
#
may appear in most places in a line and gnuplot will ignore the rest of the line. It will not have this effect inside quotes, inside numbers (including complex numbers), inside command substitutions, etc. In short, it works anywhere it makes sense to work. (Ibidem)
Just remember the simple "anywhere it makes sense to work" rule.
gnuplot> # this is a comment, nothing will happen
gnuplot> plot sin(x) # another valid comment
gnuplot> plot sin(#x)
^
invalid expression
4. Extending commands
Commands may extend over several input lines by ending each line but the last with a backslash (
\
). The backslash must be the last character on each line. The effect is as if the backslash and newline were not there. That is, no white space is implied, nor is a comment terminated. Therefore, commenting out a continued line comments out the entire command. (Ibidem)
For example, to split plot
command on multiple lines,
plot\
sin(x),\
cos(x)
will plot the same as
plot sin(x), cos(x)
A little note on "commenting out a continued line comments out the entire command". If you type the command
plot\
sin(x),\ # I would like to comment here
cos(x)
an error will occur:
gnuplot> plot\
> sin(x),\ # I would like to comment here
^
invalid character \
So it's better to be careful and respect the rule "anywhere it makes sense to work" while using #
comments.