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