April 19th, 2011 | 3 Comments
Often we use a specific line color or output terminal in Gnuplot. Or we are not satisfied with one of the default settings, for example the font used by the png terminal. There exists an easy way to fix these settings. Gnuplot reads a startup file, called
.gnuplot under Linux and
GNUPLOT.INI under Windows. First it searches the current directory and then your home directory after that file.
Here is an example of what is possible to include in the startup file.
# enable macros set macros # search for functions or data files in these directories set loadpath '/usr/local/lib/gnuplot' # add default line colors set style line 1 lc rgb '#0060ad' lt 1 lw 2 pt 5 # blue set style line 2 lc rgb '#dd181f' lt 1 lw 2 pt 7 # red # add macros to select the desired line style BLUE = "1" RED = "2" # add macros to select a desired terminal WXT = "set terminal wxt size 350,262 enhanced font 'Verdana,10' \ persist" PNG = "set terminal pngcairo size 350,262 enhanced font 'Verdana,10'" SVG = "set terminal svg size 350,262 fname \ 'Verdana, Helvetica, Arial, sans-serif' fsize = 10"
With these settings and the use of macros our plotting will become more easier. For example to plot the sinusoid from the plotting functions introduction we can now use the following code.
@WXT [...] plot f(x) title 'sin(x)' with lines ls @BLUE, \ g(x) notitle with lines ls @RED
Note that you have to omit the usage of
reset in your code, because it will clear the line style settings.
You can of course override the style settings of the configuration file.
plot f(x) title 'sin(x)' with lines ls @BLUE, \ g(x) notitle with lines ls @RED lw 1