#!/usr/local/bin/perl -w # # reads three numbers and outputs a gnuplot command # $post = 0 ; # write gnu commands for postscripting $labels = 0 ; # whether to have numbers on axes, when doing postscript $scale = 1 ; $midstyle = " w l 1 " ; $otherstyle = " w l 2 " ; $offset = "1" ; # ignore above eval "\$$1=\$2" while @ARGV && $ARGV[0]=~ /^(\w+)=(.*)/ && shift; $r = 0 ; print "# gnuplot\n" ; if ( $post ) { print "set xrange [0:10] ; set yrange [0:10] ; set nokey ; set size 0.336,0.339 \n" ; # was 357 if (!$labels) { print 'set format xy "" ;'."\n" ; } print " set term post ; set nologs xy \n" ; } else { print "set size 0.525,0.7\n" ; } # main loop while (<>) { s/\s*// ; # ( $w0 , $w1 , $w2 ) = split ; if ( $post ) { $file = sprintf ("ps/langmc%d.ps", $r ) ; print "set output '$file'\n" ; } $midstring = sprintf ("( - (%8.5g) - (%8.5g) * x )/(%8.5g) %s" , $w0,$w1,$w2,$midstyle ); $topstring = sprintf ("( (%8.5g) - (%8.5g) - (%8.5g) * x )/(%8.5g) %s", $offset,$w0,$w1,$w2,$otherstyle) ; $botstring = sprintf ("( - (%8.5g) - (%8.5g) - (%8.5g) * x )/(%8.5g) %s", $offset,$w0,$w1,$w2,$otherstyle) ; $arrowmidx = -($w0)/(($w1)+($w2)) ; # point where mid-line meets w1=w2 $arrowmidy = $arrowmidx ; # print "# midx = $arrowmidx \n" ; $arrowfromx = $arrowmidx - $scale * $w1 ; $arrowfromy = $arrowmidy - $scale * $w2 ; $arrowtox = $arrowmidx + $scale * $w1 ; $arrowtoy = $arrowmidy + $scale * $w2 ; printf "set arrow 1 from %8.5g,%8.5g to %8.5g,%8.5g\n" , $arrowfromx , $arrowfromy , $arrowtox , $arrowtoy ; print "plot $midstring, $topstring, $botstring, 'dat0' u 2:3 w p 3 3, 'dat1' u 2:3 w p 5 6\n" ; if ( !$post ) {print "pause 1\n" ; } $r ++ ; }