Dienstag, 13. August 2013

Latex beamer uncover image function

Function for latex beamer

reserveandshow allows to uncover pictures in latex beamer on a certain slide, but still reserving the space via the \phantom command on the slides specified.
Only the none \phantom picture will be shown on the handout

 % reserveandshow! uncover figure at some point  
 \newcommand{\reserveandshow}[4]{%  
 \phantom{\includegraphics<#2|handout:0>[#3]{#4}}%  
 \includegraphics<#1|handout:1>[#3]{#4}}  


Usage:
\reserveandshow{1}{2-}[size]{image}  

Contour plot gnuplot

Contour plot

To create a contour plot like this two script files are needed. First of all a contour.gnu gnuplot file which plots the data and then contour.sh bash file which edits a temporary output file.

Steps in gnuplot:

  1. Write data into temporary file
  2. Write contour lines into temporary file
  3. Edit temporary file with contour.sh
  4. plot the edited data





Contour.sh


 #!/bin/bash  
 gawk -v d=$2 -v w=$3 -v os=$4 'function abs(x) { return (x>=0?x:-x) }  
   {  
       if($0~/# Contour/) nr=0  
       if(nr==int(os+w/2) && d==0) {i++; a[i]=$1; b[i]=$2; c[i]=$3;}  
       if(abs(nr-os-w/2)>w/2 && d==1) print $0  
       nr++  
   }  
   END {  if(d==0) {  
           for(j=1;j<=i;j++)  
           printf "set label %d \"%g\" at %g, %g centre front\n", j, c[j], a[j], b[j]  
       }  
   }' $1  

d: which option (0: set labels, 1: give data back where no label is)
w: width
os: offset

Contour.gnu

 
 # Step 1
 set xrange [-5:0]  
 set yrange [2:5]  
 set isosample 150, 150  
 set table 'test.dat'  
 splot sin(1.3*x)*cos(.9*y)+cos(.8*x)*sin(1.9*y)+cos(y*.2*x)  
 unset table  
 # Step 2
 set cont base  
 set cntrparam level incremental -3, 0.5, 3  
 unset surf  
 set table 'cont.dat'  
 splot sin(1.3*x)*cos(0.9*y)+cos(.8*x)*sin(1.9*y)+cos(y*.2*x)  
 unset table  
 reset
 # Step 3 and 4
 set xrange [-5:0]  
 set yrange [2:5]  
 unset key  
 set palette rgbformulae 33,13,10  
 load '<./contour.sh cont.dat 0 20 0'  
 plot 'test.dat' w ima, '<./contour.sh cont.dat 1 20 0' w l lt -1 lw 1.5  

Step 1:

Surface data of the function "sin(1.3*x)*cos(.9*y)+cos(.8*x)*sin(1.9*y)+cos(y*.2*x)" is plotted into "test.dat" in the x- and y-range given.

Step 2:

By using "set cont base" only the contour data of the function is written to the file "cont.dat"

Step 3:

By loading the contour.sh script the contour data in cont.dat is read and the labels for gnuplot are created.

Step 4:

The plot command plots first the data as an image and adds to that the modified contour data (modified by contour.sh)


adapted from http://gnuplot-tricks.blogspot.com/2009/07/maps-contour-plots-with-labels.html

Mittwoch, 31. Juli 2013

gnuplot tikz terminal

 Just now i found out about the tikz terminal in gnuplot 4.6 and just tried it out. It works very nicely, but I think I have to put a little bit of effort into it if its worth to change from pdflatex terminal to lua tikz.
But here is how it works:

Usage

 set terminal lua tikz standalone
 set output "test.tex"  
 plot sin(x)   

standalone/nostandalone/fulldoc

Compiling

 > pdflatex test.tex
immediate compiling only works as far as I saw for standalone and fulldoc

UPDATE COMING SOON

gnuplot if else

gnuplot 4.4 and lower:

 if (<condition>) <command-line> [; else if (<condition>) ...; else ...]
commands are just written after if condition

gnuplot 4.6

 if (<condition>) { <command>; <command>  
  <commands>  
  <commands>  
  } else {  
  <commands>   
  }  
 Commands enclosed in curly brackets.

string comparison:

test eq "test" 

And with this framework you can start building your logical setups in gnuplot, have fun.

gnuplot: key magic

All info about key: www.gnuplot.info

positioning key

 set key top left
top/bottom/centerleft/right

justification of the text

 set key Left
Left or Right (Default)

small tricks

 set key reverse            ## reverse text and sample
 set key samplen <length>   ## change length of samplen
 set key spacing <spacing>  ## set spacing between key lines

Dienstag, 30. Juli 2013

Changing textsize epslatex terminal or latexterm subroutine

 latexterm subroutine

Example file to change the fontsize in my latexterm subroutine:


The way it works:
1. Loading the gnuplot setup file
2. plotting a random function
3. evaluating the latexterm subroutine while renewing the normalsize in latex to another fontsize

 load "gnuplot-setup" 
 plot sin(x) 
 eval latexterm("test","6cm","4cm","",'\n\\renewcommand\{\\normalsize\}\{\\fontsize\{24.88\}\{30\}\\selectfont\}') 

epslatex terminal


In general you can also use it to change the textsize with the epslatex terminal for that you just have to add an option to the epslatex terminal like:

 set terminal epslatex header "\\renewcommand\{\\normalsize\}\{\\fontsize\{24.88\}\{30\}\\selectfont\}"

Imagemagick compose two images

convert pdf into png

convert -density 300 -depth 8 -rotate -90 -quality 85 test.pdf test.png  


compose an inlet into an background:
while resizing the inlet by 15% in both directions
and shifting the inlet by +700 +0
composite -verbose -geometry 15%x15%+700+00 inset.png background.png test.png