⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 psgraph.c.n

📁 seismic software,very useful
💻 N
字号:
char *sdoc ="PSGRAPH - PostScript GRAPHer\n""Graphs n[i] pairs of (x,y) coordinates, for i = 1 to nplot.\n""\n""psgraph [optional parameters] <binaryfile >postscriptfile\n""\n""Data formats supported:""	1. n1,x1,y1,x2,y2,...,xn1,yn1""	2. n1,y1,y2,...,yn1 (must give non-zero d1[]=)""	3. n1,y1,y2,...,yn1 (must give non-zero d2[]=)""	4. n1 (must give non-zero d1[]= and non-zero d2[]=)""  The formats may be repeated and mixed in any order, but if""  formats 2-4 are used, the dx and dy arrays must be fully specified""  including d1[]=0.0 d2[]=0.0 entries for any internal occurences of format 1.""  Also, if formats 2-4 are used with non-zero f1[] or f2[] entries, then ""  the corresponding array(s) must be fully specified including f1[]=0.0""  and/or f2[]=0.0 entries for any internal occurences of format 1 or""  formats 2-4 where the zero entries are desired.""\n""Optional Parameters:\n""d1=0.0,...             x sampling intervals (0.0 if x coordinates input)\n""f1=0.0,...             first x values (not used if x coordinates input)\n""d2=0.0,...             y sampling intervals (0.0 if y coordinates input)\n""f1=0.0,...             first y values (not used if y coordinates input)\n""linewidth=1.0,...      line widths (in points) (0.0 for no lines)\n""linegray=0.0,...       line gray levels (black=0.0 to white=1.0)\n""mark=0,1,2,3,...       indices of marks used to represent plotted points\n""marksize=0.0,0.0,...   size of marks (0.0 for no marks)\n""xbox=1.5               offset in inches of left side of axes box\n""ybox=1.5               offset in inches of bottom side of axes box\n""wbox=6.0               width in inches of axes box\n""hbox=8.0               height in inches of axes box\n""x1beg=x1min            value at which axis 1 begins\n""x1end=x1max            value at which axis 1 ends\n""d1num=0.0              numbered tic interval on axis 1 (0.0 for automatic)\n""f1num=x1min            first numbered tic on axis 1 (used if d1num not 0.0)\n""n1tic=1                number of tics per numbered tic on axis 1\n""grid1=none             grid lines on axis 1 - none, dot, dash, or solid\n""label1=                label on axis 1\n""x2beg=x2min            value at which axis 2 begins\n""x2end=x2max            value at which axis 2 ends\n""d2num=0.0              numbered tic interval on axis 2 (0.0 for automatic)\n""f2num=x2min            first numbered tic on axis 2 (used if d2num not 0.0)\n""n2tic=1                number of tics per numbered tic on axis 2\n""grid2=none             grid lines on axis 2 - none, dot, dash, or solid\n""label2=                label on axis 2\n""labelfont=Helvetica    font name for axes labels\n""labelsize=12           font size for axes labels\n""title=                 title of plot\n""titlefont=Helvetica-Bold font name for title\n""titlesize=24           font size for title\n""style=normal           normal (x axis horizontal, y axis vertical) or\n""                       seismic (x axis vertical, y axis horizontal)\n""\n""Example:\n""psgraph d1=2.5,1,0.33 <datafile >psfile\n""  plots three curves with equally spaced x values in one plot frame\n""  x1-coordinates are x1(i) = f1+i*d1 for i = 1 to n (f1=0 by default)\n""  number of x2's and then x2-coordinates for each curve are read\n""  sequentially from datafile.\n""\n""AUTHOR:  Dave Hale, Colorado School of Mines, 05/29/90\n""MODIFIED:  Jack K. Cohen 11/23/90 for different input data format\n""\n";#include <stdio.h>#include <math.h>#include "par.h"#include "psplot.h"#define NPMAX 500main (argc,argv)int argc; char **argv;{	int nplot,npoint[NPMAX],curpoint,n1tic,n2tic,		mark[NPMAX],i,j,grid1,grid2,style,npar,ni,bbox[4];	float labelsize,titlesize,linewidth[NPMAX],linegray[NPMAX],		marksize[NPMAX],d1[NPMAX],f1[NPMAX],d2[NPMAX],f2[NPMAX],		x1beg,y2beg,x1end,y2end,xbox,ybox,wbox,hbox,		x1min,x1max,y2min,x2max, d1num,f1num,d2num,f2num,		xsize,ysize,xscale,yscale;	char *label1="",*label2="",*title="",		*labelfont="Helvetica",*titlefont="Helvetica-Bold",		*styles="normal",*grid1s="none",*grid2s="none";	FILE *plotfp;	/* initialize getpar */	initargs(argc,argv);	askdoc(1);	/* get parameters needed to interpret datafile */	for (i=0; i<NPMAX; i++) {		d1[i] = 0.0;		f1[i] = 0.0;		d2[i] = 0.0;		f2[i] = 0.0;	}	getparfloat("d1",d1); 	getparfloat("f1",f1);	getparfloat("d2",d2); 	getparfloat("f2",f2);	/* read data and compute global extreme values */	plotfp = etmpfile();	x2max = x1max = -FLT_MAX;	y2min = x1min =  FLT_MAX;	nplot = 0;	while (efread(&curpoint, ISIZE, 1, stdin)) {		if (nplot > NPMAX)  err("too many plots");		npoint[nplot] = curpoint;		/* read data for this plot */		if (d1[nplot] && d2[nplot]) { /* straight line */			float x,y;			register int i;			for (i=0; i<curpoint; ++i) {				x = f1[nplot] + i*d1[nplot];				y = f2[nplot] + i*d2[nplot];				x1max = MAX(x, x1max);				x1min = MIN(x, x1min);				x2max = MAX(y, x2max);				y2min = MIN(y, y2min);				efwrite(&x, FSIZE, 1, plotfp);				efwrite(&y, FSIZE, 1, plotfp);			}					} else if (d1[nplot]) { /* equally spaced x's */			float x,y;			register int i;			for (i=0; i<curpoint; ++i) {				efread(&y, FSIZE, 1, stdin);				x = f1[nplot] + i*d1[nplot];				x1max = MAX(x, x1max);				x1min = MIN(x, x1min);				x2max = MAX(y, x2max);				y2min = MIN(y, y2min);				efwrite(&x, FSIZE, 1, plotfp);				efwrite(&y, FSIZE, 1, plotfp);			}		} else if (d2[nplot]) { /* equally spaced y's */			float x,y;			register int i;			for (i=0; i<curpoint; ++i) {				efread(&x, FSIZE, 1, stdin);				y = f2[nplot] + i*d2[nplot];				x1max = MAX(x, x1max);				x1min = MIN(x, x1min);				x2max = MAX(y, x2max);				y2min = MIN(y, y2min);				efwrite(&x, FSIZE, 1, plotfp);				efwrite(&y, FSIZE, 1, plotfp);			}		} else { /* pairs */			float x,y;			register int i;			for (i=0; i<curpoint; ++i) {				efread(&x, FSIZE, 1, stdin);				efread(&y, FSIZE, 1, stdin);				x1max = MAX(x, x1max);				x1min = MIN(x, x1min);				x2max = MAX(y, x2max);				y2min = MIN(y, y2min);				efwrite(&x, FSIZE, 1, plotfp);				efwrite(&y, FSIZE, 1, plotfp);			}		}		++nplot;	}	/* cope with special cases */	if (x1min==FLT_MAX) x1min = x1max = 0.0;	if (y2min==FLT_MAX) y2min = x2max = 0.0;	if (x1min == x1max) {		x1min -= 1.0;		x1max += 1.0;	}	if (y2min == x2max) {		y2min -= 1.0;		x2max += 1.0;	}	/* get plotting parameters */	getparstring("label1",&label1);	getparstring("label2",&label2);	getparstring("title",&title);	getparstring("style",&styles);	if (STREQ("normal",styles)) style = NORMAL;	else style = SEISMIC;	getparstring("labelfont",&labelfont);	getparstring("titlefont",&titlefont);	labelsize = 18.0; getparfloat("labelsize",&labelsize);	titlesize = 24.0; getparfloat("titlesize",&titlesize);	xbox = 1.5; getparfloat("xbox",&xbox);	ybox = 1.5; getparfloat("ybox",&ybox);	wbox = 6.0; getparfloat("wbox",&wbox);	hbox = 8.0; getparfloat("hbox",&hbox);	/* minmax(stdin,nplot,n,dx,fx,dy,fy,&x1min,&x1max,&y2min,&x2max); */	x1beg = x1min; getparfloat("x1beg",&x1beg);	x1end = x1max; getparfloat("x1end",&x1end);	y2beg = y2min; getparfloat("y2beg",&y2beg);	y2end = x2max; getparfloat("y2end",&y2end);	d1num = 0.0; getparfloat("d1num",&d1num);	f1num = x1min; getparfloat("f1num",&f1num);	n1tic = 1; getparint("n1tic",&n1tic);	getparstring("grid1",&grid1s);	if (STREQ("dot",grid1s)) grid1 = DOT;	else if (STREQ("dash",grid1s)) grid1 = DASH;	else if (STREQ("solid",grid1s)) grid1 = SOLID;	else grid1 = NONE;	d2num = 0.0; getparfloat("d2num",&d2num);	f2num = 0.0; getparfloat("f2num",&f2num);	n2tic = 1; getparint("n2tic",&n2tic);	getparstring("grid2",&grid2s);	if (STREQ("dot",grid2s)) grid2 = DOT;	else if (STREQ("dash",grid2s)) grid2 = DASH;	else if (STREQ("solid",grid2s)) grid2 = SOLID;	else grid2 = NONE;	for (i=0; i<nplot; i++) {		mark[i] = i%9;		marksize[i] = 0.0;		linewidth[i] = 1.0;		linegray[i] = 0.0;	}	if (npar=getparint("mark",mark))		for (j=npar; j<nplot; j++)			mark[j] = mark[npar-1];	if (npar=getparfloat("marksize",marksize))		for (j=npar; j<nplot; j++)			marksize[j] = marksize[npar-1];	if (npar=getparfloat("linewidth",linewidth))		for (j=npar; j<nplot; j++)			linewidth[j] = linewidth[npar-1];	if (npar=getparfloat("linegray",linegray))		for (j=npar; j<nplot; j++)			linegray[j] = linegray[npar-1];	/* begin PostScript */	beginps();	newpage("1",1);	/* convert box parameters from inches to points */	xbox *= 72.0;	ybox *= 72.0;	wbox *= 72.0;	hbox *= 72.0;	/* set bounding box */	psAxesBBox(		xbox,ybox,wbox,hbox,		labelfont,labelsize,		titlefont,titlesize,		style,bbox);	boundingbox(bbox[0],bbox[1],bbox[2],bbox[3]);	/* draw axes and title */	psAxesBox(		xbox,ybox,wbox,hbox,		x1beg,x1end,0.0,0.0,		d1num,f1num,n1tic,grid1,label1,		y2beg,y2end,0.0,0.0,		d2num,f2num,n2tic,grid2,label2,		labelfont,labelsize,		title,titlefont,titlesize,		style);	/* set clip */	rectclip(xbox,ybox,wbox,hbox);	/* determine axes sizes */	xsize = (style==NORMAL)?wbox:hbox;	ysize = (style==NORMAL)?hbox:wbox;	/* translate coordinate system by box offset */	translate(xbox,ybox);	/* if style is not normal, rotate coordinate system */	if (style!=NORMAL) {		rotate(-90.0);		translate(-hbox,0.0);	}	/* determine x and y scale factors */	xscale = xsize/(x1end-x1beg);	yscale = ysize/(y2end-y2beg);	/* draw the plots */	rewind(plotfp);	for (i=0; i<nplot; ++i) {		float *x, *y;		register int j;		ni = npoint[i];		x = ealloc1float(ni);		y = ealloc1float(ni);		/* read next set of pairs from tmpfile */		for (j=0; j<ni; ++j) {			efread(x+j, FSIZE, 1, plotfp);			efread(y+j, FSIZE, 1, plotfp);		}				/* translate and scale */		for (j=0; j<ni; j++) {			x[j] = (x[j]-x1beg)*xscale;			y[j] = (y[j]-y2beg)*yscale;		}		/* plot */		gsave();		if (linewidth[i]!=0.0) {			setlinewidth(linewidth[i]);			setgray(linegray[i]);			polyline(x,y,ni);		}		if (marksize[i]!=0.0) {			for (j=0; j<ni; j++)				markto(x[j],y[j],mark[i],marksize[i]);		}		grestore();		free1float(x);		free1float(y);	}	/* end PostScript */	showpage();	endps();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -