#!/bin/csh -f # ============================================================================= # make_statistics # ----------------------------------------------------------------------------- # This tool computes publications-per-year statistics of bibtex databases # and draws the resulting bar charts in the formats png (for inclusion in # html documents), pic (for inclusion in LaTeX documents; no scaling) and # eps (using LaTeX fonts; scalable). # ----------------------------------------------------------------------------- # usage : make_statistics file.bib [ year_min [ year_max ] ] # output : file.png file.pic file.eps # requirements: latex, dvips, gnuplot (http://www.gnuplot.org/) # ----------------------------------------------------------------------------- # This software is provided "as-is" and without warranty of any kind. # In no event shall the author be liable for any damage of any kind. # ----------------------------------------------------------------------------- # Author: Alexander Wolff # Institute of Mathematics & Computer Science # Greifswald University # http://www.math-inf.uni-greifswald.de/~awolff # ============================================================================= set bibfile = $1 if ( ( $#argv < 1 ) || ( $#argv > 3 ) || ( $bibfile:e != bib ) ) goto usage set pngfile = $1:r.png set epsfile = $1:r.eps set picfile = $1:r.pic if ( $#argv > 1) then set year_min = $2 else set year_min = 0 endif if ( $#argv > 2) then set year_max = $3 else set year_max = 3000 endif echo "INPUT = $bibfile" echo "OUTPUT = $pngfile $epsfile" echo "YEAR_MIN = $year_min" echo "YEAR_MAX = $year_max" # count year entries in bibtex file and write results in data file grep --ignore-case "year *=.*\([0-9][0-9][0-9][0-9]\)" $bibfile | \ sed -e "s/^.*\([0-9][0-9][0-9][0-9]\).*/\1/" | \ sort -n | \ awk -v ymin=$year_min -v ymax=$year_max \ 'BEGIN { min = 3000; max = 0; total = 0 } \ { \ i=$1; pub[i]++; total++; \ if ( (i=ymin) ) min=i; \ if ( (i>max) && (i<=ymax) ) max=i; \ } \ END { \ for (i=min; i<=max; i++) \ if (pub[i]) printf "%s %s\n", i, pub[i] \ else printf "%s 0\n", i \ }' >tmp_statistics.dat # The total number of references should be output (e.g. on stderr). # call gnuplot to draw bar charts of data file gnuplot << END set nokey set tics out set xtics nomirror # make latex picture without axis labels # -- you may specify a fontsize like 9, 10, 12 pt. here as follows: # set terminal latex 9 set terminal latex set output "tmp_statistics.pic" plot "tmp_statistics.dat" with boxes # make png picture with axis labels set xlabel "year of publication" set ylabel "number of references" set size 0.7, 0.7 set terminal png small transparent set output "tmp_statistics.png" plot "tmp_statistics.dat" with boxes END # call latex to generate dvi file latex << END \documentclass{article} \usepackage{colordvi} \setbox0=\hbox{\White{\fbox{\Black{\input{tmp_statistics.pic}}}}} \shipout\box0 \stop END # call dvips -E to generate eps file \dvips -E -f texput.dvi >tmp_statistics.eps # clean up \rm -f texput.dvi texput.log tmp_statistics.dat \mv -f tmp_statistics.pic $picfile \mv -f tmp_statistics.eps $epsfile \mv -f tmp_statistics.png $pngfile exit 0 # ----------------------------------------------------------------------------- usage: echo "$0:t -- computes publications-per-year statistics of bibtex databases" echo "and draws the resulting bar charts in the formats png and eps." echo "USAGE : $0:t file.bib [ year_min [ year_max ] ]" echo "OUTPUT: file.png file.pic file.eps" exit 1 # ==================================== EOF ====================================