/* Last edited on 2007-12-26 17:34:02 by stolfi */ void bb2_initialize_plot ( char *outName, bool_t epsfmt, Interval xr, Interval yr, FILE **psfP, double *xsc, double *ysc, char *title ); /* Opens the output plot file and initializes scales, captions, etc. If {epsfmt} is true the file is encapsulated Postscript ("{outname}.eps") otherwise it is a plain Postscripr ("{outname}.ps"). The file is returned in {*psfP}. The procedure also computes factors {xsc} and {ysc} to be applied to the X and Y coordinates before plotting. The client plot window will contain the rectangle {{xsc*xr} × (ysc*yr)}. */ void bb2_finalize_plot(FILE **psfP, bool_t epsfmt); /* Finalizes the plot and closes the plot file {*psfP}, whose type is indicated by {epsf}. */ void bb2_initialize_plot ( char *outName, bool_t epsfmt, Interval xr, Interval yr, FILE **psfP, double *xsc, double *ysc, char *title ) { PSStream *ps = NULL; /* Compute widths of {xr} and {yr}: */ double xw = xr.hi - xr.lo; double yw = yr.hi - yr.lo; /* Add a safety margin around {xr,yr}: */ xr.lo -= 0.01*xw; xr.hi += 0.01*xw; xw = xr.hi - xr.lo; yr.lo -= 0.01*yw; yr.hi += 0.01*yw; yw = yr.hi - yr.lo; /* Actual figure dimensions: */ double hw = 420.0, vw = 420.0; /* In pt. */ /* Compute {xscale,yscale} so that {(xscale*xw)/(yscale*yw) = hw/vw}: */ double xscale, yscale; { double hyq = hw*yw; double vxq = vw*xw; if (hyq < vxq) { xscale = hyq/vxq; yscale = 1.0; } else { xscale = 1.0; yscale = vxq/hyq; } } double mrg = 4.0; ps = pswr_new_stream(epsfmt, outName, NULL, "letter", hw + 2*mrg, vw + 2*mrg); pswr_begin_picture(ps, xr.lo, xr.hi, yscale*yr.lo, yscale*yr.hi); pswr_set_pen(ps, 0.0,0.0,0.0, 0.10, 0.0,0.0); if (! epsfmt) { pswr_add_caption(psfile, title, 0.5); } *psfP = psfile; *xsc = xscale; *ysc = yscale; } void bb2_finalize_plot(PSStream **psfP, bool_t epsfmt) { PSStream *ps = *psfP; pswr_close_stream(ps); (*psfP) = NULL; }