Re: XForms: Printing of xyplots?

Robert Williams (bob@bob.usuf2.usuhs.mil)
Wed, 13 Aug 1997 14:47:03 -0400

To subscribers of the xforms list from Robert Williams <bob@bob.usuf2.usuhs.mil> :

Robert Williams wrote:
>
> Let's see...my online manual is at
> http://bob.usuf2.usuhs.mil/doc/pgplot/index.html

Here is a chunk of my hardcopy routine, part
of an xforms based package of mine:

/* ---------------- MAKE A HARDCOPY PLOT. ------------------ */

/* We need ymin and ymax, and those globals
are not guaranteed to be set at this point.
*/

ymin_ymax(Y_data1, (int)npts[Current_file1_set],&ymin,&ymax);

if (debug_level2 == 1)
{
printf("Exited from ymin_ymax in case 421.\n");
}

/* We need to check Ytitle and Xtitle to see
if they have been set to something elsewhere,
either in the data file or here.
*/

if(((int)Xtitle[0] < (int)'!')|| (int)(Xtitle[0]> (int)'~'))
{
/*This is just a temporary default.*/
(void)strcpy(Xtitle,(const char *)"Frequency, cm\\u-1\\d\000");
Xtitle_is_set_flag=1;
}

if((Ytitle[0]=='\0')||(Ytitle[0]==' '))
{
/*This is just a temporary default.*/
(void)strcpy(Ytitle,(const char *)"Raman Intensity\000");
Ytitle_is_set_flag=1;
}

/*Initialize postscript plotting.*/

/*if(cpgbeg(0,"pgplot_on_file.ps",1,1) != 1) */
if(cpgbeg(0,"pgplot_on_file.ps/VPS",1,1) != 1)
{
printf("%s\n%s\n%s\n","Error at cpgbeg",
" in plot_submenu_source_submenu_callback","");

}
if (debug_level2 == 1)
{
printf("%s\n%s\n%s\n","Writing postscript file",
" pgplot_on_file.ps","");
}

cpgslw(2); /*Select line width for box.*/
cpgsvp (0.16,0.9,0.55,0.86); /*view port(% of page)*/
y_data1_scale = (ymax - ymin) * 0.05;

/*This appears to be a bug either in cpgswin
or in our postscript routines: When X_start is
not a multiple of 100 (1200, 800, etc) but
rather something like 1280 or 840, the plotting
package looses track of where the decimal point
is, and plots x-axis labels like 1200x10**80.!!!
So, to get around this problem for now, we will
find the nearest multiple of 100 for the
starting x-axis data. */

round_down_x = 100 * (int)( X_start[Current_file1_set] / 100.0 );
plot_x_start = (float) round_down_x;
if (debug_level2 == 1)
{
printf("round_down_x, plot_x_start = %d %f\n",
round_down_x, plot_x_start );
}

cpgswin (plot_x_start,
X_end[Current_file1_set],
ymin,(ymax+y_data1_scale)); /*window*/
cpgslw(2); /*Select line width for labels.*/
cpgbox ("BCNST",100.0, 5, "BC", 1000.0, 1); /*box*/
/* cpgbox ("BCNST",100.0, 5, "BC", 0.0, 0);*/ /*box*/
cpglab (Xtitle, Ytitle,T); /*labels*/


cpgslw(3); /*Select line width for plot.*/

cpgline ((int)npts[Current_file1_set], X_data1,Y_data1);
/*Plot spectrum.*/
cpgsch (0.6); /*size of characters, 1.0 is default*/
cpgslw (1); /*Select line width for peak labels.*/

/* Print the peak x-coordinates on the plot. */
for(j=0;j<npeaks;j++)
{
/* Add text peak labels to plot.*/
cpgptxt(Peak_x_list[j],(Peak_y_list[j]+0.25*y_data1_scale),
0.0, 0.5, &x_peak_label[j][0]);
}

cpgsch (1.0); /*size of characters, 1.0 is default*/

/* Print the filename on the plot */
cpgptxt(X_data1[0],(ymin - 0.5*ymax), 0.0, 0.0, (char *)Fname1);

cpgiden; /*Print name, date on bottom.*/
cpgend(); /*End pgplot*/

fl_show_alert("Printing postscript file",
"pgplot_on_file.ps","", 0);
/* (void) system("ghostview pgplot_on_file.ps"); */
(void) system("lpr pgplot_on_file.ps");

-- 
Bob Williams, http://bob.usuf2.usuhs.mil/
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
Xforms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/