Donnerstag, 28. November 2013

gnuplot array

How does it work to have an array in gnuplot?

The simplest way to create an array is like this:
 array="1 2 3 4 5"

to address a element you simple use the word command (for the zeroth element e.g.):
 word(array, 0)

In a real exercise you could use it e.g. to loop over files:
files="file1 file2 file3"
plot for [i=0:2] word(files,i) u 1:2 ti word(files,i)

gnuplot loop over datablocks

How to plot several datablocks with separate linestyles in one file?

In the following three datablocks are shown:

0.0 1.0
1.0 2.0
2.0 3.0

0.5 1.5
1.5 2.5
2.5 3.5

0.75 1.75
1.75 2.75
2.75 3.75

The first one e.g. can be addressed in gnuplot via:
plot 'datafile' every :::0::0

But to address all consecutively you need a loop the simplest way would be this loop over i=0,1,2:
plot for [i=0:2] 'datafile' every :::i::i w l ls i

There is also the possibility to use the do for loop with curly brackets {}:
 do for [i=0:3] {
 plot "datafile" ls i
} 

Freitag, 22. November 2013

emacs show latex index (reftex)

View index of latex document in emacs

1) Make sure reftex is properly installed


2) Add this section to your .emacs file

(require 'reftex)
(setq reftex-plug-into-AUCTeX t)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex) 
(add-hook 'latex-mode-hook 'turn-on-reftex


2) Compile latex document


3) Showing the index in a new window


Ctrl-c =

Example:

emacs preview of texdocument pdflatex (auctex)

Show preview of latex formulas in emacs

1) install auctex with preview

2) add following to your .emacs file


(load "auctex.el" nil t t)
(load "preview-latex.el" nil t t)
(setq preview-gs-options '("-q" "-dNOSAFER" "-dNOPAUSE" "-DNOPLATFONTS" "-dPrinted" "-dTextAlphaBits=4" "-dGraphicsAlphaBits=4"))

3) Compile the preview via:

Ctrl-c p-d

Example:


Montag, 18. November 2013

latex documentclass standalone

To create a standalone image with latex, e.g. using tikz or pstricks, one should use the documentclass standalone. The Standalone document just contains the figure itself without the rest of the document.

 \documentclass{standalone} 

additionally several options can be added:

[tikz]
sets the standalone package as multi images and set every new tikzpicture environment on a seperate page:

 \documentclass[tikz]{standalone} 




additional Infos via standalone documentation

Donnerstag, 7. November 2013

gnuplot: redirecting print

Sometimes it comes in handy to redirect the output of the print command, especially if you fit something and want to reuse the data later. This can be done with gnuplot via:
 set print "FILENAME"  

A complete example:
set print "test.dat"
print "test"
set print