- Timestamp:
- 02/27/08 07:09:03 (17 years ago)
- Location:
- trunk/Jgraph
- Files:
-
- 20 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Jgraph/README
r418 r419 47 47 48 48 Author: Jim Plank 49 Email: jsp@princeton.edu 50 USmail: Department of Computer Science 51 Princeton University 52 35 Olden St. 53 Princeton, NJ 08544-2087 49 Page: http://www.cs.utk.edu/~plank 50 Email: plank@cs.utk.edu 51 USmail: Associate Professor 52 Department of Computer Science 53 University of Tennessee 54 203 Claxton Complex 55 1122 Volunteer Blvd. 56 Knoxville, TN 37996-3450 -
trunk/Jgraph/draw.c
r418 r419 9 9 #include <stdio.h> 10 10 #include <math.h> 11 #include <stdlib.h> //by pzn@debian.org 12 #include <string.h> //by pzn@debian.org 11 13 12 14 static char real_eof = EOF; … … 315 317 } 316 318 for (i = 0; i < 4; i++) { 317 if (fscanf(f, "%d", &(bb[i])) != 1) {319 if (fscanf(f, "%d", &(bb[i])) == NULL) { 318 320 fprintf(stderr, "Error: Eps file '%s': eof in %s\n", 319 321 c->eps, "bounding box"); … … 642 644 Graphs gs_p; 643 645 Graph g; 646 int page_counter=0; 644 647 645 648 for (gs_p = first(gs); gs_p != nil(gs); gs_p = next(gs_p)) { 649 page_counter++; 646 650 draw_header(gs_p, pp, landscape); 647 651 for (g = first(gs_p->g); g != nil(gs_p->g); g = next(g)) { … … 649 653 } 650 654 draw_footer(gs_p, pp); 655 } 656 if (pp) { 657 printf("\n%%%%Trailer\n"); 658 printf("%%%%Pages: %i\n",page_counter); 659 printf("%%%%EOF\n"); 651 660 } 652 661 } … … 660 669 char c; 661 670 662 if (gs->page == 1) printf("%%!PS-Adobe-2.0 EPSF-1.2\n"); 663 printf("%%%%Page: %d %d\n", gs->page, gs->page); 664 if (landscape) { 665 printf("%%%%BoundingBox: %d %d %d %d\n", gs->bb[1], gs->bb[0], 666 gs->bb[3], gs->bb[2]); 671 if (gs->page == 1) { 672 if (pp) { 673 printf("%%!PS-Adobe-3.0\n"); 674 printf("%%%%Pages: (atend)\n"); 675 printf("%%%%Creator: jgraph\n"); 676 printf("%%%%EndComments\n\n"); 677 printf("%%%%BeginProlog\n"); 678 printf("%%%%EndProlog\n"); 679 printf("%%%%BeginSetup\n"); 680 printf("%%%%EndSetup\n"); 681 } else { 682 printf("%%!PS-Adobe-2.0 EPSF-1.2\n"); 683 printf("%%%%Creator: jgraph\n"); 684 } 685 } 686 687 if (pp) { 688 printf("\n%%%%Page: %d %d\n", gs->page, gs->page); 689 printf("%%%%BeginPageSetup\n"); 690 printf("%%%%EndPageSetup\n\n"); 691 } 692 693 if ( (gs->page>1) && !pp ) { 694 /* tring EPS with more than one page */ 695 fprintf(stderr, "Error: 'newpage' token is not allowed" 696 " without '-P' command line option.\n"); 697 exit(1); 698 } 699 700 /* if (landscape) { 701 printf("%%%%BoundingBox: %d %d %d %d\n", gs->bb[1], gs->bb[0], 702 gs->bb[3], gs->bb[2]); 667 703 } else { 668 printf("%%%%BoundingBox: %d %d %d %d\n", gs->bb[0], gs->bb[1], 669 gs->bb[2], gs->bb[3]); 670 } 671 672 printf("%%%%EndComments\n"); 704 printf("%%%%BoundingBox: %d %d %d %d\n", gs->bb[0], gs->bb[1], 705 gs->bb[2], gs->bb[3]); 706 } 707 printf("%%%%EndComments\n"); */ 708 709 //BEGIN added by pzn@debian.org 710 { // expands the bounding box to fit characters with tilde, acute,... 711 // if user has set JGRAPH_BORDER enviroment variable 712 int expandborder=0; 713 char *s; \ 714 s=(char *)getenv("JGRAPH_BORDER"); 715 if (s!=NULL) { 716 expandborder=atoi(s); 717 } 718 if (!pp) { 719 if (landscape) { 720 printf("%%%%BoundingBox: %d %d %d %d\n", gs->bb[1]-expandborder, 721 gs->bb[0]-expandborder, gs->bb[3]+expandborder, 722 gs->bb[2]+expandborder); 723 } else { 724 printf("%%%%BoundingBox: %d %d %d %d\n", gs->bb[0]-expandborder, 725 gs->bb[1]-expandborder, gs->bb[2]+expandborder, 726 gs->bb[3]+expandborder); 727 } 728 printf("%%%%EndComments\n\n"); 729 } 730 } 731 732 if (gs->page==1) 733 //reencode fonts to ISOLatin1 or other 734 { //NOTE: this is a preliminary version. It will only work with 735 // the default fonts, that are Times-Roman and Times-Bold 736 // "export JGRAPH_ENCODING=ISOLatin1Encoding" will work in sh 737 char *s; \ 738 s=(char *)getenv("JGRAPH_ENCODING"); 739 if ((s!=NULL) && (strlen(s)>0)) { 740 comment("Setting font encoding by pzn@debian.org"); 741 printf("/Times-Bold findfont\n"); 742 printf("dup length dict begin\n"); 743 printf(" {1 index /FID ne {def} {pop pop} ifelse} forall\n"); 744 printf(" /Encoding %s def\n",s); 745 printf(" currentdict\n"); 746 printf("end\n"); 747 printf("/Times-Bold exch definefont pop\n"); 748 printf("/Times-Roman findfont\n"); 749 printf("dup length dict begin\n"); 750 printf(" {1 index /FID ne {def} {pop pop} ifelse} forall\n"); 751 printf(" /Encoding %s def\n",s); 752 printf(" currentdict\n"); 753 printf("end\n"); 754 printf("/Times-Roman exch definefont pop\n"); 755 comment("End of font encoding"); 756 printf("\n"); 757 } 758 } 759 //END added by pzn 760 673 761 if (landscape) { 674 762 printf("-90 rotate\n"); … … 771 859 grestore(); 772 860 if (pp) printf("showpage\n"); else printf("\n"); 773 } 774 861 862 if (pp) { 863 printf("%%%%PageTrailer\n"); 864 } 865 866 } 867 -
trunk/Jgraph/ex2.jgr
r418 r419 26 26 marktype none linetype solid 27 27 label : N log N / 35000 28 pts shell : nawk \28 pts shell : awk \ 29 29 ' $5 != 0 { \ 30 30 print $5, $5 * log($5) / 35000}' \ … … 53 53 marktype none linetype solid\ 54 54 label : N log N / 35000\ 55 pts shell : nawk \\55 pts shell : awk \\ 56 56 ' $5 != 0 { \\ 57 57 print $5, $5 * log($5) / 35000}' \\ -
trunk/Jgraph/exit.c
r418 r419 15 15 **-- 16 16 **/ 17 #include < varargs.h>17 #include <stdarg.h> 18 18 19 19 exit(va_alist) -
trunk/Jgraph/jgraph.1
r418 r419 65 65 function plotting, and pie graphs. The latter is impossible to do 66 66 with the aid of 67 \fBjgraph , \fR67 \fBjgraph\fR, 68 68 however, the others can be effected with 69 69 \fBjgraph \fR … … 245 245 error will be flagged. 246 246 (copygraph does not copy the values of the 247 \fB\fIhash_at\f B, \fImhash_at\fB,\fR247 \fB\fIhash_at\fR, \fImhash_at\fR,\fR 248 248 and 249 249 \fB\fI\fIhash_label\fB\fR … … 259 259 is the same as appending together the output of separate calls of 260 260 jgraph on the text before the 261 \fB\fInewpage ,\fB\fR261 \fB\fInewpage\fR,\fR 262 262 and on the text after the 263 \fB\fInewpage.\f B\fR263 \fB\fInewpage.\fR 264 264 \fB\fINewpage\fB\fR 265 265 will most likely produce bizarre results if the … … 293 293 \fB\fIbbox\fB\fR 294 294 command. If there's more than one page in the jgraph file, 295 \fB\fIY ,\fB\fR295 \fB\fIY\fR,\fR 296 296 \fB\fIX\fB\fR 297 297 and … … 308 308 jgraph output. Its units are the 309 309 final postscript units. It's probably best to use the 310 \fB\-p\ FR310 \fB\-p\fR 311 311 option 312 312 to see what the bounding box is that jgraph produces, and then 313 313 alter that accordingly with 314 \fB\fIbbox.\f B\fR314 \fB\fIbbox.\fR 315 315 The main use for this is to change the automatic centering that jgraph 316 316 performs: Usually the center of the bounding box that jgraph computes … … 334 334 files (the token specifies the filename) which will be copied directly 335 335 into jgraph's output. 336 The \fIpreamble\f Bis included at the beginning of the output336 The \fIpreamble\fR is included at the beginning of the output 337 337 (after some initial postscript to set things up for jgraph), 338 and the \fIepilogue\f Bis included at the end. A good use for339 the \fIpreamble\f Bis to set up a postscript dictionary if you're338 and the \fIepilogue\fR is included at the end. A good use for 339 the \fIpreamble\fR is to set up a postscript dictionary if you're 340 340 using postscript marks. 341 341 .PD … … 365 365 If the curve doesn't exist, then this command creates it and starts 366 366 editing it. 367 \fINewcurve\f B367 \fINewcurve\fR 368 368 and 369 \fIcurve\f B369 \fIcurve\fR 370 370 interact as 371 \fInewgraph\f B372 and 373 \fIgraph\f B371 \fInewgraph\fR 372 and 373 \fIgraph\fR 374 374 do. 375 375 .TP … … 413 413 .TP 414 414 \fBcopystring \|[\fIinteger\fB\|]\fR 415 \fIString\f B416 and 417 \fIcopystring\f B415 \fIString\fR 416 and 417 \fIcopystring\fR 418 418 are to 419 \fInewstring\f B419 \fInewstring\fR 420 420 as 421 \fIcurve\f B422 and 423 \fIcopycurve\f B421 \fIcurve\fR 422 and 423 \fIcopycurve\fR 424 424 are to 425 \fInewcurve .\fB425 \fInewcurve\fR. 426 426 .TP 427 427 \fBborder\fR … … 430 430 .TP 431 431 \fBnoborder\fR 432 \fIBorder\fR \fB432 \fIBorder\fR 433 433 draws a square border around the area defined by the axes. 434 \fINoborder\f B434 \fINoborder\fR 435 435 specifies no border. 436 \fINoborder\f B436 \fINoborder\fR 437 437 is the default. 438 438 .TP … … 442 442 .TP 443 443 \fBnoclip\fR 444 \fIClip\f B444 \fIClip\fR 445 445 specifies that all curves in the graph will be clipped -- that is, 446 446 no points outside of the of axes will be plotted. Clipping can also be 447 447 specified on a per-curve basis. The default is 448 \fInoclip .\fB448 \fInoclip\fR. 449 449 .TP 450 450 \fBinherit_axes\fR 451 451 This is an old command which is kept for backward compatibility. 452 \fICopycurve .\fB452 \fICopycurve\fR. 453 453 is equivalent to: 454 454 .PP … … 465 465 By default, the bottom left-hand corner of each graph is at point 466 466 (0,0) (final postscript units). 467 \fIX_translate\f B468 and 469 \fIY_translate\f B467 \fIX_translate\fR 468 and 469 \fIY_translate\fR 470 470 translate the bottom left-hand corner of the graph 471 471 \fB\|[\fIfloat\fB\|] \fR … … 475 475 only one graph is drawn, it will always be centered on the page, 476 476 regardless of its 477 \fIX_translate\f B478 and 479 \fIY_translate\f B477 \fIX_translate\fR 478 and 479 \fIY_translate\fR 480 480 values. These values are used for relative placement of the graphs. 481 481 To change the centering of the graphs, use 482 \fIbbox.\f B482 \fIbbox.\fR 483 483 .TP 484 484 \fBX \|[\fIfloat\fB\|]\fR … … 488 488 \fBY \|[\fIfloat\fB\|]\fR 489 489 These are the same as 490 \fIX\f B490 \fIX\fR 491 491 and 492 \fIY\f B492 \fIY\fR 493 493 in the 494 494 Top-level commands, except that they let the user continue editing … … 501 501 These commands act on the current 502 502 axis as chosen by 503 \fIxaxis\f B503 \fIxaxis\fR 504 504 or 505 \fIyaxis\f B505 \fIyaxis\fR 506 506 (see GRAPH EDITING COMMANDS). 507 507 Axis editing terminates when a graph or top-level command is given. … … 519 519 default is linear. If the axis is set to be logarithmic, then values 520 520 <= 0.0 will be disallowed, as they are at negative infinity on the 521 axis. 521 axis. If you are using logarithmic axes and the labels shows 0 0 1 10 522 instead of 0.01 0.1 1 10, then you should read "hash_format" in this 523 section. Hint: xaxis log hash_format g 522 524 .TP 523 525 \fBmin \|[\fIfloat\fB\|]\fR … … 532 534 option. Unless stated, all units (for example point 533 535 plotting, string plotting, etc.) will be in terms of the 534 \fImin\f B535 and 536 \fImax\f B536 \fImin\fR 537 and 538 \fImax\fR 537 539 values of the x and y axes. 538 540 .TP … … 557 559 for the value). By default, each hash mark 558 560 will be labeled with its value. 559 \fIHash\f B561 \fIHash\fR 560 562 and 561 \fIshash\f B563 \fIshash\fR 562 564 are ignored if 563 565 the axes are logarithmic. … … 572 574 = -1. 573 575 If 574 \fIhash\f B576 \fIhash\fR 575 577 is set by the user, 576 \fIshash\f B578 \fIshash\fR 577 579 is defaulted to the 578 \fImin\f B580 \fImin\fR 579 581 value of the axis. 580 582 .TP … … 624 626 Draw the axis line at this point on the other axis. 625 627 The default is usually the other axis's 626 \fImin , \fB628 \fImin\fR, 627 629 however if 628 \fIhash_scale \f B630 \fIhash_scale \fR 629 631 is positive (see 630 \fIhash_scale \f B632 \fIhash_scale \fR 631 633 under ADVANCED AXIS EDITING), it will be 632 634 the other axis's 633 \fImax .\fB635 \fImax\fR. 634 636 .TP 635 637 \fBnodraw\fR … … 637 639 is useful for plotting points with no axes, and for overlaying graphs 638 640 on top of one another with no clashes. This is equivalent to 639 \fIno_draw_axis ,\fB640 \fIno_draw_axis_label ,\fB641 \fIno_draw_hash_marks ,\fB642 and 643 \fIno_draw_hash_labels .\fB641 \fIno_draw_axis\fR, 642 \fIno_draw_axis_label\fR, 643 \fIno_draw_hash_marks\fR, 644 and 645 \fIno_draw_hash_labels\fR. 644 646 .TP 645 647 \fBdraw\fR 646 648 Cancels the effect of 647 \fInodraw . \fB649 \fInodraw\fR. 648 650 Default = 649 \fIdraw .\fB651 \fIdraw\fR 650 652 This is 651 653 equivalent to 652 \fIdraw_axis ,\fB653 \fIdraw_axis_label ,\fB654 \fIdraw_hash_marks ,\fB654 \fIdraw_axis\fR, 655 \fIdraw_axis_label\fR, 656 \fIdraw_hash_marks\fR, 655 657 and 656 \fIdraw_hash_labels .\fB658 \fIdraw_hash_labels\fR. 657 659 .TP 658 660 \fBgrid_lines\fR … … 661 663 .TP 662 664 \fBno_grid_lines\fR 663 \fIGrid_lines\f B665 \fIGrid_lines\fR 664 666 specifies to plot a grid line at each major hash 665 667 mark on this axis. The default is 666 \fIno_grid_lines.\f B668 \fIno_grid_lines.\fR 667 669 .TP 668 670 \fBmgrid_lines\fR … … 671 673 .TP 672 674 \fBno_mgrid_lines\fR 673 \fIMgrid_lines\f B675 \fIMgrid_lines\fR 674 676 specifies to plot a grid line at each minor hash 675 677 mark on this axis. The default is 676 \fIno_mgrid_lines .\fB678 \fIno_mgrid_lines\fR. 677 679 .PD 678 680 .RE … … 682 684 These commands act on the current curve as 683 685 chosen by 684 \fInewcurve\f B686 \fInewcurve\fR 685 687 or 686 \fIcurve\f B688 \fIcurve\fR 687 689 (see GRAPH EDITING COMMANDS). Curve 688 690 editing terminates when a graph or top-level command is given. … … 692 694 This sets the points to plot in this 693 695 curve. The first 694 \fIfloat\f B696 \fIfloat\fR 695 697 is the x value, and the second 696 \fIfloat\f B698 \fIfloat\fR 697 699 is the y 698 700 value of the point. Points are plotted in the order specified. … … 708 710 This allows the user to specify points and ``confidence values'' (otherwise 709 711 known as ``error bars''). The first two 710 \fIfloats\f B712 \fIfloats\fR 711 713 specify the x and y values of 712 714 the point, as above. If 713 715 \fBx_epts\fR 714 716 is specified, then the second two 715 \fIfloats\f B717 \fIfloats\fR 716 718 specify range or confidence values 717 719 for the x value of the point. … … 719 721 original point's y value) 720 722 from the original point. Similarly, 721 \fIy_epts\f B723 \fIy_epts\fR 722 724 specifies range or confidence values for the y value of the point. 723 \fIpts\f B724 \fIx_epts\f B725 and 726 \fIy_epts\f B725 \fIpts\fR 726 \fIx_epts\fR 727 and 728 \fIy_epts\fR 727 729 can all be intermixed. 728 730 .TP … … 745 747 curve points (units are units of the x and y axes). 746 748 Default label values are 0 for x and y, and center justification. 747 \fIPostscript :\fR See the \fIpostscript\fBtoken below.748 \fIEps :\fR See the \fIeps\fBtoken below.749 \fIPostscript\fR: See the \fIpostscript\fR token below. 750 \fIEps\fR: See the \fIeps\fR token below. 749 751 \fINone\fR means that no mark will be 750 752 plotted (this is useful for drawing lines). 751 753 There are four types of \fIgeneral\fR marks, which work using the 752 \fIgmarks\f Bcommand described below. The four marktypes are754 \fIgmarks\fR command described below. The four marktypes are 753 755 \fIgeneral\fR, \fIgeneral_nf\fR, \fIgeneral_bez\fR, and 754 756 \fIgeneral_bez_nf\fR. … … 782 784 \fIgray\fR 783 785 should be from 0 (black) to 1 (white). Values for 784 \fIcolor\fR \fB786 \fIcolor\fR 785 787 should also be from 0 to 1. They are RGB values, and thus define the 786 788 amount of red, green and blue in the curve respectively. Specifying 787 789 color nullifies the gray value, and vice versa. The default is 788 \fIgray 0\f B790 \fIgray 0\fR 789 791 .TP 790 792 \fBfill \|[\fIfloat\fB\|]\fR … … 795 797 This sets the filling of marks which define an area 796 798 to fill (e.g. \fIbox\fR, \fIcircle\fR, \fIxbar\fR). 797 \fIfill\f B799 \fIfill\fR 798 800 defines a gray value, and 799 \fIcfill\f B801 \fIcfill\fR 800 802 defines a color value (see 801 \fIgray\f B802 and 803 \fIcolor\f B803 \fIgray\fR 804 and 805 \fIcolor\fR 804 806 above for a description of the units). 805 807 The default is 806 \fIfill 0\f B808 \fIfill 0\fR 807 809 (black). 808 810 .TP … … 838 840 .TP 839 841 \fBppattern \fItoken\fB \|[\fIfloat\fB\|]\fR 840 \fIPoly\f Ballows the user to make jgraph treat the curve as a842 \fIPoly\fR allows the user to make jgraph treat the curve as a 841 843 closed polygon (or in the case of a bezier, a closed bezier curve). 842 \fIpfill\f B, \fIpcfill\fB and \fIppattern\fBspecify the844 \fIpfill\fR, \fIpcfill\fR and \fIppattern\fR specify the 843 845 filling of the polygon, 844 and work like \fIfill\f B, \fIcfill\fB and \fIpattern\fBabove.845 The default is \fInopoly\f B.846 and work like \fIfill\fR, \fIcfill\fR and \fIpattern\fR above. 847 The default is \fInopoly\fR. 846 848 .TP 847 849 \fBgmarks \|[\|{\fIfloat\fB\|} \|{\fIfloat\fB\|}\|]*\fR 848 \fIGmarks\f B850 \fIGmarks\fR 849 851 is a way for the user to define custom marks. For each mark on 850 \fI(x,y) ,\fB852 \fI(x,y)\fR, 851 853 Each pair of 852 854 \fB\|{\fIfloat_x\fB\|}, \|{\fIfloat_y\fB\|}, \fR … … 879 881 be set up so that when the string or file is put to the output, (0, 0) of 880 882 the the axes is in the middle of the mark, it is rotated by 881 \fImrotate\f Bdegrees, and scaled by882 (\fImarksize_x\f B / 2), \fImarksize_y\fB/ 2).883 \fImrotate\fR degrees, and scaled by 884 (\fImarksize_x\fR / 2), \fImarksize_y\fR / 2). 883 885 Thus, the \fIbox\fR mark could be defined as: 884 886 .PP … … 888 890 .fi 889 891 .PP 890 If the \fImarksize_x\f Bis defined to be (0, 0), then jgraph does no892 If the \fImarksize_x\fR is defined to be (0, 0), then jgraph does no 891 893 scaling. This is useful when the postscript has strings, and the 892 894 user does not want the strings to be scaled. … … 895 897 This allows the user to include an encapsulated postscript file 896 898 and treat it as a mark. It automatically sets the marktype to 897 \fIeps\f B. The file will be scaled so that the bounding899 \fIeps\fR. The file will be scaled so that the bounding 898 900 box is \fImarksize\fR units. Among other things, this allows the 899 901 user to include whole jgraph files as marks. Please see ad.jgr, … … 913 915 .TP 914 916 \fBnorarrows\fR 915 \fIRarrows\f B917 \fIRarrows\fR 916 918 specifies to draw an arrow at the end of every line 917 919 segment in the curve. 918 \fILarrows\f B920 \fILarrows\fR 919 921 specifies to draw an arrow at the beginning of every line segment. 920 922 The size of the arrows can be changed by using 921 \fIasize.\f B923 \fIasize.\fR 922 924 The default is 923 \fInolarrows\f B924 and 925 \fInorarrows\f B.925 \fInolarrows\fR 926 and 927 \fInorarrows\fR. 926 928 Arrows always go exactly to the point specified, with the exception 927 929 of when the marktype is ``circle''. In this case, the arrow goes to … … 941 943 .TP 942 944 \fBnorarrow\fR 943 This is analgous to the above, except that with \fIlarrow\f B, the945 This is analgous to the above, except that with \fIlarrow\fR, the 944 946 only arrow drawn is to the beginning of the first segment in the 945 curve, and with \fIrarrow\f B, the only arrow drawn is to the end947 curve, and with \fIrarrow\fR, the only arrow drawn is to the end 946 948 of the last segment. 947 949 .TP … … 965 967 \fBapattern \fItoken\fB \|[\fIfloat\fB\|]\fR 966 968 These control the grayness or color of arrowheads. 967 \fIAfill\f B,968 \fIacfill\f B969 \fIAfill\fR, 970 \fIacfill\fR 969 971 and 970 \fIapattern\f B972 \fIapattern\fR 971 973 work in the same way as 972 \fIfill\f B,973 \fIcfill\f B974 and 975 \fIpattern\f B974 \fIfill\fR, 975 \fIcfill\fR 976 and 977 \fIpattern\fR 976 978 described above. The default is 977 \fIafill 0\f B979 \fIafill 0\fR 978 980 (black). 979 981 .TP … … 984 986 \fInone\fR. The default is \fInone\fR. \fIGeneral\fR lets the user define 985 987 his own linetype using the 986 \fIglines\f B988 \fIglines\fR 987 989 command described below. Points are connected in the 988 990 order in which they are inserted using the 989 \fIpts\f B991 \fIpts\fR 990 992 command. 991 993 .TP … … 994 996 is as in postscript -- the first number is the length of the first 995 997 dash, the second is the length of the space after the first dash, 996 etc. For example, \fIdotdash\f B could be defined as ``\fIglines\fB5 3998 etc. For example, \fIdotdash\fR could be defined as ``\fIglines\fR 5 3 997 999 1 3''. 998 1000 .TP … … 1008 1010 .br 1009 1011 .ns 1010 \fIBezier\f B1012 \fIBezier\fR 1011 1013 specifies to use the curve's points to define successive bezier curves. 1012 1014 The first point is the starting point. The next two are control points … … 1017 1019 points, where n is at least 1. 1018 1020 In bezier curves, marks and arrows only apply to every third point. 1019 \fINobezier\f Bis the default.1021 \fINobezier\fR is the default. 1020 1022 1021 1023 .TP … … 1027 1029 This turns off clipping. If clipping was specified for the 1028 1030 entire graph, then 1029 \fInoclip\f B1031 \fInoclip\fR 1030 1032 has no effect. 1031 \fINoclip\f B1033 \fINoclip\fR 1032 1034 is the default. 1033 1035 .TP … … 1036 1038 drawing a legend. (see LABEL EDITING COMMANDS and LEGEND EDITING 1037 1039 COMMANDS). Unless the legend entry is 1038 \fIcustom\f B,1040 \fIcustom\fR, 1039 1041 setting any label attribute except for the text itself 1040 1042 will have no effect. … … 1083 1085 These set the horizontal justification to left, 1084 1086 center, and right, respectively. Default = 1085 \fIhjc.\f B1087 \fIhjc.\fR 1086 1088 .TP 1087 1089 \fBvjt\fR … … 1096 1098 These set the vertical justification to top 1097 1099 center, and bottom, respectively. Default = 1098 \fIvjb.\f B1100 \fIvjb.\fR 1099 1101 .TP 1100 1102 \fBrotate \|[\fIfloat\fB\|]\fR … … 1102 1104 \fB\|[\fIfloat\fB\|] \fR 1103 1105 degrees. The point of rotation is defined by the 1104 \fIvj\f B1106 \fIvj\fR 1105 1107 and 1106 \fIhj\f B1108 \fIhj\fR 1107 1109 commands. For example, to rotate 90 degrees about the center of a string, 1108 1110 one would use 1109 \fIvjc hjc rotate 90.\f B1111 \fIvjc hjc rotate 90.\fR 1110 1112 .TP 1111 1113 \fBlgray \|[\fIfloat\fB\|]\fR … … 1115 1117 \fBlcolor \|[\fIfloat\fB \fIfloat\fB \fIfloat\fB\|]\fR 1116 1118 These control the color or the grayness of the label. It works just as 1117 \fIgray\f B1118 and 1119 \fIcolor\f B1119 \fIgray\fR 1120 and 1121 \fIcolor\fR 1120 1122 do for curves and axes. The default depends on the context. For example, 1121 1123 for strings and the title, the default is black. For axis labels and hash … … 1139 1141 fontsize to be 18, you had to set it in each entry's curve. Now, 1140 1142 default legend entry characteristics are set using the 1141 \fIdefaults\f B1143 \fIdefaults\fR 1142 1144 keyword. Unless a 1143 \fIcustom\f B1145 \fIcustom\fR 1144 1146 legend is specified, these default values override any values set in 1145 1147 the entry's curve. Thus, to get all entries to have a fontsize of 1146 1148 18, it must be set using 1147 \fIdefaults fontsize 18 .\fB1149 \fIdefaults fontsize 18\fR. 1148 1150 1149 1151 If legend editing seems cryptic, try the following example: … … 1169 1171 .ns 1170 1172 .TP 1171 \fBoff\ R1173 \fBoff\fR 1172 1174 These turn printing of the legend on and off. The default is on 1173 1175 (but, of course, if there are no curve labels defined, there will … … 1224 1226 .ns 1225 1227 .TP 1226 \fIright\f B1228 \fIright\fR 1227 1229 These will automatically produce a legend to the left or 1228 1230 the right of the graph. 1229 \fILeft\f B1231 \fILeft\fR 1230 1232 is equivalent to 1231 \fIdefaults hjr vjc\f B1232 and 1233 \fIright\f B1233 \fIdefaults hjr vjc\fR 1234 and 1235 \fIright\fR 1234 1236 is equivalent to 1235 \fIdefaults hjl vjc .\fB1237 \fIdefaults hjl vjc\fR. 1236 1238 .TP 1237 1239 \fBtop\fR … … 1242 1244 These will automatically produce a legend on the top or 1243 1245 the bottom of the graph. 1244 \fITop\f B1246 \fITop\fR 1245 1247 is equivalent to 1246 \fIdefaults hjl vjb\f B1248 \fIdefaults hjl vjb\fR 1247 1249 and 1248 \fIbottom\f B1250 \fIbottom\fR 1249 1251 is equivalent to 1250 \fIdefaults hjl vjt .\fB1252 \fIdefaults hjl vjt\fR. 1251 1253 .TP 1252 1254 \fBx \|[\fIfloat\fB\|]\fR … … 1257 1259 These are included mainly for backward compatability to earlier 1258 1260 versions of jgraph. Setting 1259 \fIx\f B1261 \fIx\fR 1260 1262 and 1261 \fIy\f B1263 \fIy\fR 1262 1264 is equivalent to ``defaults x 1263 \fIfloat\f B1265 \fIfloat\fR 1264 1266 y 1265 \fIfloat\f B1267 \fIfloat\fR 1266 1268 hjl vjt'' 1267 1269 .TP … … 1269 1271 This lets the user control where each individual legend 1270 1272 entry goes. The values of the 1271 \fIdefaults\f B1273 \fIdefaults\fR 1272 1274 fields are ignored, and instead, the values of the curve's 1273 1275 labels are used. All justifications have defined results, except 1274 1276 for 1275 \fIhjc\f B.1277 \fIhjc\fR. 1276 1278 Similarly, rotation other than 0 is likely to produce bad effects. 1277 1279 .PD … … 1293 1295 These specify either the grayness of the axis or its color. Values 1294 1296 for 1295 \fIgray\f B1297 \fIgray\fR 1296 1298 should be from 0 (black) to 1 (white). Values for 1297 \fIcolor\f B1299 \fIcolor\fR 1298 1300 should also be from 0 to 1. They are RGB values, and thus define the 1299 1301 amount of red, green and blue in the axis respectively. Specifying 1300 1302 color nullifies the gray value, and vice versa. The default is 1301 \fIgray 0\f B.1303 \fIgray 0\fR. 1302 1304 These values affect every part of the axis: the label, 1303 1305 the hash marks and labels, the axis line and the grid lines. … … 1320 1322 axis lines. 1321 1323 The default 1322 \fIgrid_gray\f B1323 and 1324 \fIgrid_color\f B1324 \fIgrid_gray\fR 1325 and 1326 \fIgrid_color\fR 1325 1327 is the same as the axis's 1326 \fIgray\f B1327 and 1328 \fIcolor\f B.1328 \fIgray\fR 1329 and 1330 \fIcolor\fR. 1329 1331 The default 1330 \fImgrid_gray\f B1331 and 1332 \fImgrid_color\f B1332 \fImgrid_gray\fR 1333 and 1334 \fImgrid_color\fR 1333 1335 is the same as 1334 \fIgrid_gray\f B1335 and 1336 \fIgrid_color\f B.1336 \fIgrid_gray\fR 1337 and 1338 \fIgrid_color\fR. 1337 1339 .TP 1338 1340 \fBhash_at \|[\fIfloat\fB\|]\fR … … 1350 1352 This is so that the user can change the fontsize, justification, 1351 1353 etc., of the hash labels. Editing 1352 \fIhash_labels \f B1354 \fIhash_labels \fR 1353 1355 is just like editing 1354 1356 normal labels (see LABEL EDITING COMMANDS), except that the 1355 \fI: ,\fB1356 \fIx ,\fB1357 and 1358 \fIy\f B1357 \fI:\fR, 1358 \fIx\fR, 1359 and 1360 \fIy\fR 1359 1361 values are all ignored. Defaults for hash labels are as 1360 1362 follows: Fontsize=9, Font=``Times-Roman'', Justification is dependent 1361 1363 on whether it is the x or y axis and whether 1362 \fIhash_scale\f B1364 \fIhash_scale\fR 1363 1365 is positive or negative. 1364 1366 .TP … … 1373 1375 either above or below the axis. This command changes where they are 1374 1376 drawn. 1375 \fIHash_scale\f B1377 \fIHash_scale\fR 1376 1378 still determines whether they are drawn above or 1377 1379 below this point, and their size. … … 1381 1383 drawn either above or below the hash marks (again, this is dependent 1382 1384 on 1383 \fIhash_scale\f B).1385 \fIhash_scale\fR). 1384 1386 This command changes where they are drawn. 1385 1387 Justification and fontsize, etc., can be changed with the 1386 \fIhash_labels\f B1388 \fIhash_labels\fR 1387 1389 command. 1388 1390 .TP … … 1396 1398 \fBjgraph \fR 1397 1399 will automatically create hash marks according to 1398 \fIhash ,\fB1399 \fImhash\f B1400 and 1401 \fIshash\f B1400 \fIhash\fR, 1401 \fImhash\fR 1402 and 1403 \fIshash\fR 1402 1404 (or 1403 \fIlog_base\f B1404 and 1405 \fImhash\f B1405 \fIlog_base\fR 1406 and 1407 \fImhash\fR 1406 1408 for logarithmic axes). 1407 1409 The default is 1408 \fIauto_hash_marks .\fB1410 \fIauto_hash_marks\fR. 1409 1411 .TP 1410 1412 \fBauto_hash_labels\fR … … 1417 1419 \fBjgraph \fR 1418 1420 will automatically create hash labels for the 1419 \fIauto_hash_marks\f B.1421 \fIauto_hash_marks\fR. 1420 1422 Default = 1421 \fIauto_hash_labels\f B.1423 \fIauto_hash_labels\fR. 1422 1424 .TP 1423 1425 \fBdraw_axis\fR … … 1428 1430 This toggles whether or not the axis 1429 1431 line is drawn. Default = 1430 \fIdraw_axis .\fB1432 \fIdraw_axis\fR. 1431 1433 .TP 1432 1434 \fBdraw_axis_label\fR … … 1437 1439 This toggles whether or 1438 1440 not the axis label (as editted by the 1439 \fIlabel\f B1441 \fIlabel\fR 1440 1442 command) is drawn. 1441 1443 Default = 1442 \fIdraw_axis_label .\fB1444 \fIdraw_axis_label\fR. 1443 1445 .TP 1444 1446 \fBdraw_hash_marks\fR … … 1449 1451 This toggles whether or 1450 1452 not the hash marks (both automatic and those created with 1451 \fIhash_at\f B1453 \fIhash_at\fR 1452 1454 and 1453 \fImhash_at\f B)1455 \fImhash_at\fR) 1454 1456 are drawn. Default = 1455 \fIdraw_hash_marks .\fB1457 \fIdraw_hash_marks\fR. 1456 1458 .TP 1457 1459 \fBdraw_hash_labels\fR … … 1462 1464 This toggles whether or 1463 1465 not the hash labels are drawn. Default = 1464 \fIdraw_hash_labels .\fB1466 \fIdraw_hash_labels\fR. 1465 1467 .PD 1466 1468 .RE … … 1471 1473 along the appropriate axis. As a default, they are printed at the 1472 1474 place denoted by the most recent 1473 \fIhash_at\f B1475 \fIhash_at\fR 1474 1476 or 1475 \fImhash_at\f B1477 \fImhash_at\fR 1476 1478 for this 1477 1479 axis, but this can be changed by the 1478 \fIat\f B1480 \fIat\fR 1479 1481 command. If there has been 1480 1482 no 1481 \fIhash_at\f B1483 \fIhash_at\fR 1482 1484 or 1483 \fImhash_at ,\fB1485 \fImhash_at\fR, 1484 1486 then an 1485 \fIat\f B1487 \fIat\fR 1486 1488 command must be given, or 1487 1489 there will be an error. Hash editing terminates when either one of … … 1510 1512 \fBFunction plotting\fR 1511 1513 With the 1512 \fIinclude\f B1514 \fIinclude\fR 1513 1515 and 1514 \fIshell\f B1516 \fIshell\fR 1515 1517 statement, it's easy to 1516 1518 create a file of points of a function with a c or awk program, and … … 1530 1532 a user desires. To embellish the graph with extra text, axes, lines, 1531 1533 etc., it is helpful to use 1532 \fIcopygraph.\f B1534 \fIcopygraph.\fR 1533 1535 The following example graphs show a few examples of different features 1534 of jgraph. They should be in the directory JGRAPH_DIR.1536 of jgraph. They should be in the directory /usr/doc/examples/jgraph. 1535 1537 .sp 1536 1538 - acc.jgr is a simple bar graph. Acc.tex is also included to show … … 1545 1547 - sin.jgr shows how a sin function can be plotted using a simple c 1546 1548 program to produce the sin wave. Moreover, this file shows a use of 1547 \fIcopygraph\f B1549 \fIcopygraph\fR 1548 1550 to plot an extra x and y axis at the 0 point. 1549 1551 .sp … … 1571 1573 complicated output graph can be quite concisely and simply stated. 1572 1574 In this graph, the x axis is a time line. It shows usage of the 1573 \fIhash_label\f B1574 and 1575 \fIhash_labels\f B1575 \fIhash_label\fR 1576 and 1577 \fIhash_labels\fR 1576 1578 commands, as well as displaying how jgraph lets you extract data from 1577 1579 output files with awk. … … 1598 1600 To view these graphs, use jgraph -P, and view the resulting output 1599 1601 file with 1600 \fIgs ,\fB1602 \fIgs\fR, 1601 1603 or a similar postscript viewer. 1602 1604 To make a hard copy of these graphs, pipe the output of jgraph 1603 1605 -P directly to 1604 \fIlpr .\fB1606 \fIlpr\fR. 1605 1607 1606 1608 .SH USING JGRAPH TO DRAW PICTURES … … 1608 1610 preprocessor to make drawings. There are two advantages 1609 1611 using jgraph to draw pictures instead of using standard drawing tools like 1610 \fIxfig\f B,1611 \fIfigtool\f B,1612 \fIxfig\fR, 1613 \fIfigtool\fR, 1612 1614 or 1613 \fIidraw\f B.1615 \fIidraw\fR. 1614 1616 The first is that with jgraph, you know exactly where strings, lines, 1615 1617 boxes, etc, will end up, because you plot them explicitly. The second … … 1625 1627 If you'd like to see some more complex pictures drawn with jgraph, as 1626 1628 well as some hints to make picture-drawing easier, send me email 1627 (jsp@princeton.edu). 1628 1629 .SH EMBEDDING THE OUTPUT IN LATEX 1630 I haven't read the manuals, but the way I've been loading these files 1631 into LaTeX has been as follows: 1632 .PP 1629 (plank@cs.utk.edu). 1630 1631 .SH SUPPORT FOR OTHER FONT ENCODINGS 1632 If you want to use non-english characters to set labels or titles, 1633 set enviroment variable JGRAPH_ENCODING with the font encoding that 1634 you need. This value will be passed directly to the postscript. 1635 1636 Ex. to use ISO-8859-1 characters, try: 1633 1637 .nf 1634 1. Toward the beginning of my LaTeX file, I've had ``\\input{psfig}'' 1635 2. Where I've wanted my file, I've put: 1636 1637 \\begin{figure} 1638 \\centerline{\\psfig{figure=<path-name>/<filename-of-jgraph-output>}} 1639 \\end{figure} 1640 1641 Some versions of dvips or dvi2ps work without the path-name. Others 1642 require that the path-name be present. 1643 1644 3. After running latex on the file, do 1645 1646 lpr -d file.dvi 1647 1648 4. If that doesn't work, try dvips-ing the file and printing the postscript. 1638 1639 export JGRAPH_ENCODING=ISOLatin1Encoding 1649 1640 1650 1641 .fi 1651 .PP 1642 Note: that only works with default fonts. if you use 'font' in stdin 1643 to specify another font, it won't work. 1644 1645 You also have the possibility to expand the bounding box if jgraph 1646 cuts some acute, tilde or special chars near the border; try: 1647 .nf 1648 1649 export JGRAPH_BORDER=5 1650 1651 .fi 1652 This support is currently 'testing' code. Send bugs about it 1653 to pzn@debian.org 1654 1655 .SH INTEGRATION WITH LATEX 1656 .PP 1657 .nf 1658 1. At the top, say 1659 \\usepackage{graphics} 1660 1661 2. The floating object is done using: 1662 1663 \\begin{figure} 1664 \\begin{center} 1665 \\includegraphics{a.eps} 1666 \\end{center} 1667 \\end{figure} 1668 1669 3. Now go through dvips as usual and the .ps file will work. 1670 .fi 1671 .PP 1672 .SH INTEGRATION WITH PDFLATEX 1673 1674 If you are using pdflatex, it requires .pdf files and not .eps 1675 files. In that case, you have to run epstopdf on the .eps file to get 1676 a .pdf file. After that, 1677 .br 1678 \\includegraphics{a.pdf} 1679 .br 1680 does the trick. 1681 .SH SCALING THE INCLUDED GRAPHICS OBJECT 1682 Sometimes you need to change the size of the included object at LaTeX 1683 time. In that case, you need 1684 .br 1685 \\usepackage{graphicx} 1686 .br 1687 instead of graphics, and then say something like 1688 1689 \\includegraphics[width=7cm]{a.eps} 1690 or 1691 \\includegraphics[height=7cm]{a.eps} 1692 1693 you can also omit the .eps/.pdf suffix: 1694 \\includegraphics[height=7cm]{a} 1695 1696 a.eps and a.pdf can both exist, and includegraphics will automatically 1697 choose the correct one for postscript or pdf output, depending if you 1698 are using latex of pdflatex. 1699 1700 .SH AUTOMATION USING MAKE 1701 You can automate the mapping from .jgr -> .eps or .jgr -> .pdf 1702 in your Makefile using these rules: 1703 .nf 1704 1705 --------- cut here --------- 1706 %.eps : %.jgr 1707 jgraph $< > $@ 1708 %.pdf : %.jgr 1709 jgraph $< | epstopdf --filter > $@ 1710 --------- cut here --------- 1711 .fi 1712 1713 jgraph can also return the exit status correctly, so it is also a good 1714 idea to use it in your scripts to prevent bad .eps files if the .jgr 1715 source is bad. The following Makefile can handle its exit status. 1716 .nf 1717 1718 --------- cut here --------- 1719 %.eps : %.jgr 1720 jgraph $< > $@; \\ 1721 if [ "$$?" != "0" ]; then \\ 1722 rm -f $@; \\ 1723 exit 1; \\ 1724 fi 1725 %.pdf : %.jgr 1726 TMP=`tempfile`; jgraph $< > $${TMP}; \\ 1727 if [ "$$?" == "0" ]; then \\ 1728 cat $${TMP} | epstopdf --filter > $@; \\ 1729 rm -f $${TMP}; \\ 1730 else \\ 1731 rm -f $${TMP} $@; \\ 1732 exit 1; \\ 1733 fi; 1734 --------- cut here --------- 1735 .fi 1736 1652 1737 .SH BUGS 1653 1738 Logarithmic axes cannot contain points <= 0. If I have … … 1658 1743 own hash labels. 1659 1744 .sp 1660 There may well be loads of other bugs. Send to jsp@princeton.edu.1745 There may well be loads of other bugs. Send to plank@cs.utk.edu. 1661 1746 .sp 1662 1747 -
trunk/Jgraph/makefile
r418 r419 7 7 # jgraph.1 to be the directory containing the example jgraphs. 8 8 9 CC = gcc -LCC9 CC = cc 10 10 11 11 OBJS = draw.o \ 12 12 edit.o \ 13 jgraph.o \14 13 list.o \ 15 14 printline.o \ … … 43 42 wortman.jps 44 43 44 LOADLIBES = -lm 45 45 46 46 all: jgraph … … 58 58 .tex.dvi: 59 59 latex $*.tex 60 .c.o:61 $(CC) -c -g $*.c60 #.c.o: 61 # $(CC) -c -g $*.c 62 62 63 63 64 64 jgraph: $(OBJS) 65 $(CC) -g $(OBJS) -lm -o jgraph65 # $(CC) -g $(OBJS) -lm -o jgraph 66 66 67 67 sin: sin.o … … 76 76 sin3.jps: sin3.pts 77 77 tree1.jps: tree.awk 78 ( echo "4 3" | nawk -f tree.awk ; echo "xaxis size 5.4" ) | \78 ( echo "4 3" | awk -f tree.awk ; echo "xaxis size 5.4" ) | \ 79 79 jgraph -P > tree1.jps 80 80 tree2.jps: tree.awk 81 ( echo "5 2" | nawk -f tree.awk ; echo "xaxis size 5.4" ) | \81 ( echo "5 2" | awk -f tree.awk ; echo "xaxis size 5.4" ) | \ 82 82 jgraph -P > tree2.jps 83 83 … … 94 94 token.o: token.c list.h 95 95 clean: 96 rm -f *.o a.out *.jps 96 rm -f *.o a.out *.jps jgraph -
trunk/Jgraph/printline.c
r418 r419 8 8 #include "jgraph.h" 9 9 #include <stdio.h> 10 #include <assert.h> //by pzn@debian.org 10 11 11 12 #define LINEWIDTHFACTOR 0.700 … … 229 230 float fnl; 230 231 char *s; 232 unsigned char *s_7bit; // added by pzn@debian.org 231 233 232 234 if (l->label == CNULL) return; … … 267 269 268 270 s = l->label; 271 269 272 for (i = 0; i <= nlines; i++) { 270 printf("(%s) dup stringwidth pop ", s); 273 // BEGIN added by pzn@debian.org 274 // converts 8bit ascii chars to octal value; 275 // 7bit are not converted 276 { 277 int i, j=0, len; 278 len=strlen(s); 279 s_7bit=malloc(len*4+1); 280 assert(s_7bit!=NULL); 281 for (i=0; i<=len; i++) { 282 if((unsigned char)s[i]<128) { 283 //char is ascii 7bit 284 s_7bit[j]=s[i]; 285 j++; 286 } else { 287 //char must be converted to octal 288 sprintf(s_7bit+j,"\\%03o",(unsigned char)s[i]); 289 j+=4; 290 } 291 } 292 s_7bit[j-1]=0; 293 } 294 //printf("(%s) dup stringwidth pop ", s); //disabled by pzn 295 printf("(%s) dup stringwidth pop ", s_7bit); free(s_7bit); 296 // END added by pzn 271 297 if (l->hj == 'c') { 272 298 printf("2 div neg 0 moveto\n");
Note:
See TracChangeset
for help on using the changeset viewer.