Mittwoch, 17. Dezember 2014

layers in tikz in latex

To define a layer in tikz you would first in the preamble define a new layer with a defined name (here i chose "layer") and then set the order of the layers especially in comparison to the standard "main" layer.

\pgfdeclarelayer{layer}    % declare layer
\pgfsetlayers{layer,main}  % set the order of the layers (main is the standard layer)

in the plotting step you can then explicitly plot on a different layer by using the pgfonlayer environment

\begin{pgfonlayer}{layer}
      \draw[ultra thick] (0.0,0.0) -- ++ (1.0,0.0);
\end{pgfonlayer}

Freitag, 14. November 2014

latex trim image

to cut an image in latex you can simply use the trim option and then define then use the clip option as follow:

\includegraphics[trim={left low right top},clip]{./test.png}

Donnerstag, 23. Oktober 2014

Latex (tikz) emphasize part of graphic

http://tex.stackexchange.com/questions/181098/semitransparent-outside-clipped-region

gnuplot loop over all blocks in datafile

If you have a data file for gnuplot with indexable blocks (two blank lines between data blocks) e.g.:

0 1
1 2

0 1.5
1 2.5


0 2.0
2 3.0

and want to plot each plot individually but with the same plot command, you can simply use the gnuplot 4.6 stats function to get the number of blocks and loop over the blocks in a combined command:

#!/usr/bin/gnuplot

file="data.dat"
stats file

plot for [i=0:STATS_blocks-2] file index i w l ls i+1
PS: if you only have one blank line between data blocks you need to use the every command:
#!/usr/bin/gnuplot

file="data.dat"
stats file

plot for [i=0:STATS_blank] file every :::i::i w l ls i+1

Mittwoch, 22. Oktober 2014

histogram with gnuplot

if you want to plot a histogram with gnuplot, just use the raw data in "data.dat" and plot the data via the following command:

the data is transformed into a histogram via the bin function and then plotted via the plot with boxes command.

  #!/usr/bin/gnuplot

file="data.dat"
binwidth=1.0
bin(x,width)=width*floor(x/width)
set style fill solid 0.5

plot file u (bin($1,binwidth)):(1.0) smooth freq with boxes ls 1 t 'total'


the result looks something like that:

Freitag, 10. Oktober 2014

remove zero sized file

To delete zero sized files in bash you can simply use an if clause with you can put in a loop. First the if clause

  if [ ! -s file ] ; then
    rm file
 fi

and finally the full loop:

 for file in *
 do
   if [ ! -s $file ] ; then
     rm $file
   fi
 done