[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Plotting alternatives



Hi all,

A few days ago I wrote to this list suggesting some
alternatives to XGraph. Specifically, I mentioned
Grace (a full featured GUI plotting tool with
extensive batch processing capabilities) and also
plplot (a plotting library with Tcl bindings)

Two notes on this topic:

First, plplot doesn't have 'raw' Tcl, but
"incr Tcl" bindings. "incr Tcl" is, just like OTcl,
an OO extension to Tcl, so I'm afraid that integration
into ns scripts wouldn't be as easy as I suggested.
However, plplot has also C++ bindings, so simple
OTcl wrappers could be provided for this purpose.

Second, for those who don't like XGraph but are
afraid of other plotting tools which are better
and more widely supported, but less familiar
to ns users, here is an awk script which
automatically translates Xgraph data files to
Grace ones (not that they are that different,
but still...)

Hope it helps someone.

=== Cut (file: xg2gr) ===
#!/bin/sh

awk '
BEGIN{
print "# This file is generated by xg2gr";
print "# It should work";
DSET=0;
DSETC=2;
ISNEWDSET=(1==1);
ISBAR=(1!=1);
}
{
    if(($1=="BarGraph:")&&($2~/[Tt]/)){ 
	print "@g0 type Chart"; 
	ISBAR=(1==1);
	}
    if(($1=="LogY:")&&($2~/[Tt]/)){ print "@ yaxes scale Logarithmic";}
    if(($1=="LogX:")&&($2~/[Tt]/)){ print "@ xaxes scale Logarithmic";}
    if($1=="TitleText:"){ printf "@ title \"%s\"\n",substr($0,12); }
    if($1=="XUnitText:"){ printf "@ xaxis  label
\"%s\"\n",substr($0,12); }
    if($1=="YUnitText:"){ printf "@ yaxis  label
\"%s\"\n",substr($0,12); }
    if($1=="XLowLimit:"){ printf "@ world xmin %g\n",$2; }
    if($1=="YLowLimit:"){ printf "@ world ymin %g\n",$2; }
    if($1=="XHighLimit:"){ printf "@ world xmax %g\n",$2; }
    if($1=="YHighLimit:"){ printf "@ world ymax %g\n",$2; }
    if(substr($1,1,1)=="\""){
	printf "@ s%d legend %s",DSET,$0;
	if(substr($0,length($0),1)!="\""){printf "\" \n"}
	else{printf " \n"}
	}
    ISDATA = ($1==$1+0)||($1=="draw")||($1=="move");
    if(ISNEWDSET&&ISDATA){
	if(ISBAR) {
	    printf "@ s%d type bar\n",DSET;
	    }
	printf "@ s%d line color %d\n",DSET,DSETC;
	printf "@ target s%d \n",DSET;
	} 
    if($1==$1+0){ 
	print $1, $2;
	ISNEWDSET=(1!=1);
	}
    if($1=="draw"){ 
	print $2, $3;
	ISNEWDSET=(1!=1);
	}
    if($1=="move"){ 
	if(ISNEWDSET){ISNEWDSET=(1!=1);}
	else{DSET++; print " ";ISNEWDSET=(1==1);}
	print $2, $3; 
	}
    if(($1=="")&&(!ISNEWDSET)){DSET++; DSETC++; print "
";ISNEWDSET=(1==1);}
}
' $1

=== Cut (file: xg2gr) ===

Regards,
G.
-- 
Guillermo Rodriguez Garcia
<[email protected]>