Example using the epslatex terminal in Gnuplot (equation in plot)

Here’s a short example of how to generate a high-quality vector image using the epslatex terminal in Gnuplot. The png version is shown here for comparison, but the pdf version is available here (note that you can zoom in as far as you like without any pixelation): ocpvp-crop

ocpvp

This plot used a data set:
# h2ox1 Ph2(psig), Eagagcl
-0.00098 -0.16
0.5659 -0.225
0.71943 -0.231
0.74305 -0.238
1.1564 -0.258
2.50274 -0.254
4.03804 -0.258
4.74664 -0.261

and the gnuplot script looks like this:

set key off
set terminal epslatex size 5,3
set output 'h2ox1_ocpvp.tex'
set xrange [-0.1:5]
set xlabel "$ P_{\\mathrm{H}_2}/ \\mathrm{psi_g}$"
set ylabel "$E/\\mathrm{mV}_{\\mathrm{SHE}}$"
set label "$E = \\frac{RT}{nF} \\ln(\\frac{[\\mathrm{H}^+]^2}{P_{\\mathrm{H}_2}}) $" at 1,0
set arrow from 1.5,-15 to 1.5, -35
plot 'ocpvp.dat' u 1:($2+0.21)*1000 pt 7 ps 1.25, 0.0128*log(0.004/(x/14.7))*1000 lw 4

After writing the script, all one needs to do is load the file from within gnuplot:

load 'myplotscript.plt'

and that will generate the required image in a .tex format. Then one simple has to call that file using the \include statement in a latex file like this:

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{graphics}
\usepackage{nopageno}
\begin{document}
\large
\begin{center}
\input{h2ox1_ocpvp.tex}
\end{center}
\end{document}

This will generate the desired pdf image.

Gnuplot example

This is a simple example that shows a nice encapulated post script (.eps) plot made with only 9 lines of gnuplot commands.

another gnuplot example

here’s the gnuplot code:

set xlabel “{/Symbol n}^{1/2}”
set ylabel “{/Symbol D}E_p (V)”
set key center right
set label 1 “{/Symbol D}E_p({/Symbol n}^{1/2}) = 0.055 + 0.0035 {/Symbol n}^{1/2}” at 7,0.11
set label 2 “{/Symbol D}E_p({/Symbol n}^{1/2}) = 0.079 + 0.012 {/Symbol n}^{1/2} ” at 7,0.23
plot “data_1” title “GC” w lines lw 5, “data_2” title “Pt” w lines lw 5
set terminal postscript eps color enhanced “Helvetica” 16
set output ‘myplot.eps’
replot

The data is stored in two text files called data_1 and data_2, and gnuplot produces an encapsulated postscript image
called myplot.eps.

The data files look like this:
(data_1)
3.16         0.11
5               0.147
7.07        0.169
10              0.2
14.14        0.25

(data_2)
3.16         0.063
5              0.075
7.07         0.081
10            0.092
14.14       0.103

The program is used by navigating to the directory that has the plotter and data files, then running the command:

$ gnuplot
gnuplot> load ‘plotter’

the eps image appears in the directory

Creating gif animations in Gnuplot 4.6

This is one approach to using Gnuplot 4.6 to create a gif animation from a separate text file
that has one time column and eight data columns. The Gnuplot text file could look like this:

# Gnuplot seven-channel time series animation generator (gif)
# gnuplotscript.txt
# 12/2012
# Assumes a data text file (myfile.dat) with eight columns of data, the first being the time, and the other seven being normalized data
# The data (text) file is assumbed to be named myfile.dat
# The data file must have all preamble infomration deleted so the first row in the file myfile.dat is time series data, not text
unset key
unset ytics
unset xtics
set style data lines
set yrange[-1:11]
set terminal gif size 1000,800 animate delay 2
set output “myanimation.gif”
do for [t=1:1500]{
set xrange[((t/100.)-1):((t/100.)+1)]
plot “myfile.dat” using 1:2 lw 2, “myfile.dat” using 1:3 lw 2, “myfile.dat” using 1:4 lw 2, “myfile.dat” using 1:5 lw 2, “myfile.dat” using 1:6 lw 2, “myfile.dat” using 1:7 lw 2, “myfile.dat” using 1:8 lw 2}

and this file is run by entering the following command in the command line (after using cd to change to the correct directory):

gnuplot gnuplotscript.txt

which will create the file called myanimation.gif in the same directory

Animating data in Mathematica

In Mathematica, large sets of data can easily be animated using a few lines of code. One approach is shown below:

rawdata =
Import[“/Documents/nervesignals/nervesignals.atf”,
“Data”];

animationtable =
Table[ListLinePlot[
ParallelTable[
Transpose[{rawdata[[All, 1]][[10000 ;; 130000]],
Standardize[
rawdata[[All, i]][[10000 ;; 130000]]] + (22 i)}], {i, 2,
7}], Frame -> True, Axes -> False, AxesLabel -> False,
FrameTicks -> None,
PlotRange -> {{(j – 2.5), (j + 2.5)}, {20, 165}},
ImageSize -> 750, PlotStyle -> Thick], {j, 3.5, 9.5, 0.08}];

Export[“/animation/myanimation.gif”,
animationtable, “DisplayDurations” -> 0.15]

Six channels of nerve signals

A similar example for animating cyclic voltammetric data:

hydrogen adsorption/desorption