October 28, 2022

gnuplot and paths

It is very convenient to define a path where gnuplot knows where the configuration files are. I also create directories in that location with styles, definitions, macros, etc, so that I do not have to include them in every single gnuplot script that I create. I have stolen the idea from this page.

I have defined a folder named

~/fitx_confg/gnuplot

where I have both the file gnuplotrc and another folder, called snippets.

I do not like to have configuration files in my home directory, I prefer to collect them all in a different folder. The contents of gnuplotrc are

# gnuplotrc configuration file
# Pau Amaro Seoane, Berlin, 24/Jul/2020

# Beause gnuplot does not allow to pass an argument
# to load this file, link its location to $HOME/.gnuplot
# In my case gnuplotrc is in $HOME/fitx_confg/gnuplot/ :

# ln -fs $HOME/fitx_confg/gnuplot/gnuplotrc $HOME/.gnuplot


            # ******************** loadpath ******************* #

set loadpath "/home/pau/fitx_confg/gnuplot/snippets/:/home/pau/fitx_confg/gnuplot/palettes/" # Do not use $HOME here

If you wish, obviously, you can simply add that line to $HOME/.gnuplotrc and avoid the symbolic linking.

The contents of snippets is the following:

$   ls snippets 
arrows.cfg       convfactors.cfg  header.cfg       lines.cfg        xborder.cfg      yborder.cfg
constants.cfg    grid.cfg

where, again, I have taken over a lot of things from gnuplotting.

The most important file is header.cfg, which contains this

set terminal epslatex size 8.89cm,6.65cm color colortext 10 header "\\newcommand{\\ft}[0]{\\footnotesize}"
set border linewidth 4
set output "out.tex"

because I always use latex with gnuplot thanks to two scripts I wrote.

Another example is constants.cfg

# Physical and astronomical constants in cgs units
# Source: Binney & Tremaine 87, Appendix 1.A

Grav_G=6.672e-8
Light_c=2.99792458e10
Planck_h=6.62618e-27
Boltzmann_k=1.38066e-16
Electron_q=4.80324e-10
Electron_q_inCoulomb=1.602189e-19
Proton_m=1.672649e-24
Electron_m=9.10953e-28
StefanBoltz_Sigma=5.6703e-5
Thomson_CrossSec=6.65245e-25
AstroUnit=1.49597892e13
Parsec=3.08567802e18
SideralYear=3.1558149984e7
Sun_M=1.989e33
Sun_GM=1.32712497e26
Sun_R=6.9599e10
Sun_L=3.826e33
Sun_Vesc=6.175e7
Sun_MagV=4.83
Sun_MagB=5.48
Earth_M=5.976e27
Sun_Teff=5778

# Mathematical constants

pi=3.14159

You can get more examples from the original page here:

gnuplotting and snippets