Bsoft  2.1.0
Bernard's software package
ps_plot.cpp
Go to the documentation of this file.
1 
9 #include "ps_plot.h"
10 #include "utilities.h"
11 
12 #include <iostream>
13 #include <time.h>
14 
15 // Declaration of global variables
16 extern int verbose; // Level of output to the screen
17 
18 
32 ofstream* ps_open_and_init(Bstring filename, Bstring title, int npages,
33  int width, int height)
34 {
35  if ( verbose & VERB_DEBUG )
36  cout << "DEBUG ps_open_and_init: title=" << title << " npages="
37  << npages << " width=" << width << " height=" << height << endl;
38 
39  ofstream* fps = new ofstream(filename.c_str());
40 
41  time_t t = time(NULL);
42 
43  *fps << "%!PS-Adobe-2.0" << endl;
44  *fps << "%%Creator: Bsoft" << endl;
45  *fps << "%%CreationDate: " << asctime(localtime(&t));
46  *fps << "%%Title: " << title << endl;
47  *fps << "%%DocumentData: Clean7Bit" << endl;
48  *fps << "%%LanguageLevel: 2" << endl;
49  *fps << "%%Origin: 0 0" << endl;
50  *fps << "%%Pages: " << npages << endl;
51  *fps << "%%BoundingBox: 0 0 " << width << " " << height << endl;
52  *fps << "%%EndComments" << endl;
53  *fps << "%%BeginSetup" << endl;
54  *fps << "%%EndSetup" << endl;
55  *fps << "%%EndProlog" << endl;
56 
57  return fps;
58 }
59 
70 ofstream* ps_open_and_init(Bstring filename, Bplot* plot)
71 {
72  if ( verbose & VERB_DEBUG )
73  cout << "DEBUG ps_open_and_init: title=" << plot->title() << " npages="
74  << plot->pages() << " width=" << plot->page_width() << " height=" << plot->page_height() << endl;
75 
76  ofstream* fps = new ofstream(filename.c_str());
77 
78  time_t t = time(NULL);
79 
80  *fps << "%!PS-Adobe-2.0" << endl;
81  *fps << "%%Creator: Bsoft" << endl;
82  *fps << "%%CreationDate: " << asctime(localtime(&t));
83  *fps << "%%Title: " << plot->title() << endl;
84  *fps << "%%DocumentData: Clean7Bit" << endl;
85  *fps << "%%LanguageLevel: 2" << endl;
86  *fps << "%%Origin: 0 0" << endl;
87  *fps << "%%Pages: " << plot->pages() << endl;
88  *fps << "%%BoundingBox: 0 0 " << plot->page_width() << " " << plot->page_height() << endl;
89  *fps << "%%EndComments" << endl;
90  *fps << "%%BeginSetup" << endl;
91  *fps << "%%EndSetup" << endl;
92  *fps << "%%EndProlog" << endl;
93 
94  return fps;
95 }
96 
105 int ps_close(ofstream* fps)
106 {
107  if ( verbose & VERB_DEBUG )
108  cout << "DEBUG ps_close" << endl;
109 
110  *fps << "%%Trailer" << endl;
111  *fps << "%%EOF" << endl << endl;
112 
113  fps->close();
114 
115  delete fps;
116 
117  return 0;
118 }
119 
129 int ps_plot(Bstring filename, Bplot* plot)
130 {
131  if ( verbose )
132  cout << "Plotting a graph to " << filename << endl << endl;
133 
134  ofstream* fps = ps_open_and_init(filename, plot);
135 
136  for ( int i=1; i<=plot->pages(); i++ ) ps_graph(fps, plot, i);
137 
138  ps_close(fps);
139 
140  return 0;
141 }
142 
149 Bplot* ps_read(Bstring& filename)
150 {
151  if ( filename.length() < 1 ) return NULL;
152 
153  if ( verbose & VERB_PROCESS )
154  cout << "# Reading Postscript file: " << filename << endl;
155 
156  Bplot* plot = NULL;
157 
158  ifstream fps(filename.c_str());
159  if ( fps.fail() ) return plot;
160 
161  char aline[1024];
162  long i(0), j;
163  int ncol(0), nrow(0);
164  Bstring sline;
165 
166  // Title
167  while ( fps.getline(aline, 1024) && strncmp(aline, "%%Title:", 8) ) ;
168 
169  Bstring title(aline);
170  title = title.substr(8,title.length());
171 
172  // Start of data
173  while ( fps.getline(aline, 1024) && strncmp(aline, "/Data [", 7) ) ;
174 
175  // Lables line
176  fps.getline(aline, 1024);
177  sline = aline;
178  Bstring* labels = sline.split();
179  Bstring* label;
180 
181  // Determine number of rows and columns
182  while ( fps.getline(aline, 1024) && aline[0] != ']' ) {
183  if ( verbose & VERB_DEBUG )
184  cout << "DEBUG ps_read: aline = \"" << aline << "\"" << endl;
185  sline = aline;
186  sline = sline.substr(0, sline.length() - 1);
187  vector<double> temp = sline.split_into_doubles(0);
188  if ( ncol < temp.size() ) ncol = temp.size();
189  nrow++;
190  }
191 
192  if ( verbose ) {
193  cout << "Plot file: " << filename << endl;
194  cout << "Columns: " << ncol << endl;
195  cout << "Rows: " << nrow << endl;
196  cout << "Labels: ";
197  }
198 
199  plot = new Bplot(1, nrow, ncol);
200  plot->title(title);
201  plot->page(0).title(title);
202  plot->page(0).columns(ncol);
203  for ( i=0, label = labels; i<ncol; i++, label = label->next ) {
204  plot->page(0).column(i).number(i);
205  plot->page(0).column(i).label(*label);
206  if ( verbose )
207  cout << " " << *label;
208  }
209 
210  if ( verbose )
211  cout << endl << endl;
212 
213  string_kill(labels);
214 
215  fps.seekg(0);
216 
217  // Start of data
218  while ( fps.getline(aline, 1024) && strncmp(aline, "/Data [", 7) ) ;
219 
220  // Lables line
221  fps.getline(aline, 1024);
222 
223  // Read the data
224  i = 0;
225  while ( fps.getline(aline, 1024) && aline[0] != ']' ) {
226  if ( verbose & VERB_DEBUG )
227  cout << "DEBUG ps_read: aline = \"" << aline << "\"" << endl;
228  sline = aline;
229  vector<double> temp = sline.split_into_doubles(0);
230  for ( j=0; j<ncol; j++ ) (*plot)[j*nrow+i] = temp[j];
231  i++;
232  }
233 
234  return plot;
235 }
236 
247 int ps_graph(ofstream* fps, Bplot* plot, int page_number)
248 {
249  if ( page_number < 1 ) {
250  cerr << "Error in ps_graph: A page number less than 1 is not valid!" << endl;
251  bexit(-1);
252  }
253 
254  plot->limits();
255 
256  Bpage page = plot->page(page_number-1);
257 
258  if ( verbose & VERB_DEBUG )
259  cout << "DEBUG ps_graph: starting page " << page.number() << endl;
260 
261  if ( page.columns() < 2 ) {
262  cerr << "Error in ps_graph: At least two columns must be specified for page " << page.number() << endl;
263  return -1;
264  }
265 
266  page.limits();
267 
268  long i, j, left = plot->left(), bottom = plot->bottom(), width = plot->width(), height = plot->height();
269  long c, ncol(0), nrow(0), x_inverse, y_inverse, y2_inverse;
270  long max_row(32767);
271  Bstring x_label, y_label, y2_label, *txt;
272  double x_min, x_max, x_inc;
273  double y_min, y_max, y_inc;
274  double y2_min, y2_max, y2_inc;
275  double v_min, v_max;
276  double y_red(0), y_green(0), y_blue(0), y2_red(0), y2_green(0), y2_blue(0);
277  Bcolumn col;
278 
279  nrow = plot->rows();
280  ncol = page.columns();
281 
282  if ( verbose & VERB_DEBUG ) {
283  cout << "DEBUG ps_graph: page index = " << page_number-1 << " columns = " << ncol << endl;
284  cout << "DEBUG ps_graph: indices =";
285  for ( i=0; i<ncol; i++ ) cout << " " << page.column(i).number();
286  cout << endl;
287  cout << "DEBUG ps_graph: axes =";
288  for ( i=0; i<ncol; i++ ) cout << " " << page.column(i).axis();
289  cout << endl;
290  }
291 
292  x_min = page.axis(1).min();
293  x_max = page.axis(1).max();
294  x_inc = page.axis(1).inc();
295  x_inverse = page.axis(1).flags() & 1;
296  y_min = page.axis(3).min();
297  y_max = page.axis(3).max();
298  y_inc = page.axis(3).inc();
299  y_inverse = page.axis(3).flags() & 1;
300  y2_min = page.axis(4).min();
301  y2_max = page.axis(4).max();
302  y2_inc = page.axis(4).inc();
303  y2_inverse = page.axis(4).flags() & 1;
304  v_min = page.axis(5).min();
305  v_max = page.axis(5).max();
306 
307 // cout << "v_min = " << v_min << " v_max = " << v_max << endl;
308 
309  x_label = page.axis(1).label();
310  y_label = page.axis(3).label();
311  y2_label = page.axis(4).label();
312 
313  for ( i=0; i<ncol; i++ ) {
314  col = page.column(i);
315  if ( col.axis() == 1 ) {
316  if ( x_label.length() < 1 ) x_label = col.label();
317  } else if ( col.axis() == 3 ) {
318  if ( y_label.length() < 1 ) y_label = col.label();
319  y_red = col.red();
320  y_green = col.green();
321  y_blue = col.blue();
322  } else if ( col.axis() == 4 ) {
323  if ( y2_label.length() < 1 ) y2_label = col.label();
324  y2_red = col.red();
325  y2_green = col.green();
326  y2_blue = col.blue();
327  }
328  }
329 
330  long hw = (int) (width*1.0/nrow); // Histogram bar width
331  if ( hw < 1 ) hw = 1;
332  long hhw = hw/2;
333 
334  long x_digits = (long) (3 - log(x_max - x_min)/log(10));
335  long y_digits = (long) (3 - log(y_max - y_min)/log(10));
336  long y2_digits = (long) (3 - log(y2_max - y2_min)/log(10));
337 
338  *fps << "%%Page: " << page.number() << " " << page.number() << endl;
339  *fps << "/Helvetica findfont 14 scalefont setfont" << endl;
340  *fps << "40 740 moveto (" << page.title() << ") show" << endl;
341  *fps << "/Left " << left << " def" << endl;
342  *fps << "/Bottom " << bottom << " def" << endl;
343  *fps << "/Height " << height << " def" << endl;
344  *fps << "/Width " << width << " def" << endl;
345  *fps << setprecision(4) << "/x_Min " << x_min << " def" << endl;
346  *fps << "/y_Min " << y_min << " def" << endl;
347  *fps << "/y2_Min " << y2_min << " def" << endl;
348  *fps << "/v_Min " << v_min << " def" << endl;
349  *fps << "/x_Max " << x_max << " def" << endl;
350  *fps << "/y_Max " << y_max << " def" << endl;
351  *fps << "/y2_Max " << y2_max << " def" << endl;
352  *fps << "/v_Max " << v_max << " def" << endl;
353  *fps << "/x_Scale Width x_Max x_Min sub div def" << endl;
354  *fps << "/y_Scale Height y_Max y_Min sub div def" << endl;
355  *fps << "/y2_Scale Height y2_Max y2_Min sub div def" << endl;
356 // *fps << "/v_Scale Height v_Max v_Min sub div def" << endl;
357  *fps << "/v_Scale 1 v_Max v_Min sub div def" << endl;
358  *fps << "/Ncol " << ncol << " def" << endl;
359  *fps << "/Frame { newpath 0 0 moveto 0 Height lineto Width Height lineto Width 0 lineto closepath } def" << endl;
360 
361  *fps << "/Data [" << endl;
362  *fps << "%";
363  for ( j=0; j<ncol; j++ ) {
364  col = page.column(j);
365  *fps << col.label() << " ";
366  }
367  *fps << endl;
368  *fps << setprecision(8);
369  for ( i=0; i<nrow && i<max_row; i++ ) {
370  for ( j=0; j<ncol; j++ ) {
371  c = page.column(j).number();
372 // cout << c << ":" << i << " " << (*plot)[c*nrow+i] << endl;
373  *fps << (*plot)[c*nrow+i] << " ";
374  }
375  *fps << endl;
376  }
377  *fps << "] def" << endl;
378 
379  *fps << "/Helvetica findfont 12 scalefont setfont" << endl;
380  for ( i=140, txt = page.text(); txt; txt = txt->next, i-=18 )
381  *fps << "40 " << i << " moveto (" << *txt << ") show" << endl;
382 
383  *fps << "/Helvetica findfont 14 scalefont setfont" << endl;
384  *fps << "/DeviceRGB setcolorspace" << endl;
385  *fps << "0 0 0 setcolor" << endl;
386 
387  if ( x_label.length() )
388  *fps << left+(width-6*x_label.length())/2 << " " << bottom-40 <<
389  " moveto (" << x_label << ") show" << endl;
390 
391  if ( y_label.length() ) {
392  *fps << y_red << " " << y_green << " " << y_blue << " setcolor" << endl;
393  *fps << left-40 << " " << bottom+(height-6*y_label.length())/2 <<
394  " moveto gsave 90 rotate (" << y_label << ") show grestore" << endl;
395  }
396 
397  if ( y2_label.length() ) {
398  *fps << y2_red << " " << y2_green << " " << y2_blue << " setcolor" << endl;
399  *fps << left+width+35 << " " << bottom+(height-6*y2_label.length())/2 <<
400  " moveto gsave -90 rotate (" << y2_label << ") show grestore" << endl;
401  }
402 
403  *fps << "0 0 0 setcolor" << endl;
404 
405  ps_scale(fps, left, bottom, left+width, bottom, x_min, x_max, x_inc,
406  10, M_PI_2, x_digits, 10, x_inverse);
407 
408  ps_scale(fps, left, bottom, left, bottom+height, y_min, y_max, y_inc,
409  10, 0, y_digits, 10, y_inverse);
410 
411  if ( y2_label.length() )
412  ps_scale(fps, left+width, bottom, left+width, bottom+height, y2_min, y2_max, y2_inc,
413  10, M_PI, y2_digits, 10, y2_inverse);
414 
415  *fps << "gsave" << endl;
416  *fps << " /DeviceRGB setcolorspace" << endl;
417  *fps << " Left Bottom translate Frame stroke Frame clip" << endl;
418  *fps << " /y 0 y_Min sub y_Scale mul def" << endl;
419  *fps << " 0 y moveto Width y lineto stroke" << endl;
420  *fps << " /x 0 x_Min sub x_Scale mul def" << endl;
421  *fps << " x 0 moveto x Height lineto stroke" << endl;
422 
423  for ( i=0; i<ncol; i++ ) {
424  col = page.column(i);
425  if ( col.axis() == 3 || col.axis() == 4 ) {
426  *fps << " " << col.red() << " " << col.green() << " " << col.blue() << " setcolor" << endl;
427  *fps << " /x Data 0 get x_Min sub x_Scale mul def" << endl;
428  *fps << " /y Data " << i << " get y_Min sub y_Scale mul def" << endl;
429  *fps << " x y moveto" << endl;
430  *fps << " Ncol Ncol Data length Ncol sub {" << endl;
431  *fps << " /x_Index exch def" << endl;
432  *fps << " /y_Index x_Index " << i << " add def" << endl;
433  if ( col.type() == 3 ) *fps << " /py_Index y_Index 1 sub def" << endl;
434  if ( col.type() == 4 ) *fps << " /v_Index y_Index 1 add def" << endl;
435  *fps << " /x Data x_Index get x_Min sub x_Scale mul def" << endl;
436  if ( col.axis() == 3 ) {
437  if ( col.type() == 3 ) *fps << " /y Data y_Index get y_Scale mul def" << endl;
438  else *fps << " /y Data y_Index get y_Min sub y_Scale mul def" << endl;
439  } else *fps << " /y Data y_Index get y2_Min sub y2_Scale mul def" << endl;
440  if ( col.type() == 3 ) *fps << " /py Data py_Index get y_Min sub y_Scale mul def" << endl;
441  *fps << " /w " << hw << " def" << endl;
442  *fps << " /xm x " << hhw << " sub def" << endl;
443 // if ( col.type() == 4 ) *fps << " /v Data v_Index get v_Min sub v_Scale mul def" << endl;
444  if ( col.type() == 4 ) {
445  *fps << " /v v_Max Data v_Index get sub v_Scale mul def" << endl;
446  *fps << " v setgray" << endl;
447  }
448  switch ( col.type() ) {
449  case 1: *fps << " xm 0 w y rectstroke" << endl; break; // bar
450  case 2: *fps << " x y lineto" << endl; break; // line
451  case 3: // std line
452  *fps << " x py y sub moveto 0 y 2 mul rlineto" << endl;
453  *fps << " x 3 sub py y sub moveto 6 0 rlineto" << endl;
454  *fps << " x 3 sub py y add moveto 6 0 rlineto" << endl;
455  break;
456  case 4: *fps << " x y 5 0 360 arc fill" << endl; break; // variable circle
457  default: *fps << " x y " << col.element_size() << " 0 360 arc fill" << endl; // circle
458  }
459  *fps << " } for stroke" << endl;
460  }
461  }
462  *fps << "grestore" << endl;
463  *fps << "showpage" << endl;
464 
465  if ( verbose & VERB_DEBUG )
466  cout << "DEBUG ps_graph: finished page " << page.number() << endl;
467 
468  return nrow;
469 }
470 
488 int ps_scale(ofstream* fps, double x1, double y1, double x2, double y2,
489  double min, double max, double increment,
490  double tick_length, double tick_angle,
491  int digits, int fontsize, int inverse)
492 {
493  ios_base::fmtflags fl = fps->flags();
494 
495  long i, j;
496  double value, showval;
497  double x_tick = tick_length*cos(tick_angle);
498  double y_tick = tick_length*sin(tick_angle);
499  double x_step = (x2-x1)*increment/(max - min);
500  double y_step = (y2-y1)*increment/(max - min);
501 
502  if ( digits < 0 ) digits = 0;
503  if ( fontsize < 2 ) fontsize = 10;
504 
505  long integer_size = (int) (log(fabs(max))/log(10.0) + 1);
506  if ( fabs(max) < fabs(min) ) integer_size = (int) (log(fabs(min))/log(10.0) + 1);
507  if ( inverse ) {
508  if ( min <= 0 ) integer_size = (int) (log(fabs(10/max))/log(10.0) + 1);
509  else integer_size = (int) (log(fabs(1/min))/log(10.0) + 1);
510  }
511  if ( integer_size < 1 ) integer_size = 1;
512  integer_size++; // Add one for the sign
513 
514  long number_size = integer_size + 1 + digits;
515  double x_offset = x1 - number_size*fontsize/5;
516  double y_offset = y1 - fontsize/3;
517  if ( x2 - x1 > y2 - y1 )
518  y_offset -= fontsize;
519  else
520  x_offset -= number_size*fontsize/3;
521 
522  if ( tick_angle > 0.75*M_PI && tick_angle < 1.25*M_PI )
523  x_offset = x1 + fontsize/5;
524 
525  if ( verbose & VERB_DEBUG ) {
526  cout << "DEBUG ps_scale: min=" << min << " max=" << max << " increment=" << increment << endl;
527  cout << "DEBUG ps_scale: number_size=" << number_size << " digits=" << digits << endl;
528  }
529 
530  // Ticks and labels
531  *fps << "/Helvetica findfont " << fontsize << " scalefont setfont " << endl;
532  for ( i=0, value=min; value<max+0.01*increment; value+=increment, i++ ) {
533  *fps << x1+i*x_step << " " << y1+i*y_step << " moveto " <<
534  x1+i*x_step+x_tick << " " << y1+i*y_step+y_tick << " lineto stroke" << endl;
535  showval = value;
536  if ( inverse && value ) { if ( value ) showval = 1/value; else showval = 999; }
537 // cout << showval << endl;
538  *fps << x_offset + i*x_step << " " << y_offset + i*y_step << " moveto ("
539  << fixed << setprecision(digits) << right << setw(number_size) << showval << ") (";
540  for ( j=0; j<integer_size; j++ ) *fps << "x";
541  *fps << ".";
542  for ( j=0; j<digits; j++ ) *fps << "x";
543  *fps << ") cvs show" << endl;
544  }
545 
546 // fps->unsetf(fps->flags());
547  fps->flags(fl);
548 
549  return 0;
550 }
551 
561 Bplot* plot_curve(long nrow, double* c0, double* c1, double* c2, double* c3)
562 {
563  int ncol(4);
564  Bstring title("Curve");
565  Bplot* plot = new Bplot(1, nrow, ncol);
566  plot->title(title);
567  plot->page(0).title(title);
568  plot->page(0).columns(ncol);
569  for ( int i=0; i<ncol; i++ ) plot->page(0).column(i).number(i);
570  plot->page(0).column(0).label("x");
571  plot->page(0).column(0).axis(1);
572  plot->page(0).column(1).type(2);
573  plot->page(0).column(1).label("y");
574  plot->page(0).column(1).axis(3);
575  plot->page(0).column(2).type(2);
576  plot->page(0).column(2).label("f");
577  plot->page(0).column(2).axis(3);
578  plot->page(0).column(3).type(2);
579  plot->page(0).column(3).label("c");
580  plot->page(0).column(3).axis(3);
581  plot->page(0).column(1).color(1,0,0);
582  plot->page(0).column(2).color(0,0,1);
583  plot->page(0).column(3).color(0,1,0);
584 // plot->page(0).axis(1).min(0);
585 // plot->page(0).axis(1).max(nrow);
586 // plot->page(0).axis(3).min(prad->minimum());
587 // plot->page(0).axis(3).max(prad->maximum());
588 
589  for ( int i=0, j=nrow, k=j+nrow, l=k+nrow; i<nrow; i++, j++, k++, l++ ) {
590  if ( c0 ) (*plot)[i] = c0[i];
591  if ( c1 ) (*plot)[j] = c1[i];
592  if ( c2 ) (*plot)[k] = c2[i];
593  if ( c3 ) (*plot)[l] = c3[i];
594  }
595 
596  return plot;
597 }
598 
602 int ps_define_arrowline(ofstream* fps)
603 {
604  *fps << "/ArrowHeadSize " << 30 << " def" << endl;
605  *fps << "/ahead {" << endl;
606  *fps << " 1 index 4 index sub" << endl;
607  *fps << " 1 index 4 index sub" << endl;
608  *fps << " exch atan" << endl;
609  *fps << " ArrowHeadSize -.8 mul" << endl;
610  *fps << " dup" << endl;
611  *fps << " 2 index cos mul 4 index add" << endl;
612  *fps << " exch" << endl;
613  *fps << " 2 index sin mul 3 index add" << endl;
614  *fps << " 5 2 roll" << endl;
615  *fps << " gsave" << endl;
616  *fps << " 3 1 roll" << endl;
617  *fps << " translate" << endl;
618  *fps << " rotate" << endl;
619  *fps << " newpath" << endl;
620  *fps << " 0 0 moveto" << endl;
621  *fps << " ArrowHeadSize dup neg exch .25 mul" << endl;
622  *fps << " 2 copy lineto" << endl;
623  *fps << " ArrowHeadSize -.8 mul 0" << endl;
624  *fps << " 2 copy" << endl;
625  *fps << " 6 4 roll" << endl;
626  *fps << " neg curveto" << endl;
627  *fps << " closepath fill" << endl;
628  *fps << " grestore" << endl;
629  *fps << "} bind def" << endl;
630  *fps << "/arrowline {" << endl;
631  *fps << " ahead" << endl;
632  *fps << " moveto" << endl;
633  *fps << " lineto" << endl;
634  *fps << " stroke" << endl;
635  *fps << "} bind def" << endl;
636 
637  return 0;
638 }
Bplot::page_width
long page_width()
Definition: Bplot.h:198
VERB_DEBUG
#define VERB_DEBUG
Definition: utilities.h:116
string_kill
int string_kill(Bstring *list)
Kills a string linked list.
Definition: Bstring.cpp:768
Baxis::flags
long flags()
Definition: Bplot.h:38
Bstring
Definition: Bstring.h:29
Bplot::rows
void rows(long n)
Definition: Bplot.h:212
Bcolumn
Definition: Bplot.h:42
Bcolumn::color
double * color()
Definition: Bplot.h:76
Bcolumn::element_size
double element_size()
Definition: Bplot.h:74
bexit
int bexit(int value)
Exit function for cleanup and debugging.
Definition: utilities.cpp:280
Bplot::height
long height()
Definition: Bplot.h:202
Bplot
Definition: Bplot.h:146
Bcolumn::type
long type()
Definition: Bplot.h:66
VERB_PROCESS
#define VERB_PROCESS
Definition: utilities.h:111
ps_scale
int ps_scale(ofstream *fps, double x1, double y1, double x2, double y2, double min, double max, double increment, double tick_length, double tick_angle, int digits, int fontsize, int inverse)
Generates a scale for a postscript graph.
Definition: ps_plot.cpp:488
Bcolumn::axis
long axis()
Definition: Bplot.h:68
M_PI_2
#define M_PI_2
Definition: utilities.h:66
ps_plot.h
Header file for postscript output functions.
Bstring::c_str
const char * c_str()
Definition: Bstring.h:70
Bpage::text
Bstring * text()
Definition: Bplot.h:121
Bpage::axis
Baxis & axis(long id)
Definition: Bplot.h:117
Bpage::title
Bstring & title()
Definition: Bplot.h:100
Bpage::limits
void limits()
Definition: Bplot.h:123
Bcolumn::green
double green()
Definition: Bplot.h:79
Baxis::inc
double inc()
Definition: Bplot.h:34
Bplot::left
long left()
Definition: Bplot.h:204
Bpage::column
Bcolumn & column(long i)
Definition: Bplot.h:110
Bstring::split_into_doubles
vector< double > split_into_doubles(const Bstring &delim)
Definition: Bstring.cpp:673
Bplot::title
Bstring & title()
Definition: Bplot.h:194
Bplot::bottom
long bottom()
Definition: Bplot.h:205
Baxis::min
double min()
Definition: Bplot.h:30
Bpage::number
void number(long n)
Definition: Bplot.h:103
Bplot::limits
void limits()
Definition: Bplot.h:224
Baxis::label
Bstring & label()
Definition: Bplot.h:28
M_PI
#define M_PI
Definition: utilities.h:63
utilities.h
Header file for general utilities.
Bstring::substr
Bstring substr(long start, long len)
Definition: Bstring.cpp:332
ps_graph
int ps_graph(ofstream *fps, Bplot *plot, int page_number)
Generates postscript graphs.
Definition: ps_plot.cpp:247
Bcolumn::blue
double blue()
Definition: Bplot.h:80
Bstring::length
long length() const
Definition: Bstring.cpp:263
ps_define_arrowline
int ps_define_arrowline(ofstream *fps)
Generates an arrow and line.
Definition: ps_plot.cpp:602
ps_close
int ps_close(ofstream *fps)
Closes a postscript file.
Definition: ps_plot.cpp:105
Bpage
Definition: Bplot.h:83
Bstring::next
Bstring * next
Definition: Bstring.h:31
Bcolumn::red
double red()
Definition: Bplot.h:78
Bplot::pages
void pages(long n)
Definition: Bplot.h:206
ps_plot
int ps_plot(Bstring filename, Bplot *plot)
Generates postscript graphs.
Definition: ps_plot.cpp:129
Bplot::page_height
long page_height()
Definition: Bplot.h:199
Bstring::split
Bstring * split()
Definition: Bstring.cpp:605
verbose
int verbose
Bcolumn::label
Bstring & label()
Definition: Bplot.h:63
Bplot::page
Bpage & page(long i)
Definition: Bplot.h:216
ps_read
Bplot * ps_read(Bstring &filename)
Reads a postscript file with a data table.
Definition: ps_plot.cpp:149
Bcolumn::number
long number()
Definition: Bplot.h:61
Baxis::max
double max()
Definition: Bplot.h:32
Bplot::width
long width()
Definition: Bplot.h:201
Bpage::columns
void columns(long ncol)
Definition: Bplot.h:105
plot_curve
Bplot * plot_curve(long nrow, double *c0, double *c1, double *c2, double *c3)
Generates 1-3 line plot.
Definition: ps_plot.cpp:561
ps_open_and_init
ofstream * ps_open_and_init(Bstring filename, Bstring title, int npages, int width, int height)
Opens and initializes a postscript file.
Definition: ps_plot.cpp:32