File: plotutils.texi

package info (click to toggle)
plotutils 2.4.1-11
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 11,676 kB
  • ctags: 6,967
  • sloc: ansic: 76,305; sh: 15,172; cpp: 12,403; yacc: 2,604; makefile: 888; lex: 144
file content (11713 lines) | stat: -rw-r--r-- 511,275 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
9339
9340
9341
9342
9343
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
9378
9379
9380
9381
9382
9383
9384
9385
9386
9387
9388
9389
9390
9391
9392
9393
9394
9395
9396
9397
9398
9399
9400
9401
9402
9403
9404
9405
9406
9407
9408
9409
9410
9411
9412
9413
9414
9415
9416
9417
9418
9419
9420
9421
9422
9423
9424
9425
9426
9427
9428
9429
9430
9431
9432
9433
9434
9435
9436
9437
9438
9439
9440
9441
9442
9443
9444
9445
9446
9447
9448
9449
9450
9451
9452
9453
9454
9455
9456
9457
9458
9459
9460
9461
9462
9463
9464
9465
9466
9467
9468
9469
9470
9471
9472
9473
9474
9475
9476
9477
9478
9479
9480
9481
9482
9483
9484
9485
9486
9487
9488
9489
9490
9491
9492
9493
9494
9495
9496
9497
9498
9499
9500
9501
9502
9503
9504
9505
9506
9507
9508
9509
9510
9511
9512
9513
9514
9515
9516
9517
9518
9519
9520
9521
9522
9523
9524
9525
9526
9527
9528
9529
9530
9531
9532
9533
9534
9535
9536
9537
9538
9539
9540
9541
9542
9543
9544
9545
9546
9547
9548
9549
9550
9551
9552
9553
9554
9555
9556
9557
9558
9559
9560
9561
9562
9563
9564
9565
9566
9567
9568
9569
9570
9571
9572
9573
9574
9575
9576
9577
9578
9579
9580
9581
9582
9583
9584
9585
9586
9587
9588
9589
9590
9591
9592
9593
9594
9595
9596
9597
9598
9599
9600
9601
9602
9603
9604
9605
9606
9607
9608
9609
9610
9611
9612
9613
9614
9615
9616
9617
9618
9619
9620
9621
9622
9623
9624
9625
9626
9627
9628
9629
9630
9631
9632
9633
9634
9635
9636
9637
9638
9639
9640
9641
9642
9643
9644
9645
9646
9647
9648
9649
9650
9651
9652
9653
9654
9655
9656
9657
9658
9659
9660
9661
9662
9663
9664
9665
9666
9667
9668
9669
9670
9671
9672
9673
9674
9675
9676
9677
9678
9679
9680
9681
9682
9683
9684
9685
9686
9687
9688
9689
9690
9691
9692
9693
9694
9695
9696
9697
9698
9699
9700
9701
9702
9703
9704
9705
9706
9707
9708
9709
9710
9711
9712
9713
9714
9715
9716
9717
9718
9719
9720
9721
9722
9723
9724
9725
9726
9727
9728
9729
9730
9731
9732
9733
9734
9735
9736
9737
9738
9739
9740
9741
9742
9743
9744
9745
9746
9747
9748
9749
9750
9751
9752
9753
9754
9755
9756
9757
9758
9759
9760
9761
9762
9763
9764
9765
9766
9767
9768
9769
9770
9771
9772
9773
9774
9775
9776
9777
9778
9779
9780
9781
9782
9783
9784
9785
9786
9787
9788
9789
9790
9791
9792
9793
9794
9795
9796
9797
9798
9799
9800
9801
9802
9803
9804
9805
9806
9807
9808
9809
9810
9811
9812
9813
9814
9815
9816
9817
9818
9819
9820
9821
9822
9823
9824
9825
9826
9827
9828
9829
9830
9831
9832
9833
9834
9835
9836
9837
9838
9839
9840
9841
9842
9843
9844
9845
9846
9847
9848
9849
9850
9851
9852
9853
9854
9855
9856
9857
9858
9859
9860
9861
9862
9863
9864
9865
9866
9867
9868
9869
9870
9871
9872
9873
9874
9875
9876
9877
9878
9879
9880
9881
9882
9883
9884
9885
9886
9887
9888
9889
9890
9891
9892
9893
9894
9895
9896
9897
9898
9899
9900
9901
9902
9903
9904
9905
9906
9907
9908
9909
9910
9911
9912
9913
9914
9915
9916
9917
9918
9919
9920
9921
9922
9923
9924
9925
9926
9927
9928
9929
9930
9931
9932
9933
9934
9935
9936
9937
9938
9939
9940
9941
9942
9943
9944
9945
9946
9947
9948
9949
9950
9951
9952
9953
9954
9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
9966
9967
9968
9969
9970
9971
9972
9973
9974
9975
9976
9977
9978
9979
9980
9981
9982
9983
9984
9985
9986
9987
9988
9989
9990
9991
9992
9993
9994
9995
9996
9997
9998
9999
10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
10011
10012
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
10041
10042
10043
10044
10045
10046
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
10065
10066
10067
10068
10069
10070
10071
10072
10073
10074
10075
10076
10077
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092
10093
10094
10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
10108
10109
10110
10111
10112
10113
10114
10115
10116
10117
10118
10119
10120
10121
10122
10123
10124
10125
10126
10127
10128
10129
10130
10131
10132
10133
10134
10135
10136
10137
10138
10139
10140
10141
10142
10143
10144
10145
10146
10147
10148
10149
10150
10151
10152
10153
10154
10155
10156
10157
10158
10159
10160
10161
10162
10163
10164
10165
10166
10167
10168
10169
10170
10171
10172
10173
10174
10175
10176
10177
10178
10179
10180
10181
10182
10183
10184
10185
10186
10187
10188
10189
10190
10191
10192
10193
10194
10195
10196
10197
10198
10199
10200
10201
10202
10203
10204
10205
10206
10207
10208
10209
10210
10211
10212
10213
10214
10215
10216
10217
10218
10219
10220
10221
10222
10223
10224
10225
10226
10227
10228
10229
10230
10231
10232
10233
10234
10235
10236
10237
10238
10239
10240
10241
10242
10243
10244
10245
10246
10247
10248
10249
10250
10251
10252
10253
10254
10255
10256
10257
10258
10259
10260
10261
10262
10263
10264
10265
10266
10267
10268
10269
10270
10271
10272
10273
10274
10275
10276
10277
10278
10279
10280
10281
10282
10283
10284
10285
10286
10287
10288
10289
10290
10291
10292
10293
10294
10295
10296
10297
10298
10299
10300
10301
10302
10303
10304
10305
10306
10307
10308
10309
10310
10311
10312
10313
10314
10315
10316
10317
10318
10319
10320
10321
10322
10323
10324
10325
10326
10327
10328
10329
10330
10331
10332
10333
10334
10335
10336
10337
10338
10339
10340
10341
10342
10343
10344
10345
10346
10347
10348
10349
10350
10351
10352
10353
10354
10355
10356
10357
10358
10359
10360
10361
10362
10363
10364
10365
10366
10367
10368
10369
10370
10371
10372
10373
10374
10375
10376
10377
10378
10379
10380
10381
10382
10383
10384
10385
10386
10387
10388
10389
10390
10391
10392
10393
10394
10395
10396
10397
10398
10399
10400
10401
10402
10403
10404
10405
10406
10407
10408
10409
10410
10411
10412
10413
10414
10415
10416
10417
10418
10419
10420
10421
10422
10423
10424
10425
10426
10427
10428
10429
10430
10431
10432
10433
10434
10435
10436
10437
10438
10439
10440
10441
10442
10443
10444
10445
10446
10447
10448
10449
10450
10451
10452
10453
10454
10455
10456
10457
10458
10459
10460
10461
10462
10463
10464
10465
10466
10467
10468
10469
10470
10471
10472
10473
10474
10475
10476
10477
10478
10479
10480
10481
10482
10483
10484
10485
10486
10487
10488
10489
10490
10491
10492
10493
10494
10495
10496
10497
10498
10499
10500
10501
10502
10503
10504
10505
10506
10507
10508
10509
10510
10511
10512
10513
10514
10515
10516
10517
10518
10519
10520
10521
10522
10523
10524
10525
10526
10527
10528
10529
10530
10531
10532
10533
10534
10535
10536
10537
10538
10539
10540
10541
10542
10543
10544
10545
10546
10547
10548
10549
10550
10551
10552
10553
10554
10555
10556
10557
10558
10559
10560
10561
10562
10563
10564
10565
10566
10567
10568
10569
10570
10571
10572
10573
10574
10575
10576
10577
10578
10579
10580
10581
10582
10583
10584
10585
10586
10587
10588
10589
10590
10591
10592
10593
10594
10595
10596
10597
10598
10599
10600
10601
10602
10603
10604
10605
10606
10607
10608
10609
10610
10611
10612
10613
10614
10615
10616
10617
10618
10619
10620
10621
10622
10623
10624
10625
10626
10627
10628
10629
10630
10631
10632
10633
10634
10635
10636
10637
10638
10639
10640
10641
10642
10643
10644
10645
10646
10647
10648
10649
10650
10651
10652
10653
10654
10655
10656
10657
10658
10659
10660
10661
10662
10663
10664
10665
10666
10667
10668
10669
10670
10671
10672
10673
10674
10675
10676
10677
10678
10679
10680
10681
10682
10683
10684
10685
10686
10687
10688
10689
10690
10691
10692
10693
10694
10695
10696
10697
10698
10699
10700
10701
10702
10703
10704
10705
10706
10707
10708
10709
10710
10711
10712
10713
10714
10715
10716
10717
10718
10719
10720
10721
10722
10723
10724
10725
10726
10727
10728
10729
10730
10731
10732
10733
10734
10735
10736
10737
10738
10739
10740
10741
10742
10743
10744
10745
10746
10747
10748
10749
10750
10751
10752
10753
10754
10755
10756
10757
10758
10759
10760
10761
10762
10763
10764
10765
10766
10767
10768
10769
10770
10771
10772
10773
10774
10775
10776
10777
10778
10779
10780
10781
10782
10783
10784
10785
10786
10787
10788
10789
10790
10791
10792
10793
10794
10795
10796
10797
10798
10799
10800
10801
10802
10803
10804
10805
10806
10807
10808
10809
10810
10811
10812
10813
10814
10815
10816
10817
10818
10819
10820
10821
10822
10823
10824
10825
10826
10827
10828
10829
10830
10831
10832
10833
10834
10835
10836
10837
10838
10839
10840
10841
10842
10843
10844
10845
10846
10847
10848
10849
10850
10851
10852
10853
10854
10855
10856
10857
10858
10859
10860
10861
10862
10863
10864
10865
10866
10867
10868
10869
10870
10871
10872
10873
10874
10875
10876
10877
10878
10879
10880
10881
10882
10883
10884
10885
10886
10887
10888
10889
10890
10891
10892
10893
10894
10895
10896
10897
10898
10899
10900
10901
10902
10903
10904
10905
10906
10907
10908
10909
10910
10911
10912
10913
10914
10915
10916
10917
10918
10919
10920
10921
10922
10923
10924
10925
10926
10927
10928
10929
10930
10931
10932
10933
10934
10935
10936
10937
10938
10939
10940
10941
10942
10943
10944
10945
10946
10947
10948
10949
10950
10951
10952
10953
10954
10955
10956
10957
10958
10959
10960
10961
10962
10963
10964
10965
10966
10967
10968
10969
10970
10971
10972
10973
10974
10975
10976
10977
10978
10979
10980
10981
10982
10983
10984
10985
10986
10987
10988
10989
10990
10991
10992
10993
10994
10995
10996
10997
10998
10999
11000
11001
11002
11003
11004
11005
11006
11007
11008
11009
11010
11011
11012
11013
11014
11015
11016
11017
11018
11019
11020
11021
11022
11023
11024
11025
11026
11027
11028
11029
11030
11031
11032
11033
11034
11035
11036
11037
11038
11039
11040
11041
11042
11043
11044
11045
11046
11047
11048
11049
11050
11051
11052
11053
11054
11055
11056
11057
11058
11059
11060
11061
11062
11063
11064
11065
11066
11067
11068
11069
11070
11071
11072
11073
11074
11075
11076
11077
11078
11079
11080
11081
11082
11083
11084
11085
11086
11087
11088
11089
11090
11091
11092
11093
11094
11095
11096
11097
11098
11099
11100
11101
11102
11103
11104
11105
11106
11107
11108
11109
11110
11111
11112
11113
11114
11115
11116
11117
11118
11119
11120
11121
11122
11123
11124
11125
11126
11127
11128
11129
11130
11131
11132
11133
11134
11135
11136
11137
11138
11139
11140
11141
11142
11143
11144
11145
11146
11147
11148
11149
11150
11151
11152
11153
11154
11155
11156
11157
11158
11159
11160
11161
11162
11163
11164
11165
11166
11167
11168
11169
11170
11171
11172
11173
11174
11175
11176
11177
11178
11179
11180
11181
11182
11183
11184
11185
11186
11187
11188
11189
11190
11191
11192
11193
11194
11195
11196
11197
11198
11199
11200
11201
11202
11203
11204
11205
11206
11207
11208
11209
11210
11211
11212
11213
11214
11215
11216
11217
11218
11219
11220
11221
11222
11223
11224
11225
11226
11227
11228
11229
11230
11231
11232
11233
11234
11235
11236
11237
11238
11239
11240
11241
11242
11243
11244
11245
11246
11247
11248
11249
11250
11251
11252
11253
11254
11255
11256
11257
11258
11259
11260
11261
11262
11263
11264
11265
11266
11267
11268
11269
11270
11271
11272
11273
11274
11275
11276
11277
11278
11279
11280
11281
11282
11283
11284
11285
11286
11287
11288
11289
11290
11291
11292
11293
11294
11295
11296
11297
11298
11299
11300
11301
11302
11303
11304
11305
11306
11307
11308
11309
11310
11311
11312
11313
11314
11315
11316
11317
11318
11319
11320
11321
11322
11323
11324
11325
11326
11327
11328
11329
11330
11331
11332
11333
11334
11335
11336
11337
11338
11339
11340
11341
11342
11343
11344
11345
11346
11347
11348
11349
11350
11351
11352
11353
11354
11355
11356
11357
11358
11359
11360
11361
11362
11363
11364
11365
11366
11367
11368
11369
11370
11371
11372
11373
11374
11375
11376
11377
11378
11379
11380
11381
11382
11383
11384
11385
11386
11387
11388
11389
11390
11391
11392
11393
11394
11395
11396
11397
11398
11399
11400
11401
11402
11403
11404
11405
11406
11407
11408
11409
11410
11411
11412
11413
11414
11415
11416
11417
11418
11419
11420
11421
11422
11423
11424
11425
11426
11427
11428
11429
11430
11431
11432
11433
11434
11435
11436
11437
11438
11439
11440
11441
11442
11443
11444
11445
11446
11447
11448
11449
11450
11451
11452
11453
11454
11455
11456
11457
11458
11459
11460
11461
11462
11463
11464
11465
11466
11467
11468
11469
11470
11471
11472
11473
11474
11475
11476
11477
11478
11479
11480
11481
11482
11483
11484
11485
11486
11487
11488
11489
11490
11491
11492
11493
11494
11495
11496
11497
11498
11499
11500
11501
11502
11503
11504
11505
11506
11507
11508
11509
11510
11511
11512
11513
11514
11515
11516
11517
11518
11519
11520
11521
11522
11523
11524
11525
11526
11527
11528
11529
11530
11531
11532
11533
11534
11535
11536
11537
11538
11539
11540
11541
11542
11543
11544
11545
11546
11547
11548
11549
11550
11551
11552
11553
11554
11555
11556
11557
11558
11559
11560
11561
11562
11563
11564
11565
11566
11567
11568
11569
11570
11571
11572
11573
11574
11575
11576
11577
11578
11579
11580
11581
11582
11583
11584
11585
11586
11587
11588
11589
11590
11591
11592
11593
11594
11595
11596
11597
11598
11599
11600
11601
11602
11603
11604
11605
11606
11607
11608
11609
11610
11611
11612
11613
11614
11615
11616
11617
11618
11619
11620
11621
11622
11623
11624
11625
11626
11627
11628
11629
11630
11631
11632
11633
11634
11635
11636
11637
11638
11639
11640
11641
11642
11643
11644
11645
11646
11647
11648
11649
11650
11651
11652
11653
11654
11655
11656
11657
11658
11659
11660
11661
11662
11663
11664
11665
11666
11667
11668
11669
11670
11671
11672
11673
11674
11675
11676
11677
11678
11679
11680
11681
11682
11683
11684
11685
11686
11687
11688
11689
11690
11691
11692
11693
11694
11695
11696
11697
11698
11699
11700
11701
11702
11703
11704
11705
11706
11707
11708
11709
11710
11711
11712
11713
\input texinfo   @c -*-texinfo-*-
@c %**start of header
@setfilename plotutils.info
@settitle The Plotutils Package
@c For double-sided printing, uncomment:
@c @setchapternewpage odd
@c %**end of header

@dircategory GNU Plotting Utilities
@direntry
* Plotutils: (plotutils).      GNU plotting utilities.
* Plotting utilities: (plotutils).      GNU plotting utilities.
* graph: (plotutils)graph Invocation.   Plot datasets, possibly in real time.
* plot: (plotutils)plot Invocation.     Convert and display plot files.
* pic2plot: (plotutils)pic2plot Invocation.   Convert files in the pic language
* tek2plot: (plotutils)tek2plot Invocation.   Translate legacy Tektronix data.
* plotfont: (plotutils)plotfont Invocation.   Plot character maps of fonts.
* spline: (plotutils)spline Invocation. Interpolate between points in datasets.
* ode: (plotutils)ode Invocation.       Integrate differential equations.
* libplot: (plotutils)libplot.          A library for 2-D vector graphics.
* Appendices: (plotutils)Appendices.    More info on the plotting utilities.
@end direntry

@iftex
@hyphenation{Zapf-Ding-bats Hershey-Serif-Symbol Hershey-Sans-Symbol Web-CGM}
@end iftex

@ifinfo
This file documents version 2.4.1 of the GNU plotting
utilities package, including GNU libplot 4.1

Copyright @copyright{} 1989--2000 Free Software Foundation, Inc.

Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
are preserved on all copies.

Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided that the entire
resulting derived work is distributed under the terms of a permission
notice identical to this one.

Permission is granted to copy and distribute translations of this manual
into another language, under the above conditions for modified versions,
except that this permission notice may be stated in a translation approved
by the Foundation.
@end ifinfo

@titlepage
@title The GNU Plotting Utilities
@subtitle Programs and functions for vector graphics and data plotting
@subtitle Version 2.4.1
@author Robert S. Maier and Nicholas B. Tufillaro
@page
@vskip 0pt plus 1filll
Copyright @copyright{} 1989--2000 Free Software Foundation, Inc.

Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
are preserved on all copies.

Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided that the entire
resulting derived work is distributed under the terms of a permission
notice identical to this one.

Permission is granted to copy and distribute translations of this manual
into another language, under the above conditions for modified versions,
except that this permission notice may be stated in a translation approved
by the Foundation.
@end titlepage
@page

@node Top, Plotutils Intro, (dir), (dir)
@ifnottex
This is the documentation for version 2.4.1 of the GNU plotting
utilities package, including GNU libplot 4.1.  The package consists of
programs and functions for data plotting and vector graphics.
@end ifnottex

@menu
* Plotutils Intro::     GNU plotting utilities
* graph::               graph, a program for plotting datasets
* plot::                plot, a plot format conversion program
* pic2plot::            pic2plot, a translator for files in the pic language
* tek2plot::            tek2plot, a translator for legacy Tektronix files
* plotfont::            plotfont, a program for plotting font character maps
* spline::              spline, an interpolation program
* ode::                 ode, a differential equation integrator
* libplot::             A library for device-independent 2-D vector graphics
* Appendices::          Additional Information
@end menu

@node Plotutils Intro, graph, Top, Top
@chapter The GNU Plotting Utilities

The GNU plotting utilities consist of eight command-line programs: the
graphics programs @code{graph}, @code{plot}, @code{pic2plot},
@code{tek2plot}, and @code{plotfont}, and the mathematical programs
@code{spline}, @code{ode}, and @code{double}.  Distributed with these
programs is GNU @code{libplot}, the library on which the graphics
programs are based.  GNU @code{libplot} is a function library for
device-independent two-dimensional vector graphics, including vector
graphics animations under the @w{X Window} System.  @w{It has} bindings
for both C @w{and C++}.

The graphics programs and GNU @code{libplot} can export vector graphics
in the following formats.

@table @asis
@item X
If this output option is selected, there is no output file.  Output is
directed to a popped-up window on an @w{X Window} System display.
@item PNG
This is ``portable network graphics'' format, which is increasingly
popular on the Web.  Unlike GIF format, it is unencumbered by patents.
Files in PNG format may be viewed or edited with many applications, such
as the free @code{ImageMagick} package.
@item PNM
This is ``portable anymap'' format.  There are three types of portable
anymap: PBM (portable bitmap, for monochrome images), PGM (portable
graymap), and PPM (portable pixmap, for colored images).  The output
file will use whichever is most appropriate.  Portable anymaps may be
translated to other formats with the @code{netpbm} package.
@item GIF
This is pseudo-GIF format rather than true GIF format.  Unlike GIF
format it does not use LZW compression, so it does not transgress the
Unisys LZW patent.  However, files in pseudo-GIF format may be viewed or
edited with any application that accepts GIF format, @w{such as}
@code{xv} and the @code{ImageMagick} package.
@item SVG
This is Scalable Vector Graphics format.  SVG is a new, XML-based format
for vector graphics on the Web.  The @uref{http://www.w3.org, @w{W3
Consortium}} has more information on SVG, which is being developed by
its @uref{http://www.w3.org/Graphics, Graphics Activity}.
@item AI
This is the format used by Adobe Illustrator.  Files in this format may
be edited with Adobe Illustrator (@w{version 5}, and more recent
versions), or other applications.
@item PS
This is @code{idraw}-editable Postscript format.  Files in this format
may be sent to a Postscript printer, imported into another document, or
edited with the free @code{idraw} drawing editor.  See @ref{idraw}.
@item CGM
This is Computer Graphics Metafile format, which may be imported into an
application or displayed in any Web browser with a CGM plug-in.  @w{By
default}, a binary file in @w{version 3} CGM format that conforms to the
WebCGM profile is produced.  The @uref{http://www.cgmopen.org, CGM Open
Consortium} has more information on WebCGM, which is a standard for
Web-based vector graphics.
@item Fig
This is a vector graphics format that may be displayed or edited with
the free @code{xfig} drawing editor.  See @ref{xfig}.
@item PCL 5
This is a powerful version of Hewlett--Packard's Printer Control
Language.  Files in this format may be sent to a LaserJet printer or
compatible device (note that most inkjets do not support @w{PCL 5}).
@item HP-GL
This is Hewlett--Packard's Graphics Language.  By default, the modern
variant HP-GL/2 is produced.  Files in HP-GL or HP-GL/2 format may be
imported into a document or sent to a plotter.
@item ReGIS
This is the graphics format understood by several DEC terminals (VT340,
VT330, VT241, VT240) and emulators, including the DECwindows terminal
emulator, @code{dxterm}.
@item Tek
This is the graphics format understood by Tektronix 4014 terminals and
emulators, including the emulators built into the @code{xterm} terminal
emulator program and the MS-DOS version of @code{kermit}.
@item Metafile
This is device-independent GNU graphics metafile format.  The
@code{plot} program can translate it to any of the preceding formats.
@end table

Of the command-line graphics programs, the best known is @code{graph},
which is an application for plotting two-dimensional scientific data.
It reads one or more data files containing datasets, and outputs a plot.
The above output formats are supported.  The corresponding commands are
@code{graph @w{-T X}}, @code{graph -T png}, @code{graph -T pnm},
@code{graph -T gif}, @code{graph -T svg}, @code{graph -T ai},
@code{graph -T ps}, @code{graph -T cgm}, @code{graph -T fig},
@code{graph -T pcl}, @code{graph -T hpgl}, @code{graph -T regis},
@code{graph -T tek}, and @code{graph}.  @code{graph} without a @samp{-T}
option (referred to as `raw @code{graph}') produces output in GNU
metafile format.

@code{graph} can read datasets in both ASCII and binary format, and
datasets in the `table' format produced by the plotting program
@code{gnuplot}.  It produces a plot with or without axes and labels.
You may specify labels and ranges for the axes, and the size and
position of the plot on the display.  The labels may contain subscripts
and subscripts, Greek letters, and other special symbols; there is also
support for Cyrillic script (i.e., Russian) and Japanese.  You may
specify the type of marker symbol used for each dataset, and such
parameters as the style and thickness of the line @w{(if any)} used to
connect points in a dataset.  The plotting of filled regions is
supported, as is the drawing of error bars.  @code{graph} provides full
support for multiplotting.  With a single invocation of @code{graph},
you may produce a multiplot consisting of many plots, either side by
side or inset.  Each plot will have its own axes and data.

@code{graph @w{-T X}}, @code{graph -T tek}, @code{graph -T regis}, and
raw @code{graph} have a feature that most plotting programs do not have.
They can accept input from a pipe, and plot data points to the output in
real time.  For this to occur, the user must specify ranges for both
axes, so that @code{graph} does not need to wait until the end of the
input before determining them.

The @code{plot} program is a so-called plot filter.  It can translate
GNU graphics metafiles (produced @w{for example} by raw @code{graph})
into any supported output format.  The corresponding commands are
@code{plot @w{-T X}}, @code{plot -T png}, @code{plot -T pnm}, @code{plot
-T gif}, @code{plot -T svg}, @code{plot -T ai}, @code{plot -T ps},
@code{plot -T cgm}, @code{plot -T fig}, @code{plot -T pcl}, @code{plot
-T hpgl}, @code{plot -T regis}, @code{plot -T tek}, and @code{plot}.
The @code{plot} program is useful if you wish to produce output in
several different formats while invoking @code{graph} only once.  @w{It
is} also useful if you wish to translate files in the traditional
`plot(5)' format produced by, e.g., the non-GNU versions of @code{graph}
provided with some operating systems.  GNU metafile format is compatible
with plot(5) format.

The @code{pic2plot} program can translate from the pic language to any
supported output format.  The pic language, which was invented at Bell
Laboratories, is used for creating box-and-arrow diagrams of the kind
frequently found in technical papers and textbooks.  The corresponding
commands are @code{pic2plot @w{-T X}}, @code{pic2plot -T png},
@code{pic2plot -T pnm}, @code{pic2plot -T gif}, @code{pic2plot -T ai},
@code{pic2plot -T ps}, @code{pic2plot -T cgm}, @code{pic2plot -T fig},
@code{pic2plot -T pcl}, @code{pic2plot -T hpgl}, @code{pic2plot -T
regis}, @code{pic2plot -T tek}, and @code{pic2plot}.

The @code{tek2plot} program can translate from Tektronix format to any
supported output format.  The corresponding commands are @code{tek2plot
@w{-T X}}, @code{tek2plot -T png}, @code{tek2plot -T pnm},
@code{tek2plot -T gif}, @code{tek2plot -T svg}, @code{tek2plot -T ai},
@code{tek2plot -T ps}, @code{tek2plot -T cgm}, @code{tek2plot -T fig},
@code{tek2plot -T pcl}, @code{tek2plot -T hpgl}, @code{tek2plot -T
regis}, and @code{tek2plot}.  @code{tek2plot} is useful if you have an
older application that produces drawings in Tektronix format.

The @code{plotfont} program is a simple utility that displays a
character map for any font that is available to @code{graph},
@code{plot}, @code{pic2plot}, or @code{tek2plot}.  The 35 standard
Postscript fonts are available if the @samp{-T X}, @samp{-T ai},
@samp{-T ps}, @samp{-T cgm}, or @samp{-T fig} options are used.  The 45
standard @w{PCL 5} fonts (i.e., ``LaserJet'' fonts) are available if the
@samp{-T ai}, @samp{-T pcl} or @samp{-T hpgl} options are used.  In the
latter two cases (@samp{-T pcl} and @samp{-T hpgl}), @w{a number} of
Hewlett--Packard vector fonts are available @w{as well}.  @w{A set} of
22 Hershey vector fonts, including Cyrillic fonts and a Japanese font,
is always available.  When producing output for an @w{X Window System}
display, any of the graphics programs can use scalable @w{X fonts}.

Of the command-line mathematical programs, @code{spline} does spline
interpolation of scalar or vector-valued data.  It normally uses either
cubic spline interpolation or exponential splines in tension, but like
@code{graph} @w{it can} function as a real-time filter under some
circumstances.  Besides splining datasets, @w{it can} construct curves,
either open or closed, through arbitrarily chosen points in
@math{d}-dimensional space.  @code{ode} provides the ability to
integrate an ordinary differential equation or a system of ordinary
differential equations, when provided with an explicit expression for
each equation.  It supplements the plotting program @code{gnuplot},
which can plot functions but not integrate ordinary differential
equations.  The final command-line mathematical program, @code{double},
is a filter for converting, scaling and cutting binary or ASCII data
streams.  @w{It is} still under development and is not yet documented.

The GNU @code{libplot} function library, on which the command-line
graphics programs are based, is discussed @w{at length} elsewhere in
this documentation.  @w{It gives} C @w{and C++} programs the ability to
draw such objects as lines, open and closed polylines, arcs (both
circular and elliptic), quadratic and cubic Bezier curves, circles and
ellipses, points (i.e., pixels), marker symbols, and text strings.  The
filling of objects other than points, marker symbols, and text strings
is supported (fill color, @w{as well} as pen color, can be set
arbitrarily).  Text strings can be drawn in any of a large number of
fonts.  The 35 standard Postscript fonts are supported by the @w{X
Window} System, SVG, Illustrator, Postscript, CGM, and @code{xfig}
drivers, and the 45 standard @w{PCL 5} fonts are supported by the SVG,
Illustrator, @w{PCL 5} and HP-GL/2 drivers.  The latter two also support
a number of Hewlett--Packard vector fonts.  All drivers, including the
PNG, PNM, GIF, ReGIS, Tektronix and metafile drivers, support a set of
22 Hershey vector fonts.

The support for drawing text strings is extensive.  Text strings may
include subscripts and superscripts, and may include characters chosen
from more than one font in a typeface.  Many non-alphanumeric characters
may be included.  The entire collection of over 1700 `Hershey glyphs'
digitized by @w{Allen V.} Hershey at the U.S. Naval Surface Weapons
Center, which includes many curious symbols, is built into GNU
@code{libplot}.  Text strings in the so-called EUC-JP encoding (the
Extended Unix Code for Japanese) can be also be drawn.  Such strings may
include both syllabic Japanese characters (Hiragana and Katakana) and
ideographic Japanese characters (Kanji).  GNU @code{libplot} contains a
library of 603 Kanji, including 596 of the 2965 frequently used 
@w{Level 1} Kanji.

@node graph, plot, Plotutils Intro, Top
@chapter The @code{graph} Application

Each invocation of @code{graph} reads one or more datasets from files
named on the command line or from standard input, and prepares a plot.
There are many command-line options for adjusting the visual appearance
of the plot.  
@iftex
@xref{graph Invocation}, for documentation on all options.
@end iftex
The following sections explain how to use the most frequently used
options, by giving examples.

@menu
* Simple Examples::     Simple examples using graph
* Non-Square Plots::    Rotating and changing the aspect ratio of a plot
* Multiple Datasets::   Preparing a plot from more than one dataset
* Multiplotting::       Multiple plots on a single page
* Data Formats::        Reading binary and other data formats
* graph Invocation::    Command-line options
@end menu

@node Simple Examples, Non-Square Plots, graph, graph
@section Simple examples using @code{graph}

By default, @code{graph} reads ASCII data from the files specified on
the command line, or from standard input if no files are specified.  The
data are pairs of numbers, interpreted as the @math{x} @w{and @math{y}}
coordinates of data points.  An example would be:

@example
0.0  0.0
1.0  0.2
2.0  0.0
3.0  0.4
4.0  0.2
5.0  0.6
@end example

@noindent
Data points do not need to be on different lines, nor do the @math{x}
and @math{y} coordinates of a data point need to be on the same line.
However, there should be no blank lines in the input if it is to be
viewed as forming a single dataset.

To plot such a dataset with @code{graph}, you could do

@example
graph -T ps datafile > plot.ps
@end example

@noindent
or equivalently

@example
graph -T ps < datafile > plot.ps
@end example

@noindent
Either of these would produce an encapsulated Postscript file
@file{plot.ps}, which could be included in another document, displayed
on a screen, sent to a printer, or edited with the free @code{idraw}
drawing editor.  The @samp{--page-size} option, or equivalently the
@code{PAGESIZE} environment variable, specifies the size of the page on
which the plot will be positioned.  The default is "letter", i.e.,
8.5@dmn{in} by 11@dmn{in}, but "a4" or other ISO or ANSI page sizes
could equally well be specified.  See @ref{Page and Viewport Sizes}.

Similarly, you would do

@example
graph -T svg < datafile > plot.svg
graph -T cgm < datafile > plot.cgm
@end example

@noindent
to produce SVG and WebCGM files that could be displayed in a Web browser
with SVG and WebCGM support, or

@example
graph -T fig < datafile > plot.fig
@end example

@noindent
to produce a file @file{plot.fig} in Fig format that could be edited
with the free @code{xfig} drawing editor, or

@example
graph -T ai < datafile > plot.ai
@end example

@noindent
to produce a file @file{plot.ai} that could be edited with Adobe
Illustrator.  If you do

@example
graph -T hpgl < datafile > plot.plt
@end example

@noindent
you will produce a file @file{plot.plt} in the Hewlett--Packard Graphics
Language (HP-GL/2) that may be sent to a Hewlett--Packard plotter.
Similarly, you would use @code{graph -T pcl} to produce a file in @w{PCL
5} format that may be printed on a LaserJet or other laser printer.

You would use @code{graph @w{-T X}} to @w{pop up} a window on an @w{X
Window} System display, and display the plot @w{in it}.  For that, you
would do

@example
graph -T X < datafile
@end example

@noindent
If you use @code{graph @w{-T X}}, no output file will be produced: only
a window.  The window will vanish if you @w{type @samp{q}} or click your
mouse @w{in it}.

You may also use @code{graph -T png} to produce a PNG file, @code{graph
-T pnm} to produce a PNM file (a ``portable anymap''), and @code{graph
-T gif} to produce a pseudo-GIF file.  If the free image display
application @code{xv} is available on your system, you could use any
of the three commands

@example
graph -T png < datafile | xv -
graph -T pnm < datafile | xv -
graph -T gif < datafile | xv -
@end example

@noindent
to view the output file.

Another thing you can do is use @code{graph -T tek} to display a plot on
a device that can emulate a Tektronix 4014 graphics terminal.
@code{xterm}, the @w{X Window} System terminal emulator, can do this.
Within an @code{xterm} window, you would type

@example
graph -T tek < datafile
@end example

@noindent
@code{xterm} normally emulates a VT100 terminal, but when this command
is issued from @w{within it}, @w{it will} @w{pop up} a second window
(@w{a `Tektronix} window') and draw the plot @w{in it}.  The Japanese
terminal emulator @code{kterm} should be able to do the same, provided
that it is correctly installed.  Another piece of software that can
emulate a Tektronix 4014 terminal is the MS-DOS version of @code{kermit}.

In the same way, you would use @code{graph -T regis} to display a plot
on any graphics terminal or emulator that supports ReGIS graphics.
@code{dxterm}, the DECwindows terminal emulator, can do this.  Several
DEC terminals (in particular the VT340, VT330, VT241, and VT240
terminals) also support ReGIS graphics.

@code{graph} may behave differently depending on the environment in
which it is invoked.  We have already mentioned the @code{PAGESIZE}
environment variable, which affects the operation of @code{graph -T
svg}, @code{graph -T ai}, @code{graph -T ps}, @code{graph -T cgm},
@code{graph -T fig}, @code{graph -T pcl}, and @code{graph -T hpgl}.
Similarly, the @code{BITMAPSIZE} environment variable affects the
operation of @code{graph @w{-T X}}, @code{graph -T png}, @code{graph -T
pnm}, and @code{graph -T gif}.  The @code{DISPLAY} environment variable
affects the operation of @code{graph @w{-T X}}, and the @code{TERM}
environment variable affects the operation of @code{graph -T tek}.
There are also several environment variables that affect the operation
of @code{graph -T pcl} and @code{graph -T hpgl}.  For a complete
discussion of the effects of the environment on @code{graph}, see
@ref{graph Environment}.  The following remarks apply irrespective of
which output format is specified.

By default, successive points in the dataset are joined by solid line
segments, which form a polygonal line or polyline that we call simply a
`line'.  You may choose the style of line (the `linemode') with the
@samp{-m} option:

@example
graph -T ps -m 2 < datafile > plot.ps
@end example

@noindent
Here @samp{-m 2} indicates that linemode #2 should be used.  @w{If the}
dataset is rendered in monochrome, which is the default, the line can be
drawn in one of five distinct styles.  Linemodes #1 through #5 signify
solid, dotted, dotdashed, shortdashed, and longdashed; thereafter the
sequence repeats.  @w{If the} @samp{-C} option is used, the dataset will
be rendered in color.  For colored datasets, the line can be drawn in
one of 25 distinct styles.  Linemodes #1 through #5 signify red, green,
blue, magenta, and cyan; all are solid.  Linemodes #6 through #10
signify the same five colors, but dotted rather than solid.  Linemodes
#11 through #16 signify the same five colors, but dotdashed, and so
forth.  After linemode #25, the sequence repeats.  Linemode #0,
irrespective of whether the rendering is in monochrome or color, means
that the line is not drawn.

You may wish to @emph{fill} the polygon bounded by the line (i.e.,
@w{shade it}, or fill it with a solid color).  For this, you would use
the @samp{-q} option.  @w{For example},

@example
echo .1 .1 .1 .9 .9 .9 .9 .1 .1 .1 | 
    graph -T ps -C -m 1 -q 0.3 > plot.ps
@end example

@noindent
will plot a square region with vertices (0.1,0.1), (0.1,0.9), (0.9,0.9),
and (0.9,0.1).  The repetition of the first vertex (0.1,0.1) at the end
of the sequence of vertices ensures that the square will be closed: all
four segments of its boundary will be drawn.  The square will be drawn
in red, since the colored version of linemode #1 is requested.  The
interior of the square will be filled with red to an intensity @w{of
30%}, as the @samp{-q 0.3} option specifies.  @w{If the} intensity
@w{were 1.0}, the region would be filled with solid color, and if it
@w{were 0.0}, the region would be filled with white.  @w{If the}
intensity were negative, the region would be unfilled, or transparent
(the default).

You may specify the thickness (`width') of the line, whether it is
filled or not, by using the @samp{-W} option.  @w{For example}, @samp{-W
0.01} specifies that the line should have a thickness equal to 0.01
times the size of the graphics display.  Also, you may put symbols at
each data point along the line by doing, @w{for example},

@example
graph -T ps -S 3 0.1 < datafile > plot.ps
@end example

@noindent
where the first argument 3 indicates which symbol to plot.  The optional
second argument 0.1 specifies the symbol size as a fraction of the size
of the `plotting box': the square within which the plot is drawn.
Symbol #1 is a dot, symbol #2 is a plus sign, symbol #3 is an asterisk,
symbol #4 is a circle, symbol #5 is a cross, and so forth.
(@xref{Marker Symbols}.)  Symbols 1 through 31 are the same for all
display types, and the color of a symbol will be the same as the color
of the line it is plotted along.

Actually, you would probably not want to plot symbols at each point in
the dataset unless you turn off the line joining the points.  For this
purpose, the `negative linemode' concept is useful.  @w{A line} whose
linemode is negative is not visible; however, any symbols plotted along
it will have the color associated with the corresponding positive
linemode.  So, @w{for example},

@example
graph -T ps -C -m -3 -S 4 < datafile > plot.ps
@end example

@noindent
will plot a blue circle at each data point.  The circles will not be
joined by line segments.  By adding the optional second argument to the
@samp{-S} option, you may adjust the size of the circles.

@code{graph} will automatically generate abscissa (@w{i.e., @math{x}})
values for you if you use the @samp{-a} option.  @w{If this} option is
used, no abscissa values should be given in the data file.  The data
points will be taken to be regularly spaced along the abscissa.  The two
arguments following @samp{-a} on the command line will be taken as the
sampling interval and the abscissa value of the first data point.  @w{If
they} are absent, they default to 1.0 and 0.0 respectively.  For
example, the command

@example
echo 0 1 0 | graph -T ps -a > plot.ps
@end example

@noindent
produces exactly the same plot  as

@example
echo 0 0 1 1 2 0 | graph -T ps > plot.ps
@end example

If the @samp{-I e} option is specified, @code{graph} will plot data with
error bars.  In this case the dataset should consist of triples
(@math{x},@math{y},@i{error}), rather than pairs @math{(x,y)}.  @w{A
vertical} error bar of the appropriate length will be plotted at each
data point.  You would plot a symbol at each data point, along with the
error bar, by using the @samp{-S} option in the usual way.  The symbol
will be the same for each point in the dataset.  You may use the
@samp{-a} option in conjunction with @samp{-I e}, if you wish.  @w{If
you} do, the dataset should contain no abscissa (@w{i.e., @math{x}})
values.

By default, the limits on the @math{x} and @math{y} axes, and the
spacing between the labeled ticks on each axis, are computed
automatically.  You may wish to set them manually.  You would accomplish
this with the @samp{-x} and @samp{-y} options.

@example
echo 0 0 1 1 2 0 | graph -T ps -x -1 3 -y -1 2 > plot.ps
@end example

@noindent
will produce a plot in which the @math{x} axis extends from @minus{}1
@w{to 3}, and the @math{y} axis from @minus{}1 @w{to 2}.  By default,
@code{graph} tries to place about six numbered ticks on each axis.  By
including an optional third argument to @samp{-x} or @samp{-y}, you may
manually set the spacing of the labeled ticks.  @w{For example}, using
@samp{-y -1 2 1} rather than @samp{-y -1 2} will produce a @w{@math{y}
axis} with labeled ticks at @minus{}1, 0, 1, @w{and 2}, rather than at
the locations that @code{graph} would choose by default, which would be
@minus{}1, @minus{}0.5, 0, 0.5, 1, 1.5, @w{and 2}.  @w{In general}, if a
third argument is present then labeled ticks will be placed at each of
its integer multiples.

To make an axis logarithmic, you would use the @samp{-l} option.  For
example,

@example
echo 1 1 2 3 3 1 | graph -T ps -l x > plot.ps
@end example

@noindent
will produce a plot in which the @math{x} axis is logarithmic, but the
@math{y} axis is linear.  To make both axes logarithmic, you would use
@samp{-l x -l y}.  By default, the upper and lower limits on a
logarithmic axis are powers of ten, and there are tick marks at each
power of ten and at its integer multiples.  The tick marks at the powers
of ten are labeled.  @w{If the} axis spans more than five orders of
magnitude, the tick marks at the integer multiples are omitted.

If you have an unusually short logarithmic axis, you may need to
increase the number of labeled ticks.  To do this, you should specify a
tick spacing manually.  @w{For example}, @samp{-l x -x 1 9 2} would
produce a plot in which the @w{@math{x} axis} is logarithmic and extends
from 1 @w{to 9}.  Labeled ticks would be located at each integer
multiple @w{of 2}, i.e., at 2, 4, 6, @w{and 8}.

You would label the @math{x} and @math{y} axes with the @samp{-X} and
@samp{-Y} options, respectively.  For example,

@example
echo 1 1 2 3 3 1 | graph -T ps -l x -X "A Logarithmic Axis" > plot.ps
@end example

@noindent
will label the log axis in the preceding example.  By default, the label
for the @math{y} axis (@w{if any}) will be rotated 90 degrees, unless
you use the @samp{--toggle-rotate-y-label} option.  You may specify a
`top label', or title for the plot, by using the @samp{-L} option.
Doing, @w{for example},

@example
echo 1 1 2 3 3 1 | graph -T ps -l x -L "A Simple Example" > plot.ps
@end example

@noindent
will produce a plot with a title on top.  

The font size of the @math{x} axis and @math{y} axis labels may be
specified with the @samp{-f} option, and the font size of the title with
the @samp{--title-font-size} option.  For example,

@example
echo 1 1 2 3 3 1 | graph -T ps -X "Abscissa" -f 0.1 > plot.ps
@end example

@noindent
will produce a plot in which the font size of the @math{x} axis label,
and each of the numerical tick labels, is very large (0.1 times the size
of the plotting box, i.e., the square within which the plot is drawn).

The font in which the labels specified with the @samp{-X}, @samp{-Y},
and @samp{-L} options are drawn can be specified with the @samp{-F}
option.  For example, @samp{-F Times-Roman} will make the labels appear
in Times-Roman instead of the default font (which is Helvetica, unless
@samp{-T png}, @samp{-T pnm}, @samp{-T gif}, @samp{-T pcl}, @samp{-T
hpgl}, @samp{-T regis}, or @samp{-T tek} is specified).  Font names are
case-insensitive, so @samp{-F times-roman} will work equally well.  The
available fonts include 35 Postscript fonts (for all variants of
@code{graph} other than @code{graph -T png}, @code{graph -T pnm},
@code{graph -T gif}, @code{graph -T pcl}, @code{graph -T hpgl},
@code{graph -T regis}, and @code{graph -T tek}), 45 @w{PCL 5} fonts (for
@code{graph -T svg}, @code{graph -T ai}, @code{graph -T pcl} and
@code{graph -T hpgl}), a number of Hewlett--Packard vector fonts (for
@code{graph -T pcl} and @code{graph -T hpgl}), and 22 Hershey vector
fonts.  The Hershey fonts include HersheyCyrillic, for Russian, and
HersheyEUC, for Japanese.  For a discussion of the available fonts, see
@ref{Text Fonts}.  The @code{plotfont} utility will produce a character
map of any available font.  @xref{plotfont}.

The format of the labels drawn with the @samp{-X}, @samp{-Y}, and
@samp{-L} options may be quite intricate.  Subscripts, superscripts,
square roots, and switching fonts within a typeface are all allowed.
The above examples do not illustrate this, but for details, see
@ref{Text String Format}.

Each of the preceding examples produces a plot containing the default
sort of grid (a square plotting box, with ticks and labels drawn along
its lower edge and its left edge).  There are actually several sorts of
grid you may request.  The @samp{@w{-g 0}}, @samp{@w{-g 1}}, @samp{@w{-g
2}}, and @samp{@w{-g 3}} options yield successively fancier grids.  What
they yield, respectively, is @w{no grid} @w{at all}, @w{a pair} of axes
with ticks and labels, a square plotting box with ticks and labels, and
a square plotting box with ticks, labels, and grid lines.  As you can
check, @samp{@w{-g 2}} is the default.  There is also a @samp{@w{-g 4}}
option, which yields a slightly different sort of grid: @w{a pair} of
axes that cross at the origin.  This last sort of grid is useful when
the @math{x} @w{or @math{y}} coordinates of the data points you are
plotting are both positive and negative.

@node Non-Square Plots, Multiple Datasets, Simple Examples, graph
@section Non-square, displaced, and rotated plots

To alter the linear dimensions of the plotting box, and also to position
it in a different part of the graphics display, you could do something
like

@example
graph -T ps -h .3 -w .6 -r .1 -u .1 < datafile > plot.ps
@end example

@noindent
Here the @samp{-h} and @samp{-w} options specify the height and width of
the plotting box, and the @samp{-r} and @samp{-u} options indicate how
far up and to the right the lower left corner of the plotting box should
be positioned.  All dimensions are expressed as fractions of the size of
the graphics display.  @w{By default}, the height and width of the
plotting box equal 0.6, and the `upward shift' and the `rightward shift'
@w{equal 0.2}.  @w{So the} above example will produce a plot that is
half as tall as usual.  Compared to its usual position, the plot will be
shifted slightly downward and to the left.

Several command-line options specify sizes or dimensions as fractions of
the size of the plotting box.  For example, @samp{-S 3 .01} specifies
that the marker symbols for the following dataset should be of @w{type
#3}, and should have a font size equal @w{to 0.01}, i.e., 0.01 times the
minimum dimension (height or width) of the plotting box.  If the
@samp{-h} or @samp{-w} options are employed to expand or contract the
plot, such sizes or dimensions will scale in tandem.  That is presumably
the right thing @w{to do}.

To rotate your plot by 90 degrees counterclockwise, you would add
@samp{--rotation 90} to the @code{graph} command line.  You may also
specify @samp{--rotation 180}, to produce an upside-down plot, or
@samp{--rotation 270}.  The @samp{--rotation} option may be combined
with the @samp{-h}, @samp{-w}, @samp{-r}, and @samp{-u} options.  If
they appear together, the @samp{--rotation} option takes effect first.
That is because @samp{--rotation} specifies the rotation angle of the
graphics display, while the other options specify how the plotting box
should be positioned within the graphics display.  The two sorts of
positioning are logically distinct.

The graphics display (sometimes called the `viewport') is an
abstraction.  For @code{graph @w{-T X}}, it is a popped-up window on an
@w{X display}.  For @code{graph -T pnm} and @code{graph -T gif}, it is a
square or rectangular bitmap.  In these three cases, the size of the
graphics display can be set by using the @samp{--bitmap-size} option, or
by setting the @code{BITMAPSIZE} environment variable.  For @code{graph
-T tek}, the graphics display is a square region occupying the central
part of a Tektronix display.  (Tektronix displays are 4/3 times as wide
as they are high.)  For @code{graph -T regis}, it is a square region
occupying the central part of a ReGIS display.  For @code{graph -T ai},
@code{graph -T ps}, @code{graph -T pcl}, and @code{graph -T fig}, @w{by
default} it is a 8-inch square centered on an 8.5@dmn{in} by 11@dmn{in}
page (@w{US letter} size).  For @code{graph -T hpgl}, it is an 8-inch
square, which by default is not centered.  For @code{graph -T svg} and
@code{graph -T cgm}, the default graphics display is an 8-inch square,
though if the output file is placed on a Web page, it may be scaled
arbitrarily.

The page size, which determines the default display size used by
@code{graph -T svg}, @code{graph -T ai}, @code{graph -T ps}, @code{graph
-T cgm}, @code{graph -T fig}, @code{graph -T pcl}, and @code{graph -T
hpgl}, can be set by using the @samp{--page-size} option, or by setting
the environment variable @code{PAGESIZE}@.  @w{For example}, setting the
page size to "a4" would produce output for an A4-size page (21@dmn{cm}
by 29.7@dmn{cm}), and would select a appropriate graphics display size.
Either or both of the dimensions of the graphics display can be
specified explicitly.  For example, the page size could be specified as
"letter,xsize=4in", or "a4,xsize=10cm,ysize=15cm".  The dimensions of
the graphics display are allowed to be negative (@w{a negative}
dimension results in a reflection).

The position of the display on the page, relative to its default
position, may optionally be adjusted by specifying an offset vector.
For example, the page size could be specified as "letter,yoffset=1.2in",
or "a4,xoffset=@minus{}5mm,yoffset=2.0cm".  @w{It is} also possible to
position the graphics display precisely, by specifying the location of
its lower left corner relative to the lower left corner of the page.
For example, the page size could be specified as
"letter,xorigin=2in,yorigin=3in", or "a4,xorigin=0.5cm,yorigin=0.5cm".

The preceding options may be intermingled.  However, @code{graph -T svg}
and @code{graph -T cgm} ignore the "xoffset", "yoffset", "xorigin", and
"yorigin" options, since SVG format and WebCGM format have no notion of
the Web page on which the graphics display will ultimately be
positioned.  They interpret the "xsize" and "ysize" options as
specifying a default size for the graphics display (@w{it is} merely a
default, since the output file may be scaled arbitrarily when it is
placed on a Web page).

For more information on page and graphics display sizes, see @ref{Page
and Viewport Sizes}.

@node Multiple Datasets, Multiplotting, Non-Square Plots, graph
@section Preparing a plot from more than one dataset

It is frequently the case that several datasets need to be displayed on
the same plot.  @w{If so}, you may wish to distinguish the points in
different datasets by joining them by lines of different types, or by
using marker symbols of different types.

A more complicated example would be the following.  You may have a file
containing a dataset that is the result of experimental observations,
and a file containing closely spaced points that trace out a theoretical
curve.  The second file is a dataset in its own right.  You would
presumably plot it with line segments joining successive data points, so
as to trace out the theoretical curve.  But the first dataset, resulting
from experiment, would be plotted without such line segments.  @w{In
fact}, a marker symbol would be plotted at each of its points.

These examples, and others like them, led us to define a set of seven
@emph{attributes} that define the way a dataset should be plotted.
These attributes, which can be set by command-line options, are the
following.

@enumerate
@item color/monochrome
@item linemode 
@item linewidth
@item symbol type
@item symbol size
@item symbol font name
@item fill fraction
@end enumerate

@noindent
Color/monochrome (a choice of one or the other) is the simplest.  The
choice is toggled with the @samp{-C} option.  The `linemode' (i.e., line
style) specifies how the line segments joining successive points should
be drawn; it is specified with the @samp{-m} option.  Linemode #0 means
no linemode @w{at all}, @w{for example}.  `Linewidth' means line
thickness; @w{it is} specified with the @samp{-W} option. `Symbol type'
and `symbol size', which are specified with the @samp{-S} option,
specify the symbol plotted at each point of the dataset.  `Symbol font
name' refers to the font from which marker symbols #32 and above, which
are taken to be characters rather than geometric symbols, are selected.
@w{It is} set with the @samp{--symbol-font-name} option, and is relevant
only if @samp{-S} is used to request such special marker symbols.
Finally, the polygonal line joining the points in a dataset may be
@emph{filled}, to create a filled or shaded polygon.  The `fill
fraction' is set with the @samp{-q} option.  @w{A negative} fill
fraction means no fill, or transparent; zero means white, and 1.0 means
solid, or fully colored.

The preceding seven attributes refer to the way in which datasets are
plotted.  Datasets may also differ from one another in the way in which
they are read from files.  The dataset(s) in a file may or may not
contain error bars, @w{for example}.  @w{If a} file contains data with
error bars, the @samp{-I e} option should occur on the command line
before the file name.  (The @samp{-I} option specifies the input format
for the following files.)

The following illustrates how datasets in three different input files
could be plotted simultaneously.

@example
graph -T ps -m 0 -S 3 file1 -C -m 3 file2 -C -W 0.02 file3 > output.ps
@end example

@noindent
The dataset in @code{file1} will be plotted in linemode #0, so
successive points will not be joined by lines.  But symbol #3 (an
asterisk) will be plotted at each point.  The dataset in @code{file2}
will be plotted in color, and linemode #3 will be used.  In color
plotting, linemode #3 is interpreted as a solid blue line.  The second
@samp{-C} on the command line turns off color for @code{file3}.  The
points in the third dataset will be joined by a black line with
thickness 0.02, as a fraction of the size (i.e., minimum dimension) of
the graphics display.

The above command line could be made even more complicated by specifying
additional options (e.g., @samp{-q} or @samp{-I}) before each file.
@w{In fact} the command line could also include such standard options as
@samp{-x} or @samp{-y}, which specify the range of each axis.  Such
options, which refer to the plot as a whole rather than to individual
datasets, should appear before the first file name.  @w{For example},
you could do

@example
graph -T ps -x 0 1 0.5 -m 0 -S 3 file1 -C -m 3 file2 > output.ps
@end example

@noindent
Note that it is possible to include the special file @w{name @samp{-}},
which refers to standard input, on the command line.  So you may pipe
the output of another program into @code{graph}.  You may even generate
a plot @w{in part} from piped output, and @w{in part} from files.

Each input file may include more than one dataset.  If so, the command
line options preceding a file on the command line will take effect for
all datasets in that file.  There are two exceptions to this.  @w{By
default}, the linemode is incremented (`bumped') from one dataset to the
next.  This feature is usually quite convenient.  @w{For example}, if
you do

@example
graph -T ps -m 3 file1 > output.ps
@end example

@noindent
the first dataset in @code{file1} will appear in linemode #3, the second
in linemode #4, etc.  @w{In fact}, if you do

@example
graph -T ps file1 file2 @dots{} > output.ps
@end example

@noindent
without specifying linemode explicitly, the successive datasets read
from the files on the command line will appear in linemode #1, linemode
#2,@: @dots{}.  @w{If you} do not like this feature, you may turn it
off, or in general @w{toggle it}, by using the @samp{-B} option.

You may also control manually the linemode and symbol type used for the
datasets within any file.  You would do this by including directives in
the file itself, rather than on the command line.  For example, if the
line

@example
#m=-5,S=10
@end example

@noindent
appeared in an ASCII-format input file, it would be interpreted as a
directive to switch to linemode #@minus{}5 and symbol type #10 for the
following dataset.  Future releases of @code{graph} may provide the
ability to set each of the seven dataset attributes in this way.

@node Multiplotting, Data Formats, Multiple Datasets, graph
@section Multiplotting: placing multiple plots on a single page

It is occasionally useful to display several plots at once on a single
page, or on a single graphics display.  We call such a composite plot a
@emph{multiplot}.  One common sort of multiplot is a small plot inset
into a larger one.  Another sort is two or more plots side by side.

@code{graph} can draw multiplots consisting of an arbitrarily large
number of plots.  When multiplotting, @code{graph} draws each plot in
its own `virtual display'.  When an ordinary plot is drawn, the virtual
display is the same as the physical display.  But when a plot of a
multiplot is drawn, the virtual display may be any smaller square
region.  The following two-plot example illustrates the idea.

@example
graph -T X datafile1 --reposition .35 .35 .3 datafile2
@end example

@noindent
Here @code{datafile1} is plotted in the usual way.  The
@samp{--reposition} option, which serves as a separator between plots,
specifies that the second plot will be drawn in a virtual display.  For
the purposes of the @samp{--reposition} option, the physical display is
a square with lower left corner (0.0,0.0) and upper right corner
(1.0,1.0).  @w{In those} coordinates the virtual display will be a
square of size 0.3, with lower left corner (0.35,0.35).  @w{So the}
second plot will be inset into the first.

Just as the @samp{-w}, @samp{-h}, @samp{-r}, and @samp{-u} options may
be used to set the size and position of a plotting box within the
physical display, so they may be used to set the size and position of a
plotting box within a virtual display.  For example,

@example
graph -T X datafile1 --reposition .35 .35 .3 -w .4 -r .3 datafile2
@end example

@noindent
will yield a two-plot multiplot in which the second plot is
significantly different.  Its plotting box will have a width only 0.4
times the width of the virtual display.  However, the plotting box will
be centered within the virtual display, since the distance between the
left edge of the plotting box and the left edge of the virtual display
will be @w{0.3 times} the width of the virtual display.

By convention, before each plot of a multiplot other than the first is
drawn, a `blankout region' surrounding its plotting box is erased.
(@w{That is}, @w{it is} filled with white, or whatever the background
@w{color is}.)  This erasure prevents the plots from overlapping and
producing a messy result.  @w{By default}, the blankout region is a
rectangular region 30% larger in each dimension than the plotting box
for the plot.  That is appropriate if the plot is a small one that is
inset into the first plot.  @w{It may} not be appropriate, however,
@w{if you} are preparing a multiplot in which several plots appear side
by side.  You may use the @samp{--blankout} option to adjust this
parameter.  @w{For example}, specifying @samp{--blankout 1.0} will make
the blankout region for a plot coincide with its plotting box.
Specifying @samp{--blankout 0.0} will prevent any blanking out from
occurring.  The blankout parameter may be set more than once, @w{so as}
to differ from plot to plot.

It should be emphasized that every plot in a multiplot is a plot in its
own right.  All the usual options (@samp{-m}, @samp{-S}, @samp{-x},
@samp{-y}, etc.) can be applied to each plot separately.  The options
for a plot should occur on the @code{graph} command line immediately
after the @samp{--reposition} option that applies to it.  Each plot may
be prepared from more than a single dataset, also.  The names of the
data files for each plot should occur on the command line before the
following @samp{--reposition} option, @w{if any}.  

@node Data Formats, graph Invocation, Multiplotting, graph
@section Reading binary and other data formats

By default, @code{graph} reads datasets in ASCII format.  But it can
also read datasets in any of three binary formats (single precision
floating point, double precision floating point, and integer).
These three input formats are specified by the @samp{-I d}, @samp{-I f},
and @samp{-I i} options, respectively.

There are two advantages to using binary data: @w{1) @code{graph}} runs
significantly faster because the computational overhead for converting
data from ASCII to binary is eliminated, and @w{2) the} input files may
be significantly smaller.  @w{If you} have very large datasets, using
binary format may reduce storage and runtime costs.

For example, you may create a single precision binary dataset as output
from a C language program:

@example
@group
#include <stdio.h>
void write_point (float x, float y)
@{
  fwrite(&x, sizeof (float), 1, stdout);
  fwrite(&y, sizeof (float), 1, stdout);
@}
@end group
@end example

@noindent
You may plot data written this way by doing:

@example
graph -T ps -I f < binary_datafile > plot.ps
@end example

@ifnottex
@noindent
The inclusion of multiple datasets within a single binary file is
supported.  If a binary file contains more than a single dataset,
successive datasets should be separated by a single occurrence of the
the largest possible number.  For single precision datasets this is the
quantity @code{FLT_MAX}, for double precision datasets it is the
quantity @code{DBL_MAX}, and for integer datasets it is the quantity
@code{INT_MAX}@.  @w{On most} machines @code{FLT_MAX} is approximately
3.4x10^38, @code{DBL_MAX} is approximately 1.8x10^308, and
@code{INT_MAX} is 2^32-1.
@end ifnottex
@tex
@noindent
The inclusion of multiple datasets within a single binary file is
supported.  If a binary file contains more than a single dataset,
successive datasets should be separated by a single occurrence of the
the largest possible number.  For single precision datasets this is the
quantity @code{FLT_MAX}, for double precision datasets it is the
quantity @code{DBL_MAX}, and for integer datasets it is the quantity
@code{INT_MAX}.  @w{On most} machines @code{FLT_MAX} is approximately
$3.4\times10^{38}$, @code{DBL_MAX} is approximately $1.8\times10^{308}$,
and @code{INT_MAX} is $2^{31}-1$.
@end tex

If you are reading datasets from more than one file, it is not required
that the files be in the same format.  For example,

@example
graph -T ps -I f binary_datafile -I a ascii_datafile > plot.ps
@end example

@noindent
will read @code{binary_datafile} in @samp{f} (binary single precision)
format, and @code{datafile} in @samp{a} (normal ASCII) format.

There is currently no support for reading and plotting binary data with
error bars.  If you have data with error bars, you should supply the data
to @code{graph} in ASCII, and use the @samp{-I e} option.

@code{graph} can also read data files in the ASCII `table' format
produced by the @code{gnuplot} plotting program.  For this, you should
use the @samp{-I g} option.  Such a data file may consist of more than
one dataset.

To sum up: there are six supported data formats, @samp{a} (normal
ASCII), @samp{e} (ASCII with error bars), @samp{g} (the ASCII `table'
format produced by @code{gnuplot}), @samp{f} (binary single precision),
@samp{d} (binary double precision), and @samp{i} (binary integer).
Input files may be in any of these six formats.

@node graph Invocation, , Data Formats, graph
@section @code{graph} command-line options

The @code{graph} program reads one or more datasets from files named on
the command line or from standard input, and prepares a plot.  The
output format or display type is specified with the @samp{-T} option.

By default, @code{graph} reads ASCII data from the files specified on
the command line.  The data are pairs of numbers, interpreted as the
@math{x} @w{and @math{y}} coordinates of data points.  If no files are
specified, or the file @w{name @samp{-}} is specified, the standard
input is read.  An output file is written to standard output, unless the
@samp{-T X} option is specified.  @w{In that} case the graph is
displayed in a popped-up window on an @w{X Window} System display, and
there is no output file.

There are many command-line options for adjusting the visual appearance
of the plot.  The relative order of file names and command-line options
is important.  Only the options that precede a file name on the command
line take effect for that file.

The following sections list the possible options.  Each option that
takes an argument is followed, in parentheses, by the type and default
value of the argument.  There are five sorts of option.

@iftex
@enumerate
@item
Options affecting an entire plot.  (@xref{Plot Options}.)

@item
Options affecting the reading and drawing of individual datasets within a plot.
(@xref{Dataset Options}.)

@item
Options for multiplotting (drawing several plots at once).
(@xref{Multiplot Options}.)

@item
Options relevant only to raw @code{graph}, i.e., relevant only if no
display type or output format is specified with the @samp{-T} option.
(@xref{Raw graph Options}.)

@item
Options requesting information (e.g., @samp{--help}).
(@xref{Info Options}.)
@end enumerate
@end iftex

@ifnottex
The behavior of @code{graph} is also affected by a number of environment
variables, so there is a section discussing them as well.
@end ifnottex

@menu
* Plot Options::        Options affecting an entire plot
* Dataset Options::     Options affecting the reading and plotting of datasets
* Multiplot Options::   Options for drawing several plots at once
* Raw graph Options::   Options relevant only to raw graph
* Info Options::        Options requesting information (e.g., ---help)
* graph Environment::   Environment variables
@end menu

@node Plot Options, Dataset Options, graph Invocation, graph Invocation
@subsection Plot options

The following options affect an entire plot.  They should normally occur
at most once, and should appear on the command line before the first
file name.  @w{If a} multiplot is being drawn, they may (with the
exception of the @samp{-T} option) occur more than once.  @w{If so}, the
second and later occurrences should be placed on the command line
immediately after each @samp{--reposition @var{x} @var{y}} option, which
separates the plots in a multiplot.

@table @samp
@item -T @var{type}
@itemx --display-type @var{type}
(String, default "meta".)  Select a display type or output format of
type @var{type}, which may be one of the strings "X", "png", "pnm",
"gif", "svg", "ai", "ps", "cgm", "fig", "pcl", "hpgl", "regis", "tek",
and "meta".  These refer respectively to the @w{X Window System}, PNG
format, portable anymap (PBM/PGM/PPM) format, pseudo-GIF format, the new
XML-based Scalable Vector Graphics format, the format used by Adobe
Illustrator, @code{idraw}-editable Postscript, the WebCGM format for
Web-based vector graphics, the format used by the @code{xfig} drawing
editor, the Hewlett--Packard @w{PCL 5} printer language, the
Hewlett--Packard Graphics Language (@w{by default}, HP-GL/2), the ReGIS
(remote graphics instruction set) format developed @w{by DEC}, Tektronix
format, and device-independent GNU graphics metafile format.

@item -E @var{x|y}
@itemx --toggle-axis-end @var{x|y}
Set the position of the indicated axis to be on the other end of the
plotting box from what is currently the case.  E.g., @samp{-E y} will
cause the @math{y} axis to appear on the right of the plot rather than
the left, which is the default.  Similarly, @samp{-E x} will cause the
@w{@math{x} axis} to appear at the top of the plot rather than the
bottom.  Note that if the @w{@math{x} axis} appears at the top, @w{no
plot} title will be drawn, since there will be no room.

@item -f @var{size}
@itemx --font-size @var{size}
(Float, default 0.0525.)  Set the size of the font used for the axis and
tick labels to be @var{size}.  The size is specified as a fraction of
the minimum dimension (width or height) of the plotting box.

@item -F @var{font_name}
@itemx --font-name @var{font_name}
(String, default "Helvetica" except for @code{graph -T pcl}, for which
"Univers" is the default, and @code{graph -T png}, @code{graph -T pnm},
@code{graph -T gif}, @code{graph -T hpgl}, @code{graph -T regis},
@code{graph -T tek}, and raw @code{graph}, for all of which
"HersheySerif" is the default.)  Set the font used for the axis and tick
labels, and for the plot title @w{(if any)}, to be @var{font_name}.  The
choice of font for the plot title may be overridden with the
@samp{--title-font-name} option (see below).  Font names are
case-insensitive.  @w{If the} specified font is not available, the
default font will be used.  Which fonts are available depends on which
@samp{-T} option is used.  For a list of all fonts, see @ref{Text
Fonts}.  The @code{plotfont} utility will produce a character map of any
available font.  @xref{plotfont}.

@item -g @var{grid_style}
@itemx --grid-style @var{grid_style}
(Integer in the range 0@dots{}4, default 2.)  Set the grid style for the
plot to be @var{grid_style}.  Grid styles 0 @w{through 3} are
progressively more fancy, but @w{style 4} is a somewhat different style.

@enumerate 0
@item no axes, tick marks or labels.
@item a pair of axes, with tick marks and labels.
@item box around plot, with tick marks and labels.
@item box around plot, with tick marks and labels; also grid lines.
@item axes intersect at the origin, with tick marks and labels.
@end enumerate

@item -h @var{height}
@itemx --height-of-plot @var{height}
(Float, default 0.6.)  Set the fractional height of the plot with
respect to the height of the display (or virtual display, in the case of
a multiplot) to be @var{height}.  @w{A value} of 1.0 will produce a
plotting box that fills the entire available area.  Since labels and
tick marks may be placed outside the plotting box, values considerably
less than 1.0 are normally chosen.

@item -H
@itemx --toggle-frame-on-top
Toggle whether or not a copy of the plot frame should be drawn on top of
the plot, @w{as well} as @w{beneath it}.  This option is useful when the
plotted dataset(s) project slightly beyond the frame, which can happen
if a large line thickness or symbol size is specified.

@item -k @var{length}
@itemx --tick-size @var{length}
(Float, default .02.)  Set the length of the tick marks on each axis to
be @var{length}.  @w{A value} of 1.0 produces tick marks whose length is
equal to the minimum dimension (width or height) of the plotting box.
@w{A negative} @var{length} yields tick marks that extend outside the
box, rather than inside.

@item -K @var{clip_mode}
@itemx --clip-mode @var{clip_mode}
(Integer, default 1.)  Set the clip mode for the plot to
@var{clip_mode}.  The clip mode is relevant only if data points are
being joined by a line, and the line is not being filled to create a
filled region (since filled regions are clipped in a fixed way).  

There are three clip modes: 0, 1, @w{and 2}.  They have the same meaning
as in the @code{gnuplot} plotting program.  Clip @w{mode 0} means that a
line segment joining two data points will be plotted only if neither
point is outside the plotting box.  Clip @w{mode 1} means that it will
be plotted if no more than one of the two points is outside, and clip
@w{mode 2} means that it will be plotted even if both are outside.
@w{In all} three clip modes the line segment will be clipped to the
plotting box.

@item -l @var{x|y}
@itemx --toggle-log-axis @var{x|y}
Set the specified axis to be a log axis rather than a linear axis, or
vice versa.  By default, both axes are linear axes.

@item -L @var{top_label}
@itemx --top-label @var{top_label}
(String, default empty.)  Place the text string @var{top_label} above
the plot, as its `top label', i.e., title.  The string may include
escape sequences (@pxref{Text String Format}).  The
@samp{--title-font-size} option may be used to specify the size of the
font.  The font is normally the same as the font used for labeling axes
and ticks, as selected by the @samp{-F} option.  But this can be
overridden with the @samp{--title-font-name} option.

@item -N @var{x|y}
@itemx --toggle-no-ticks @var{x|y}
Toggle the presence of ticks and tick labels on the specified axis.
This applies to the grid styles that normally include ticks and tick
labels, i.e., grid styles 1, 2, 3, @w{and 4}.

@item -r @var{right}
@itemx --right-shift @var{right}
(Float, default 0.2.)  Move the plot to the right by a fractional amount
@var{right} with respect to the width of the display (or virtual
display, in the case of a multiplot).  This produces a margin on the
left side of the plotting box.  @w{A value} of 0.5 will produce a margin
half the width of the available area.  Note that the tick marks and
labels are drawn in the margin.

@item -R @var{x|y}
@itemx --toggle-round-to-next-tick @var{x|y}
Toggle whether or not the upper and lower limits of the specified axis
should be expanded, so that they both become integer multiples of the
spacing between labeled tick marks.

This option is meaningful whenever the user specifies either or both of
the limits, by using the @samp{-x} or @samp{-y} option.  @w{If the} user
leaves both limits unspecified, they will always be chosen to satisfy
the `integer multiple' constraint.

@item -s
@itemx --save-screen
Save the screen.  This option requests that @code{graph} not erase the
output device before it begins to plot.  

This option is relevant only to @code{graph -T tek} and raw
@code{graph}.  Tektronix displays and emulators are persistent, in the
sense that previously drawn graphics remain visible.  So by repeatedly
using @code{graph -T tek -s}, you can @w{build up} a multiplot.

@item -t
@itemx --toggle-transpose-axes
Transpose the abscissa and ordinate.  This causes the axes to be
interchanged, and the options that apply to each axis to be applied to
the opposite axis.  That is, data points are read in as @math{(y, x)}
pairs, and such options as @samp{-x} and @samp{-X} apply to the
@w{@math{y} axis} rather than the @w{@math{x} axis}.  @w{If the}
@samp{-I e} option is in force, so that the data points are read with
error bars, the orientation of the error bars will be switched between
vertical and horizontal.

@item -u @var{up}
@itemx --upward-shift @var{up}
(Float, default 0.2.)  Move the plot up by a fractional amount @var{up}
with respect to the height of the display (or virtual display, in the
case of a multiplot).  This produces a margin below the plotting box.
@w{A value} of 0.5 will produce a margin half the height of the
available area.  Note that the tick marks and labels are drawn in the
margin.

@item -w @var{width}
@itemx --width-of-plot @var{width}
(Float, default 0.6.)  Set the fractional width of the plot with respect
to the width of the display (or virtual display, in the case of a
multiplot) to be @var{width}.  @w{A value} of 1.0 will produce a
plotting box that fills the entire available area.  Since labels and
tick marks may be placed outside the plotting box, values considerably
less than 1.0 are normally chosen.

@item -x [@var{lower_limit} [@var{upper_limit} [@var{spacing}]]]
@itemx --x-limits [@var{lower_limit} [@var{upper_limit} [@var{spacing}]]]
(Floats.) The arguments @var{lower_limit} and @var{upper_limit} specify
the limits of the @w{@math{x} axis}, and the optional argument
@var{spacing} specifies the spacing of labeled ticks along the axis.
@w{If any} of the three arguments is missing or is supplied @w{as
@samp{-}} (i.e., as a single hyphen), @w{it is} computed from the data.
Both arguments @var{lower_limit} and @var{upper_limit} must be present
if @code{graph} is to act as a real-time filter.

By default, the supplied limit(s) are strictly respected.  However, the
@samp{-R x} option may be used to request that they be rounded to the
nearest integer multiple of the spacing between labeled ticks.  The
lower limit will be rounded downward, and the upper limit upward.

@item -X @var{x_label}
@itemx --x-label @var{x_label}
(String, default empty.)  Set the label for the @math{x} axis to be the text
string @var{x_label}.  The string may include escape sequences
(@pxref{Text String Format}).  The @samp{-F} and @samp{-f} options may
be used to specify the name of the font and the size of the font.

@item -y [@var{lower_limit} [@var{upper_limit} [@var{spacing}]]]
@itemx --y-limits [@var{lower_limit} [@var{upper_limit} [@var{spacing}]]]
(Floats.)  The arguments specify the limits of the @math{y} axis, and
the spacing of labeled ticks along it, as for the @w{@math{x} axis} (see
above).  Both arguments @var{lower_limit} and @var{upper_limit} must be
present if @code{graph} is to act as a real-time filter.

By default, the supplied limit(s) are strictly respected.  However, the
@samp{-R y} option may be used to request that they be rounded to the
nearest multiple of the tick spacing.  The lower limit will be rounded
downward, and the upper limit upward.

@item -Y @var{y_label}
@itemx --y-label @var{y_label}
(String, default empty.)  Set the label for the @math{y} axis to be the
text string @var{y_label}.  The string may include escape sequences
(@pxref{Text String Format}).  The label will be rotated by 90 degrees
so that it is parallel to the axis, unless the
@samp{--toggle-rotate-y-label} option is used.  Some old @w{X Window}
System displays do not support rotated labels, and require the
@samp{--toggle-rotate-y-label} option.  The @samp{-F} and @samp{-f}
options can be used to specify the name of the font and the size of the
font.

@item --bg-color @var{name}
(String, default "white".)  Set the color used for the plot background
to be @var{name}.  This is relevant only to @code{graph @w{-T X}},
@code{graph -T png}, @code{graph -T pnm}, @code{graph -T gif},
@code{graph -T cgm}, @code{graph -T regis}, and @code{graph -T meta}.
@w{An unrecognized} name sets the color to the default.  For information
on what names are recognized, see @ref{Color Names}.  The environment
variable @code{BG_COLOR} can equally well be used to specify the
background color.

If the @samp{-T png} or @samp{-T gif} option is used, a transparent PNG
file or a transparent pseudo-GIF, respectively, may be produced by
setting the @code{TRANSPARENT_COLOR} environment variable to the name of
the background color.  @xref{graph Environment}.  @w{If the} @samp{-T
svg} or @samp{-T cgm} option is used, an output file without a
background may be produced by setting the background color to "none".

@item --bitmap-size @var{bitmap_size}
(String, default "570x570".)  Set the size of the graphics display in
which the plot will be drawn, in terms of pixels, to be
@var{bitmap_size}.  This is relevant only to @code{graph @w{-T X}},
@code{graph -T png}, @code{graph -T pnm}, and @code{graph -T gif}, for
all of which the size can be expressed in terms of pixels.  The
environment variable @code{BITMAPSIZE} may equally well be used to
specify the size.

The graphics display used by @code{graph -T X} is a popped-up @w{X
window}.  Command-line positioning of this window on an @w{X Window}
System display is supported.  For example, if @var{bitmap_size} is
"570x570+0+0" then the window will be @w{popped up} in the upper left
corner.

If you choose a rectangular (non-square) window size, the fonts in the
plot will be scaled anisotropically, i.e., by different factors in the
horizontal and vertical direction.  For this, @code{graph @w{-T X}}
requires an X11R6 display.  Any font that cannot be anisotropically
scaled will be replaced by a default scalable font, such as the Hershey
vector font "HersheySerif".

For backward compatibility, @code{graph -T X} allows the user to set the
window size and position by setting the @w{X resource}
@code{Xplot.geometry}, instead of @samp{--bitmap-size} or
@code{BITMAPSIZE}@.

@item --emulate-color @var{option}
(String, default "no".)  If @var{option} is "yes", replace each color in
the output by an appropriate shade of gray.  This is seldom useful,
except when using @samp{graph -T pcl} to prepare output for a @w{PCL 5}
device.  (Many monochrome @w{PCL 5} devices, such as monochrome
LaserJets, do a poor job of emulating color on their own.  They usually
map HP-GL/2's seven standard pen colors, including even yellow, to
black.)  You may equally well request color emulation by setting the
environment variable @code{EMULATE_COLOR} to "yes".

@item --frame-color @var{name}
(String, default "black".)  Set the color used for drawing the plot
frame, and for drawing monochrome datasets @w{(if any)} to be
@var{name}.  @w{An unrecognized} name sets the color to the default.
For information on what names are recognized, see @ref{Color Names}.

@item --frame-line-width @var{frame_line_width}
(Float, default @minus{}1.0.)  Set the thickness of lines in the plot
frame, as a fraction of the size (i.e., minimum dimension) of the
graphics display, to @var{frame_line_width}.  @w{A negative} value means
that the default value for the line thickness provided by the GNU
@code{libplot} graphics library should be used.  This is usually 1/850
times the size of the display, although if @samp{-T X}, @samp{-T png},
@samp{-T pnm}, or @samp{-T gif} is specified, it is zero.  By
convention, a zero-thickness line is the thinnest line that can be
drawn.  This is the case in all output formats.  Note, however, that the
drawing editors @code{idraw} and @code{xfig} treat zero-thickness lines
as invisible.

@code{graph -T tek} and @code{graph -T regis} do not support drawing
lines with other than a default thickness, and @code{graph -T hpgl} does
not support @w{doing so} if the environment variable @code{HPGL_VERSION}
is set to a value less @w{than "2"} (the default).

@item --max-line-length @var{max_line_length}
(Integer, default 500.)  Set the maximum number of points that a
polygonal line drawn through any dataset may contain, before it is
flushed to the output device, to equal @var{max_line_length}.  @w{If
this} flushing occurs, the polygonal line will be split into two or more
sub-lines, though the splitting should not be noticeable.  Splitting
will not take place if the @samp{-q} option, which requests filling, is
used.

The reason for splitting long polygonal lines is that some display
devices (e.g., old Postscript printers and HP-GL pen plotters) have
limited buffer sizes.  The environment variable @code{MAX_LINE_LENGTH}
can also be used to specify the maximum line length.  This option has no
effect on @code{graph -T tek} or raw @code{graph}, since they draw
polylines in real time and have no buffer limitations.

@item --page-size @var{pagesize}
(String, default "letter".)  Set the size of the page on which the plot
will be positioned.  This is relevant only to @code{graph -T svg},
@code{graph -T ai}, @code{graph -T ps}, @code{graph -T cgm}, @code{graph
-T fig}, @code{graph -T pcl}, and @code{graph -T hpgl}.  "letter" means
an 8.5@dmn{in} by 11@dmn{in} page.  Any ISO page size in the range
"a0"@dots{}"a4" or ANSI page size in the range "a"@dots{}"e" may be
specified ("letter" is an alias @w{for "a"} and "tabloid" is an alias
@w{for "b"}).  "legal", "ledger", @w{and "b5"} are recognized page sizes
also.  The environment variable @code{PAGESIZE} can equally well be used
to specify the page size.

For @code{graph -T ai}, @code{graph -T ps}, @code{graph -T pcl}, and
@code{graph -T fig}, the graphics display (or `viewport') within which
the plot is drawn will be, by default, a square region centered on the
specified page.  For @code{graph -T hpgl}, it will be a square region of
the same size, but may be positioned differently.  Either or both of the
dimensions of the graphics display can be specified explicitly.  For
example, @var{pagesize} could be specified as "letter,xsize=4in", or
"a4,xsize=10cm,ysize=15cm".  The dimensions are allowed to be negative
(@w{a negative} dimension results in a reflection).

The position of the graphics display, relative to its default position,
may optionally be adjusted by specifying an offset vector.  For example,
@var{pagesize} could be specified as "letter,yoffset=1.2in", or
"a4,xoffset=@minus{}5mm,yoffset=2.0cm".  @w{It is} also possible to
position the graphics display precisely, by specifying the location of
its lower left corner relative to the lower left corner of the page.
For example, @var{pagesize} could be specified as
"letter,xorigin=2in,yorigin=3in", or "a4,xorigin=0.5cm,yorigin=0.5cm".
The preceding options may be intermingled.  @code{graph -T svg} and
@code{graph -T cgm} ignore the "xoffset", "yoffset", "xorigin", and
"yorigin" options, since SVG format and WebCGM format have no notion of
the Web page on which the graphics display will ultimately be
positioned.  For more on page sizes, see @ref{Page and Viewport Sizes}.

@item --pen-colors @var{colors}
(String, default "1=red:2=green:3=blue:4=magenta:5=cyan".)  Set the
colors of the pens used for drawing plots, as numbered, to be
@var{colors}.  The format should be self-explanatory.  @w{An
unrecognized} name sets the corresponding color to the default.  For
information on what names are recognized, see @ref{Color Names}.

@item --rotation @var{angle}
(Integer, default 0.)  Set the rotation angle of the graphics display to
be @var{angle} degrees.  Recognized values are @w{0, 90}, 180, @w{and
270}.  The rotation is counterclockwise.  The environment variable
@code{ROTATION} can equally well be used to specify the rotation angle.

This option is used for switching between portrait and landscape
orientations.  Postmodernists may also find it useful.

@item --title-font-name @var{font_name}
(String, default "Helvetica" except for @code{graph -T pcl}, for which
"Univers" is the default, and @code{graph -T png}, @code{graph -T pnm},
@code{graph -T gif}, @code{graph -T hpgl}, @code{graph -T regis}, and
@code{graph -T tek}, for all of which "HersheySerif" is the default.)
Set the font used for the plot title to be @var{font_name}.  Normally
the font used for the plot title is the same as that used for labeling
the axes and the ticks along the axes, as specified by the @samp{-F}
option.  But the @samp{--title-font-name} option can be used to override
this.  Font names are case-insensitive.  @w{If the} specified font is
not available, the default font will be used.  Which fonts are available
depends on which @samp{-T} option is used.  For a list of all fonts, see
@ref{Text Fonts}.  The @code{plotfont} utility will produce a character
map of any available font.  @xref{plotfont}.

@item --title-font-size @var{size}
(Float, default 0.07.)  Set the size of the font used for the top label
(`title'), as specified by the @samp{-L} option, to be @var{size}.  The
size is specified as a fraction of the minimum dimension (width or
height) of the plotting box.

@item --toggle-rotate-y-label
Position the label on the @math{y} axis (which is set with the @samp{-Y}
option) horizontally instead of vertically, or vice versa.  By default,
the label is rotated, so that it is parallel to the @w{@math{y} axis}.
But some output devices (e.g., old @w{X Window} System displays) cannot
handle rotated fonts.
@end table

@node Dataset Options, Multiplot Options, Plot Options, graph Invocation
@subsection Dataset options

The following options affect the way in which individual datasets are
read from files, and drawn as part of a plot.  They should appear on the
command line before the file containing the datasets whose reading or
rendering they will affect.  They may appear more than once on a command
line, if more than one file is to be read.

The following three options affect the way in which datasets are read
from files.

@table @samp
@item -I @var{data-format}
@itemx --input-format @var{data-format}
This specifies which format the subsequent input file(s) are in.

@table @samp
@item a  
ASCII format.  Each input file is a sequence of floating point numbers,
interpreted as the @math{x} @w{and @math{y}} coordinates of the
successive data points in a dataset.  The @math{x} @w{and @math{y}}
coordinates of a point need not appear on the same line, and points need
not appear on different lines.  But if a blank line occurs (i.e., two
newlines in succession are seen), @w{it is} interpreted as the end of a
dataset, and the beginning of the next.

@item e
ASCII format, including error bars.  Similar to @samp{a} format, except
that triples (@math{x},@math{y},@i{error}) appear instead of pairs
@math{(x,y)}.

@item g
The ASCII `table' format produced by the @code{gnuplot} plotting program.

@item f
@ifnottex
Single precision binary format.  Each input file is a sequence of single
precision floating point numbers, interpreted as forming pairs
(@math{x},@math{y}).  Successive datasets are separated by a single
occurrence of the quantity @code{FLT_MAX}, which is the largest possible
single precision floating point number.  @w{On most} machines this is
approximately 3.4x10^38.
@end ifnottex
@tex
Single precision binary format.  Each input file is a sequence of single
precision floating point numbers, interpreted as forming pairs
(@math{x},@math{y}).  Successive datasets are separated by a single
occurrence of the quantity @code{FLT_MAX}, which is the largest possible
single precision floating point number.  @w{On most} machines this is
approximately $3.4\times10^{38}$.
@end tex

@item d
@ifnottex
Double precision binary format.  Each input file is a sequence of double
precision floating point numbers, interpreted as forming pairs
(@math{x},@math{y}).  Successive datasets are separated by a single
occurrence of the quantity @code{DBL_MAX}, which is the largest possible
double precision floating point number.  @w{On most} machines this is
approximately 1.8x10^308.
@end ifnottex
@tex
Double precision binary format.  Each input file is a sequence of double
precision floating point numbers, interpreted as forming pairs
(@math{x},@math{y}).  Successive datasets are separated by a single
occurrence of the quantity @code{DBL_MAX}, which is the largest possible
double precision floating point number.  @w{On most} machines this is
approximately $1.8\times10^{308}$.
@end tex

@item i
@ifnottex
Integer binary format.  Each input file is a sequence of integers,
interpreted as forming pairs (@math{x},@math{y}).  Successive datasets
are separated by a single occurrence of the quantity @code{INT_MAX},
which is the largest possible integer.  @w{On most} machines this is
2^31-1.
@end ifnottex
@tex
Integer binary format.  Each input file is a sequence of integers,
interpreted as forming pairs (@math{x},@math{y}).  Successive datasets
are separated by a single occurrence of the quantity @code{INT_MAX},
which is the largest possible integer.  @w{On most} machines this is
$2^{31}-1$.
@end tex
@end table

@item -a [@var{step_size} [@var{lower_limit}]]
@itemx --auto-abscissa [@var{step_size} [@var{lower_limit}]]
(Floats, defaults 1.0 and 0.0.) Automatically generate abscissa
(@math{x}) values.  Irrespective of data format (@samp{a}, @samp{e},
@samp{f}, @samp{d}, @w{or @samp{i}}), this option specifies that the
abscissa (@math{x}) values are missing from the input file: the
dataset(s) to be read contain only ordinate (@math{y}) values.  The
increment from each @w{@math{x} value} to the next will be
@var{step_size}, and the first @w{@math{x} value} will be
@var{lower_limit}.  @w{To return} to reading abscissa values from the
input, i.e., for subsequent input files, you would use @samp{-a 0},
which disables automatic generation of the abscissa values and returns
@var{step_size} and @var{lower_limit} to their default values.

@item -B
@itemx --toggle-auto-bump
By default, the linemode (set with @samp{-m}, see below) is `bumped'
(incremented by unity) at the beginning of each new dataset.  This
option toggles auto-bumping: @w{it turns} it off if it was on, and on if
it was off.
@end table

The following options affect the way in which individual datasets are
drawn as part of a plot.  These options set the six `attributes' (symbol
type, symbol font, linemode, line thickness, fill fraction, and
color/monochrome) that each dataset has.

@table @samp
@item -m @var{line_mode}
@itemx --line-mode @var{line_mode}
(Integer, default 1.)  @var{line_mode} specifies the mode (i.e., style)
of the lines drawn between successive points in a dataset.  By
convention, linemode #0 means no line @w{at all} (data points are
disconnected).  @w{If the} dataset is being rendered in monochrome, the
interpretation of @var{line_mode} is as follows.

@enumerate
@item solid
@item dotted
@item dotdashed
@item shortdashed
@item longdashed
@end enumerate

Thereafter (i.e., for @var{line_mode} greater than 5) the sequence of
five linemodes repeats.  So besides linemode #0, there are a total of
five distinct monochrome linemodes.  @w{If the} dataset is being
rendered in color (as may be requested with the @samp{-C} option), the
interpretation of linemodes #1 through #5 is instead

@enumerate
@item red, solid
@item green, solid
@item blue, solid
@item magenta, solid
@item cyan, solid
@end enumerate

Linemodes #6 through #10 use the same five colors, but are dotted;
linemodes #11 through #15 are dotdashed; linemodes #16 through #20 are
shortdashed; and linemodes #21 through #25 are longdashed.  So besides
linemode #0, there are a total of 25 distinct colored linemodes.  @w{A
negative} linemode indicates that no line should be drawn, but that the
marker symbol, @w{if any} (see below), should be in the color of the
corresponding positive linemode.

@item -S [@var{symbol_number} [@var{symbol_size}]]
@itemx --symbol [@var{symbol_number} [@var{symbol_size}]]
(Integer and float, defaults 0 and 0.03.)  Draw a marker symbol at each
data point.  @var{symbol_number} specifies the symbol type, and
@var{symbol_size} specifies the font size of the symbol, as a fraction
of the minimum dimension (width or height) of the plotting box.  @w{If
the} dataset is being rendered in color, the symbol will have the color
of the line that is being drawn to connect the data points.

If you use the @samp{-S} option, you would usually also use the
@samp{-m} option, to request that the symbols be drawn without any line
connecting them.  By specifying a negative argument @w{to @samp{-m}}
(@w{a `negative} linemode'), you may obtain colored symbols.

The following table lists the first few symbols (by convention,
@w{symbol #0} means @w{no symbol} @w{at all}).

@enumerate
@item dot
@tex
($\thinspace\cdot\thinspace$)
@end tex
@item plus (@math{+})
@item asterisk (@math{*})
@item circle
@tex
($\circ$)
@end tex
@item cross
@tex
($\times$)
@end tex
@end enumerate

Marker symbols 0@dots{}31 are furnished by the GNU @code{libplot}
graphics library.  @xref{Marker Symbols}.  Symbol numbers greater than
or equal @w{to 32} are interpreted as characters in a symbol font, which
can be set with the @samp{--symbol-font-name} option (see below).

@item -W @var{line_width}
@itemx --line-width @var{line_width}
(Float, default @minus{}1.0.)  Set the thickness of the lines used to
join successive points in a dataset, as a fraction of the size (i.e.,
minimum dimension) of the graphics display, to @var{line_width}.  @w{A
negative} value means that the default value for the line thickness
provided by the GNU @code{libplot} graphics library should be used.
This is usually 1/850 times the size of the display, although if
@samp{-T X}, @samp{-T png}, @samp{-T pnm}, or @samp{-T gif} is
specified, it is zero.  By convention, a zero-thickness line is the
thinnest line that can be drawn.  This is the case in all output
formats.  Note, however, that the drawing editors @code{idraw} and
@code{xfig} treat zero-thickness lines as invisible.

@code{graph -T tek} and @code{graph -T regis} do not support drawing
lines with other than a default thickness, and @code{graph -T hpgl} does
not support @w{doing so} if the environment variable @code{HPGL_VERSION}
is set to a value less @w{than "2"} (the default).

@item -q @var{fill_fraction}
@itemx --fill-fraction @var{fill_fraction}
(Float, default @minus{}1.0.)  If successive points in a dataset are
joined by line segments, set the shading intensity for the polygon
formed by the line segments to be @var{fill_fraction}.  @w{A solid}
polygon (i.e., one filled with the `pen color' used for drawing the line
segments) is obtained by choosing @var{fill_fraction}=1.0.  The interior
of the polygon will be white if @var{fill_fraction}=0.0.  The polygon
will be unfilled (transparent) if @var{fill_fraction} is negative.

@w{If the} polygon intersects itself, the `even-odd fill rule' will
normally be used to determine which points are inside rather than
outside, i.e., to determine which portions of the polygon should be
shaded.  The even-odd fill rule is explained in the @cite{Postscript
Language Reference Manual}.

The @samp{-q} option has no effect on @code{graph -T tek}, and it is
only partly effective in @code{graph -T hpgl} if the environment
variable @code{HPGL_VERSION} is set to a value less @w{than "2"} (the
default).

@item -C
@itemx --toggle-use-color
Toggle between color and monochrome rendering of datasets.  The
interpretation of linemode depends on whether the rendering is being
performed in color or monochrome; see the @samp{-m} option above.

@item --symbol-font-name @var{symbol_font_name}
(String, default "ZapfDingbats" unless @samp{-T png}, @samp{-T pnm},
@samp{-T gif}, @samp{-T pcl}, @samp{-T hpgl}, @samp{-T regis}, or
@code{@w{-T tek}} is specified, in which case it is "HersheySerif".)
Set the symbol font, from which marker symbols numbered 32 and higher
are selected, to be @var{symbol_font_name}.  Font names are
case-insensitive.  @w{If the} specified font is not available, the
default font will be used.  Which fonts are available depends on which
@samp{-T} option is used.  For example, if the @samp{-T pcl} or @samp{-T
hpgl} option is used then normally the Wingdings font, which is an
alternative source of symbols, becomes available.  For a list of all
fonts, see @ref{Text Fonts}.  The @code{plotfont} utility will produce a
character map of any available font.  @xref{plotfont}.

@end table

@node Multiplot Options, Raw graph Options, Dataset Options, graph Invocation
@subsection Multiplot options

The following options are used for multiplotting (placing more than a
single plots on a display, or a page).  The @samp{--reposition}
directive serves as a separator, on the command line, between the
options and file names that apply to successive plots.

@table @samp
@item --reposition @var{x} @var{y} @var{size}
(Floats, defaults 0.0, 0.0, 1.0) Set the `virtual display' within which
the next plot will be drawn to be a square of size @var{size}, with
lower left corner (@var{x},@var{y}).  Normalized coordinates are used
here: (0,0) means the lower left corner of the physical display and
(1,1) means the upper right corner of the physical display.  The size of
the plot within the virtual display may be adjusted with the @samp{-h}
and @samp{-w} options, and its position within the virtual display with
the @samp{-u} and @samp{-w} options.  After a @samp{--reposition}
directive, the arguments of those four options will be interpreted in
terms of the virtual display, not the physical display.

@item --blankout @var{blankout_fraction}
(Float, default 1.3.)  Before each additional plot of a multiplot is
drawn, the region of the display that the plot will occupy is cleared.
If @var{blankout_fraction}=1.3, @w{a region} @w{30% larger} in each
dimension is cleared.  If, for example, @var{blankout_fraction}=1.0, the
region covered by the plot's plotting box, and @w{no more}, is cleared.
The default value, 1.3, is appropriate for inset plots.  @w{1.0 would}
be appropriate for side by side plots.

@code{graph -T tek} cannot clear regions, and @code{graph -T hpgl}
cannot clear them if the environment variables @code{HPGL_VERSION} and
@code{HPGL_OPAQUE_MODE} are set to non-default values (i.e., values
other than @w{"2" and "yes"}, respectively).
@end table

@node Raw graph Options, Info Options, Multiplot Options, graph Invocation
@subsection Raw @code{graph} options

The following option is relevant only to raw @code{graph}, i.e., is
relevant only if no display type or output format is specified with the
@samp{-T} option.  In this case @code{graph} outputs a graphics
metafile, which may be translated to other formats by invoking
@code{plot}.  This option should appear on the command line before any
file names, since it affects the output of the plot (or multiplot) as a
whole.

@table @samp
@item -O
@itemx --portable-output
Output the portable (human-readable) version of GNU metafile format,
rather than a binary version (the default).  This can also be requested
by setting the environment variable @code{META_PORTABLE} to "yes".
@end table

@node Info Options, graph Environment, Raw graph Options, graph Invocation
@subsection Informational options

The following options request information.

@table @samp
@item --help
Print a list of command-line options, and then exit.

@item --help-fonts
Print a table of available fonts, and then exit.  The table will depend
on which display type or output format is specified with the @samp{-T}
option.  @code{graph @w{-T X}}, @code{graph -T svg}, @code{graph -T ai},
@code{graph -T ps}, @code{graph -T cgm}, and @code{graph -T fig} each
support the 35 standard Postscript fonts.  @code{graph -T svg},
@code{graph -T ai}, @code{graph -T pcl}, and @code{graph -T hpgl}
support the 45 standard @w{PCL 5} fonts, and @code{graph -T pcl} and
@code{graph -T hpgl} support a number of Hewlett--Packard vector fonts.
All of the preceding, together with @code{graph -T png}, @code{graph -T
pnm}, @code{graph -T gif}, @code{graph -T regis}, and @code{graph -T
tek}, support a set of 22 Hershey vector fonts.  Raw @code{graph} @w{in
principle} supports any of these fonts, since its output must be
translated to other formats with @code{plot}.  The @code{plotfont}
utility will produce a character map of any available font.
@xref{plotfont}.

@item --list-fonts
Like @samp{--help-fonts}, but lists the fonts in a single column to
facilitate piping to other programs.  @w{If no} display type or output
format is specified with the @samp{-T} option, the full set of supported
fonts is listed.

@item --version
Print the version number of @code{graph} and the plotting utilities
package, and exit.
@end table

@node graph Environment, , Info Options, graph Invocation
@section Environment variables

The behavior of @code{graph} is affected by several environment
variables.  We have already mentioned the environment variables
@code{BITMAPSIZE}, @code{PAGESIZE}, @code{BG_COLOR},
@code{EMULATE_COLOR}, @code{MAX_LINE_LENGTH}, and @code{ROTATION}@.
They serve as backups for the several options @samp{--bitmap-size},
@samp{--page-size}, @samp{--bg-color}, @samp{--emulate-color},
@samp{--max-line-length}, and @samp{--rotation}.  The remaining
environment variables are specific to individual output formats.

@code{graph @w{-T X}}, which pops up a window on an @w{X Window} System
display and draws graphics @w{in it}, checks the @code{DISPLAY}
environment variable.  The value of this variable determines the display
on which the window will be @w{popped up}.

@code{graph -T png} and @code{graph -T gif}, which produce output in PNG
and pseudo-GIF format respectively, are affected by two environment
variables.  If the value of the @code{INTERLACE} variable is "yes", the
output file will be interlaced.  Also, if the value of the
@code{TRANSPARENT_COLOR} environment variable is the name of a color
that appears in the output file, that color will be treated as
transparent by most applications.  For information on what color names
are recognized, see @ref{Color Names}.

@code{graph -T pnm}, which produces output in Portable Anymap
(PBM/PGM/PPM) format, is affected by the @code{PNM_PORTABLE} environment
variable.  If its value is "yes", the output file will be in the
portable (human readable) version of PBM, PGM, or PPM format, rather
than the default (binary) version.

@code{graph -T cgm}, which produces CGM files that comply with the
WebCGM profile for Web-based vector graphics, is affected by two
environment variables.  By default, a @w{version 3} CGM file is
generated.  Many older CGM interpreters and viewers, such as the ones
built into Microsoft Office and other commercial software, only support
@w{version 1} CGM files.  The @code{CGM_MAX_VERSION} environment
variable may be set to "1", "2", "3", @w{or "4"} (the default) to
specify an maximum value for the version number.  The
@code{CGM_ENCODING} variable may also be set, to specify the type of
encoding used in the CGM file.  Supported values are "clear_text" (i.e.,
human readable) and "binary" (the default).  The WebCGM profile requires
that the binary encoding be used.

@code{graph -T pcl}, which produces @w{PCL 5} output for
Hewlett--Packard printers, is affected by the environment variable
@code{PCL_ASSIGN_COLORS}@.  It should be set to "yes" when producing
@w{PCL 5} output for a color printer or other color device.  This will
ensure accurate color reproduction by giving the output device complete
freedom in assigning colors, internally, to its ``logical pens''.  If it
is "no" then the device will use a fixed set of colored pens, and will
emulate other colors by shading.  The default is "no" because monochrome
@w{PCL 5} devices, which are more common than colored ones, must use
shading to emulate color.

@code{graph -T hpgl}, which produces Hewlett--Packard Graphics Language
output, is also affected by several environment variables.  The most
important is @code{HPGL_VERSION}, which may be set to "1", "1.5", @w{or
"2"} (the default).  @w{"1" means} that the output should be generic
HP-GL, @w{"1.5" means} that the output should be suitable for the
HP7550A graphics plotter and the HP758x, HP7595A and HP7596A drafting
plotters (HP-GL with some HP-GL/2 extensions), and @w{"2" means} that
the output should be modern HP-GL/2.  @w{If the} version is "1" @w{or
"1.5"} then the only available fonts will be vector fonts, and all lines
will be drawn with a default thickness (the @samp{-W} option will not
work).  Additionally, if the version @w{is "1"} then the filling of
arbitrary curves with solid color will not be supported (the @samp{-q}
option may be used to fill circles and rectangles aligned with the
coordinate axes, though).

The position of the @code{graph -T hpgl} graphics display on the page
can be rotated @w{90 degrees} counterclockwise by setting the
@code{HPGL_ROTATE} environment variable to "yes".  This is not the same
as the rotation obtained with the @samp{--rotation} option, since it
both rotates the graphics display and repositions its lower left corner
toward another corner of the page.  Besides "no" and "yes", recognized
values for the @code{HPGL_ROTATE} variable are "0", "90", "180", @w{and
"270"}.  @w{"no" and} "yes" are equivalent to @w{"0" and "90"},
respectively.  "180" and "270" are supported only if @code{HPGL_VERSION}
@w{is "2"} (the default).

@emph{Opaque} filling and the drawing of visible white lines are
supported only if @code{HPGL_VERSION} is "2" (the default) and the
environment variable @code{HPGL_OPAQUE_MODE} is "yes" (the default).
@w{If the} value is "no" then opaque filling will not be used, and white
lines (@w{if any}), which are normally drawn with @w{pen #0}, will not
be drawn.  This feature is to accommodate older HP-GL/2 devices.
HP-GL/2 pen plotters, @w{for example}, do not support opacity or the use
of @w{pen #0} to draw visible white lines.  Some older HP-GL/2 devices
reportedly malfunction if asked to draw opaque objects.

@w{By default}, @code{graph -T hpgl} will draw with a fixed set of pens.
Which pens are present may be specified by setting the @code{HPGL_PENS}
environment variable.  If @code{HPGL_VERSION} @w{is "1"}, the default
value of @code{HPGL_PENS} is "1=black"; if @code{HPGL_VERSION} is
"1.5" @w{or "2"}, the default value of @code{HPGL_PENS} is
"1=black:2=red:3=green:4=yellow:5=blue:6=magenta:7=cyan".  The format
should be self-explanatory.  By setting @code{HPGL_PENS}, you may
specify a color for any pen in the range #1@dots{}#31.  For information
on what color names are recognized, see @ref{Color Names}.  @w{Pen #1}
must always be present, though it need not be black. Any other pen in
the range #1@dots{}#31 may be omitted.

If @code{HPGL_VERSION} is "2" then @code{graph -T hpgl} will also be
affected by the environment variable @code{HPGL_ASSIGN_COLORS}@.  @w{If
the} value of this variable is "yes", then @code{graph -T hpgl} will not
be restricted to the palette specified in @code{HPGL_PENS}: @w{it will}
assign colors to ``logical pens'' in the range #1@dots{}#31, @w{as
needed}.  The default value is "no" because other than color LaserJet
printers and DesignJet plotters, not many HP-GL/2 devices allow the
assignment of colors to logical pens.  In particular, HP-GL/2 pen
plotters do not.

@code{graph -T tek}, which produces output for a Tektronix terminal or
emulator, checks the @code{TERM} environment variable.  @w{If the} value
of @code{TERM} is a string beginning with "xterm", "nxterm", or "kterm",
@w{it is} taken as a sign that @code{graph} is running in an @w{X
Window} System VT100 terminal emulator: @w{an @code{xterm}},
@code{nxterm}, or @code{kterm}.  Before drawing graphics, @code{graph -T
tek} will emit an escape sequence that causes the terminal emulator's
auxiliary Tektronix window, which is normally hidden, to @w{pop up}.
After the graphics are drawn, an escape sequence that returns control to
the original VT100 window will be emitted.  The Tektronix window will
remain on the screen.

If the value of @code{TERM} is a string beginning with "kermit",
"ansi.sys", or "nansi.sys", @w{it is} taken as a sign that @code{graph}
is running in the VT100 terminal emulator provided by the MS-DOS version
of @code{kermit}.  Before drawing graphics, @code{graph -T tek} will
emit an escape sequence that switches the terminal emulator to Tektronix
mode.  Also, some of the Tektronix control codes emitted by @code{graph
-T tek} will be @code{kermit}-specific.  There will be a limited amount
of color support, which is not normally the case (the 16 @code{ansi.sys}
colors will be supported).  After drawing graphics, @code{graph -T tek}
will emit an escape sequence that returns the emulator to VT100 mode.
The key sequence `@w{ALT minus}' can be employed manually within
@code{kermit} to switch between the two modes.

@node plot, pic2plot, graph, Top
@chapter The @code{plot} Program

@menu
* plot Examples::       How to use a plot filter
* plot Invocation::     Command-line options
* plot Environment::    Environment variables
@end menu

@node plot Examples, plot Invocation, plot, plot
@section How to use @code{plot}

The GNU plot filter @code{plot} displays GNU graphics metafiles or
translates them to other formats.  @w{It will} take input from files
specified on the command line or from standard input.  The @samp{-T}
option is used to specify the desired output format.  Supported output
formats include "X", "png", "pnm", "gif", "svg", "ai", "ps", "cgm",
"fig", "pcl", "hpgl", "regis", "tek", and "meta" (the default).

The metafile format is a device-independent format for storage of vector
graphics.  By default, it is a binary rather than a human-readable
format (@pxref{Metafiles}).  Each of the @code{graph}, @code{pic2plot},
@code{tek2plot}, and @code{plotfont} utilities will write a graphics
metafile to standard output if no @samp{-T} option is specified on its
command line.  The GNU @code{libplot} graphics library may also be used
to produce metafiles.  Metafiles may contain arbitrarily many pages of
graphics, but each metafile produced by @code{graph} contains only a
single page.

@code{plot}, like the metafile format itself, is useful if you wish to
preserve a vector graphics file, and display or edit it with more than
one drawing editor.  The following example shows how you may do this.

To produce a plot of data arranged as alternating @math{x} and @math{y}
coordinates in an ASCII file, you may use @code{graph} as follows:

@example
graph < datafile > test.meta
@end example

@noindent
The file @file{test.meta} will be a single-page graphics metafile.
Similarly, to create in metafile format a plot consisting of a simple
figure, you may do:

@example
echo 0 0 1 1 2 0 | spline | graph > test.meta
@end example

@noindent
To display any such plot on an @w{X Window} System display, you
would do

@example
plot -T X test.meta
@end example

@noindent 
or

@example
plot -T X < test.meta
@end example

@noindent
To print the plot on a Postscript printer, you would do something
like

@example
plot -T ps < test.meta | lpr
@end example

@noindent
To edit it with the free @code{idraw} drawing editor, you would do

@example
@group
plot -T ps < test.meta > test.ps
idraw test.ps
@end group
@end example

@noindent
To produce a PNG file, you would do
@example
plot -T png < test.meta > test.png
@end example

@noindent
To produce a ``portable anymap'' (a file in PBM, PGM, or PPM format,
whichever is most appropriate) you would do
@example
plot -T pnm < test.meta > test.pnm
@end example

@noindent
and to produce a pseudo-GIF file, you would do
@example
plot -T gif < test.meta > test.gif
@end example

@noindent
Similarly, to produce versions of the plot in SVG format and WebCGM
format that can be displayed in a Web browser with SVG and WebCGM
support, you would do

@example
plot -T svg < test.meta > test.svg
plot -T cgm < test.meta > test.cgm
@end example

@noindent
To produce a version of the plot that can be viewed and edited with
Adobe Illustrator, you would do

@example
plot -T ai < test.meta > test.ai
@end example

@noindent
and to produce a version that can be viewed and edited with the free
@code{xfig} drawing editor, you would do

@example
@group
plot -T fig < test.meta > test.fig
xfig test.fig
@end group
@end example

@noindent
Other formats may be obtained by using @code{plot -T pcl}, @code{plot -T
hpgl}, @code{plot -T regis}, and @code{plot -T tek}.

@code{plot} may behave differently depending on the environment in which
it is invoked.  In particular, @code{plot -T svg}, @code{plot -T ai},
@code{plot -T ps}, @code{plot -T cgm}, @code{plot -T fig}, @code{plot -T
pcl}, and @code{plot -T hpgl} are affected by the environment variable
@code{PAGESIZE}@.  @code{plot @w{-T X}}, @code{plot -T png}, @code{plot
-T pnm}, and @code{plot -T gif} are affected by the environment variable
@code{BITMAPSIZE}@.  The @code{DISPLAY} environment variable affects the
operation of @code{plot @w{-T X}}, and the @code{TERM} environment
variable affects the operation of @code{plot -T tek}.  There are also
several environment variables that affect the operation of @code{plot -T
pcl} and @code{plot -T hpgl}.  For a complete discussion of the effects
of the environment on @code{plot}, see @ref{plot Environment}.

@node plot Invocation, plot Environment, plot Examples, plot
@section @code{plot} command-line options

The plot filter @code{plot} translates GNU graphics metafiles to other
formats.  The @samp{-T} option is used to specify the output format or
display type.  Files in metafile format are produced by GNU
@code{graph}, @code{pic2plot}, @code{tek2plot}, @code{plotfont}, and
other applications that use the GNU @code{libplot} graphics library.
For technical details on the metafile format, see @ref{Metafiles}.

Input file names may be specified anywhere on the command line.  That
is, the relative order of file names and command-line options does not
matter.  If no files are specified, or the file @w{name @samp{-}} is
specified, the standard input is read.  An output file is written to
standard output, unless the @samp{-T X} option is specified.  @w{In
that} case the output is displayed in a window or windows on an @w{X
Window} System display, and there is no output file.

The full set of command-line options is listed below.  There are four
sorts of option:

@enumerate
@item
Options setting the values of drawing parameters.
@item
Options relevant only to raw @code{plot}, i.e., relevant only if no
display type or output format is specified with the @samp{-T} option.
@item
Options specifying the type of metafile format the input is in (for
backward compatibility only).
@item
Options requesting information (e.g., @samp{--help}).
@end enumerate

@noindent
Each option that takes an argument is followed, in parentheses, by the
type and default value of the argument.

The following options set the values of drawing parameters.

@table @samp
@item -T @var{type}
@itemx --display-type @var{type}
(String, default "meta".)  Select a display type or output format of
type @var{type}, which may be one of the strings "X", "png", "pnm",
"gif", "svg", "ai", "ps", "cgm", "fig", "pcl", "hpgl", "regis", "tek",
and "meta".  These refer respectively to the @w{X Window System}, PNG
format, portable anymap (PBM/PGM/PPM) format, pseudo-GIF format, the new
XML-based Scalable Vector Graphics format, the format used by Adobe
Illustrator, @code{idraw}-editable Postscript, the WebCGM format for
Web-based vector graphics, the format used by the @code{xfig} drawing
editor, the Hewlett--Packard @w{PCL 5} printer language, the
Hewlett--Packard Graphics Language (@w{by default}, HP-GL/2), the ReGIS
(remote graphics instruction set) format developed @w{by DEC}, Tektronix
format, and device-independent GNU graphics metafile format.

@item -p @var{n}
@itemx --page-number @var{n}
(Positive integer.) Display only page number @var{n}, within the
metafile or sequence of metafiles that is being translated.  

Metafiles may consist of one or more pages, numbered beginning @w{with
1}.  Also, each page may contain multiple `frames'.  @code{plot @w{-T
X}}, @code{plot -T regis}, or @code{plot -T tek}, which plot in real
time, will separate successive frames by screen erasures.  @code{plot -T
png}, @code{plot -T pnm}, @code{plot -T gif}, @code{plot -T svg},
@code{plot -T ai}, @code{plot -T ps}, @code{plot -T cgm}, @code{plot -T
fig}, @code{plot -T pcl}, @code{plot -T hpgl}, which do not plot in real
time, will display only the last frame of any multi-frame page.

The default behavior, if @samp{-p} is not used, is to display all pages.
For example, @code{plot @w{-T X}} displays each page in its own @w{X
window}.  @w{If the} @samp{-T png} option, the @samp{-T pnm} option, the
@samp{-T gif} option, the @samp{-T svg} option, the @samp{-T ai} option,
or the @samp{-T fig} option is used, the default behavior is to display
only the first page, since files in PNG, PNM, pseudo-GIF, SVG, AI, or
Fig format may contain only a single page of graphics.

Most metafiles produced by the GNU plotting utilities (e.g., by raw
@code{graph}) contain only a single page, consisting of two frames: an
empty one to clear the display, and a second one containing graphics.

@item -s
@itemx --merge-pages
Merge all displayed pages into a single page, and also merge all
`frames' within each displayed page.

This option is useful when merging together single-page plots from
different sources.  For example, it can be used to merge together plots
obtained from separate invocations of @code{graph}.  This is an
alternative form of multiplotting (@pxref{Multiplotting}).

@item --bitmap-size @var{bitmap_size}
(String, default "570x570".)  Set the size of the graphics display in
which the plot will be drawn, in terms of pixels, to be
@var{bitmap_size}.  This is relevant only to @code{plot @w{-T X}},
@code{plot -T png}, @code{plot -T pnm}, and @code{plot -T gif}, for all
of which the size can be expressed in terms of pixels.  The environment
variable @code{BITMAPSIZE} may equally well be used to specify the size.

The graphics display used by @code{plot -T X} is a popped-up @w{X
window}.  Command-line positioning of this window on an @w{X Window}
System display is supported.  For example, if @var{bitmap_size} is
"570x570+0+0" then the window will be @w{popped up} in the upper left
corner.

If you choose a rectangular (non-square) window size, the fonts in the
plot will be scaled anisotropically, i.e., by different factors in the
horizontal and vertical direction.  For this, @code{plot @w{-T X}}
requires an X11R6 display.  Any font that cannot be anisotropically
scaled will be replaced by a default scalable font, such as the Hershey
vector font "HersheySerif".

For backward compatibility, @code{plot -T X} allows the user to set the
window size and position by setting the @w{X resource}
@code{Xplot.geometry}, instead of @samp{--bitmap-size} or
@code{BITMAPSIZE}@.

@item --emulate-color @var{option}
(String, default "no".)  If @var{option} is "yes", replace each color in
the output by an appropriate shade of gray.  This is seldom useful,
except when using @samp{plot -T pcl} to prepare output for a @w{PCL 5}
device.  (Many monochrome @w{PCL 5} devices, such as monochrome
LaserJets, do a poor job of emulating color on their own.  They usually
map HP-GL/2's seven standard pen colors, including even yellow, to
black.)  You may equally well request color emulation by setting the
environment variable @code{EMULATE_COLOR} to "yes".

@item --max-line-length @var{max_line_length}
(Integer, default 500.)  Set the maximum number of points that a
polygonal line may contain, before it is flushed to the output device,
to equal @var{max_line_length}.  If this flushing occurs, the polygonal
line will be split into two or more sub-lines, though the splitting
should not be noticeable.  Splitting will not take place if the line is
the boundary of a filled polygon.

The reason for splitting long polygonal lines is that some display
devices (e.g., old Postscript printers and HP-GL pen plotters) have
limited buffer sizes.  The environment variable @code{MAX_LINE_LENGTH}
can also be used to specify the maximum line length.  This option has no
effect on @code{plot -T tek} or raw @code{plot}, since they draw
polylines in real time and have no buffer limitations.

@item --page-size @var{pagesize}
(String, default "letter".)  Set the size of the page on which the plot
will be positioned.  This is relevant only to @code{plot -T svg},
@code{plot -T ai}, @code{plot -T ps}, @code{plot -T cgm}, @code{plot -T
fig}, @code{plot -T pcl}, and @code{plot -T hpgl}.  "letter" means an
8.5@dmn{in} by 11@dmn{in} page.  Any ISO page size in the range
"a0"@dots{}"a4" or ANSI page size in the range "a"@dots{}"e" may be
specified ("letter" is an alias @w{for "a"} and "tabloid" is an alias
@w{for "b"}).  "legal", "ledger", @w{and "b5"} are recognized page sizes
also.  The environment variable @code{PAGESIZE} can equally well be used
to specify the page size.

For @code{plot -T ai}, @code{plot -T ps}, @code{plot -T pcl}, and
@code{plot -T fig}, the graphics display (or `viewport') within which
the plot is drawn will be, by default, a square region centered on the
specified page.  For @code{plot -T hpgl}, it will be a square region of
the same size, but may be positioned differently.  Either or both of the
dimensions of the graphics display can be specified explicitly.  For
example, @var{pagesize} could be specified as "letter,xsize=4in", or
"a4,xsize=10cm,ysize=15cm".  The dimensions are allowed to be negative
(@w{a negative} dimension results in a reflection).

The position of the graphics display, relative to its default position,
may optionally be adjusted by specifying an offset vector.  For example,
@var{pagesize} could be specified as "letter,yoffset=1.2in", or
"a4,xoffset=@minus{}5mm,yoffset=2.0cm".  @w{It is} also possible to
position the graphics display precisely, by specifying the location of
its lower left corner relative to the lower left corner of the page.
For example, @var{pagesize} could be specified as
"letter,xorigin=2in,yorigin=3in", or "a4,xorigin=0.5cm,yorigin=0.5cm".
The preceding options may be intermingled.  @code{plot -T svg} and
@code{plot -T cgm} ignore the "xoffset", "yoffset", "xorigin", and
"yorigin" options, since SVG format and WebCGM format have no notion of
the Web page on which the graphics display will ultimately be
positioned.  For more on page sizes, see @ref{Page and Viewport Sizes}.
@end table

The following options set the initial values of additional drawing
parameters.  Any of these may be overridden by a directive in the
metafile itself.  @w{In fact}, these options are useful only when
plotting old metafiles in the pre-GNU `plot(5)' format, which did not
include such directives.

@table @samp
@item --bg-color @var{name}
(String, default "white".)  Set the color used for the plot background
to be @var{name}.  This is relevant only to @code{plot @w{-T X}},
@code{plot -T png}, @code{plot -T pnm}, @code{plot -T gif}, @code{plot
-T cgm}, @code{plot -T regis}, and @code{plot -Tmeta}.  @w{An
unrecognized} name sets the color to the default.  For information on
what names are recognized, see @ref{Color Names}.  The environment
variable @code{BG_COLOR} can equally well be used to specify the
background color.

If the @samp{-T png} or @samp{-T gif} option is used, a transparent PNG
file or a transparent pseudo-GIF, respectively, may be produced by
setting the @code{TRANSPARENT_COLOR} environment variable to the name of
the background color.  @xref{plot Environment}.  @w{If the} @samp{-T
svg} or @samp{-T cgm} option is used, an output file without a
background may be produced by setting the background color to "none".

@item -f @var{font_size}
@itemx --font-size @var{font_size}
(Float, initial value device-dependent.)  Set the initial size of the
font used for rendering text, as a fraction of the width of the graphics
display, to @var{font_size}.

@item -F @var{font_name}
@itemx --font-name @var{font_name}
(String, default "Helvetica" except for @code{plot -T pcl}, for which
"Univers" is the default, and @code{plot -T png}, @code{plot -T pnm},
@code{plot -T gif}, @code{plot -T hpgl}, @code{plot -T regis},
@code{plot -T tek}, and raw @code{plot}, for all of which "HersheySerif"
is the default.)  Set the font initially used for text (i.e., for
`labels') to @var{font_name}.  Font names are case-insensitive.  @w{If
the} specified font is not available, the default font will be used.
Which fonts are available depends on which @samp{-T} option is used.
For a list of all fonts, see @ref{Text Fonts}.  The @code{plotfont}
utility will produce a character map of any available font.
@xref{plotfont}.

@item -W @var{line_width}
@itemx --line-width @var{line_width}
(Float, default @minus{}1.0.)  Set the thickness of lines, as a fraction
of the size (i.e., minimum dimension) of the graphics display, to
@var{line_width}.  @w{A negative} value means that the default value
provided by the GNU @code{libplot} graphics library should be used.
This is usually 1/850 times the size of the display, although if
@samp{-T X}, @samp{-T png}, @samp{-T pnm}, or @samp{-T gif} is
specified, it is zero.  By convention, a zero-thickness line is the
thinnest line that can be drawn.  This is the case in all output
formats.  Note, however, that the drawing editors @code{idraw} and
@code{xfig} treat zero-thickness lines as invisible.

@code{plot -T tek} and @code{plot -T regis} do not support drawing lines
with other than a default thickness, and @code{plot -T hpgl} does not
support @w{doing so} if the environment variable @code{HPGL_VERSION} is
set to a value less @w{than "2"} (the default).

@item --pen-color @var{name}
(String, default "black".)  Set the pen color to be @var{name}.  An
unrecognized name sets the pen color to the default.  For information on
what color names are recognized, see @ref{Color Names}.
@end table

The following option is relevant only to raw @code{plot}, i.e., relevant
only if no output type is specified with the @samp{-T} option.  In this
case @code{plot} outputs a graphics metafile, which may be translated to
other formats by a second invocation of @code{plot}.

@table @samp
@item -O
@itemx --portable-output
Output the portable (human-readable) version of GNU metafile format,
rather than a binary version (the default).  This can also be requested
by setting the environment variable @code{META_PORTABLE} to "yes".
@end table

@code{plot} will automatically determine which type of GNU metafile
format the input @w{is in}.  There are two types: binary (the default)
and portable (human-readable).  The binary format is machine-dependent.
@xref{Metafiles}.

For compatibility with older plotting software, the reading of input
files in the pre-GNU `plot(5)' format is also supported.  This is
normally a binary format, with each integer in the metafile represented
as a pair of bytes.  The order of the two bytes is machine dependent.
You may specify that input file(s) are in plot(5) format rather than
ordinary GNU metafile format by using either the @samp{-h} option
(``high byte first'') or the @samp{-l} option (``low byte first''),
whichever is appropriate.  Some non-GNU systems support an ASCII
(human-readable) variant of plot(5) format.  You may specify that the
input is in this format by using the @samp{-A} option.  Irrespective of
the variant, a file in plot(5) format includes only one page of
graphics.

@table @samp
@item -h
@itemx --high-byte-first-input
Input file(s) are assumed to be in traditional `plot(5)' metafile
format, with the high-order byte of each integer occurring first.  This
variant is uncommon.

@item -l
@itemx --low-byte-first-input
Input file(s) are assumed to be in traditional `plot(5)' metafile
format, with the low-order byte of each integer occurring first.  This
variant is the most common.

@item -A
@itemx --ascii-input
Input file(s) are assumed to be in the ASCII variant of traditional
`plot(5)' metafile format.  This variant is rare: on some older systems,
it is produced by a program called @code{plottoa}.
@end table

The following options request information.

@table @samp
@item --help
Print a list of command-line options, and then exit.

@item --help-fonts
Print a table of available fonts, and then exit.  The table will depend
on which display type or output format is specified with the @samp{-T}
option.  @code{plot @w{-T X}}, @code{plot -T svg}, @code{plot -T ai},
@code{plot -T ps}, @code{plot -T cgm}, and @code{plot -T fig} each
support the 35 standard Postscript fonts.  @code{plot -T svg},
@code{plot -T ai}, @code{plot -T pcl}, and @code{plot -T hpgl} support
the 45 standard @w{PCL 5} fonts, and @code{plot -T pcl} and @code{plot
-T hpgl} support a number of Hewlett--Packard vector fonts.  All of the
preceding, together with @code{plot -T png}, @code{plot -T pnm},
@code{plot -T gif}, @code{plot -T regis}, and @code{plot -T tek},
support a set of 22 Hershey vector fonts.  Raw @code{plot} @w{in
principle} supports any of these fonts, since its output must be
translated to other formats with @code{plot}.  The @code{plotfont}
utility will produce a character map of any available font.
@xref{plotfont}.

@item --list-fonts
Like @samp{--help-fonts}, but lists the fonts in a single column to
facilitate piping to other programs.  @w{If no} display type or output
format is specified with the @samp{-T} option, the full set of supported
fonts is listed.

@item --version
Print the version number of @code{plot} and the plotting utilities
package, and exit.
@end table

@node plot Environment, , plot Invocation, plot
@section Environment variables

The behavior of @code{plot} is affected by several environment
variables.  We have already mentioned the environment variables
@code{BITMAPSIZE}, @code{PAGESIZE}, @code{BG_COLOR},
@code{EMULATE_COLOR}, @code{MAX_LINE_LENGTH}, and @code{ROTATION}@.
They serve as backups for the several options @samp{--bitmap-size},
@samp{--page-size}, @samp{--bg-color}, @samp{--emulate-color},
@samp{--max-line-length}, and @samp{--rotation}.  The remaining
environment variables are specific to individual output formats.

@code{plot @w{-T X}}, which pops up a window on an @w{X Window} System
display and draws graphics @w{in it}, checks the @code{DISPLAY}
environment variable.  The value of this variable determines the display
on which the window will be @w{popped up}.

@code{plot -T png} and @code{plot -T gif}, which produce output in PNG
format and pseudo-GIF format respectively, are affected by two
environment variables.  If the value of the @code{INTERLACE} variable is
"yes", the output file will be interlaced.  Also, if the value of the
@code{TRANSPARENT_COLOR} environment variable is the name of a color
that appears in the output file, that color will be treated as
transparent by most applications.  For information on what color names
are recognized, see @ref{Color Names}.

@code{plot -T pnm}, which produces output in Portable Anymap
(PBM/PGM/PPM) format, is affected by the @code{PNM_PORTABLE} environment
variable.  If its value is "yes", the output file will be in the
portable (human readable) version of PBM, PGM, or PPM format, rather
than the default (binary) version.

@code{plot -T cgm}, which produces CGM files that comply with the WebCGM
profile for Web-based vector graphics, is affected by two environment
variables.  By default, a @w{version 3} CGM file is generated.  Many
older CGM interpreters and viewers, such as the ones built into
Microsoft Office and other commercial software, only support @w{version
1} CGM files.  The @code{CGM_MAX_VERSION} environment variable may be
set to "1", "2", "3", @w{or "4"} (the default) to specify a maximum
value for the version number.  The @code{CGM_ENCODING} variable may also
be set, to specify the type of encoding used in the CGM file.  Supported
values are "clear_text" (i.e., human readable) and "binary" (the
default).  The WebCGM profile requires that the binary encoding be used.

@code{plot -T pcl}, which produces @w{PCL 5} output for Hewlett--Packard
printers, is affected by the environment variable
@code{PCL_ASSIGN_COLORS}@.  It should be set to "yes" when producing
@w{PCL 5} output for a color printer or other color device.  This will
ensure accurate color reproduction by giving the output device complete
freedom in assigning colors, internally, to its ``logical pens''.  If it
is "no" then the device will use a fixed set of colored pens, and will
emulate other colors by shading.  The default is "no" because monochrome
@w{PCL 5} devices, which are more common than colored ones, must use
shading to emulate color.

@code{plot -T hpgl}, which produces Hewlett--Packard Graphics Language
output, is also affected by several environment variables.  The most
important is @code{HPGL_VERSION}, which may be set to "1", "1.5", @w{or
"2"} (the default).  @w{"1" means} that the output should be generic
HP-GL, @w{"1.5" means} that the output should be suitable for the
HP7550A graphics plotter and the HP758x, HP7595A and HP7596A drafting
plotters (HP-GL with some HP-GL/2 extensions), and @w{"2" means} that
the output should be modern HP-GL/2.  @w{If the} version is "1" @w{or
"1.5"} then the only available fonts will be vector fonts, and all lines
will be drawn with a default thickness (the @samp{-W} option will not
work).  Additionally, if the version @w{is "1"} then the filling of
arbitrary curves with solid color will not be supported (circles and
rectangles aligned with the coordinate axes may be filled, though).

The position of the @code{plot -T hpgl} graphics display on the page can
be rotated @w{90 degrees} counterclockwise by setting the
@code{HPGL_ROTATE} environment variable to "yes".  This is not the same
as the rotation obtained with the @samp{--rotation} option, since it
both rotates the graphics display and repositions its lower left corner
toward another corner of the page.  Besides "no" and "yes", recognized
values for the @code{HPGL_ROTATE} variable are "0", "90", "180", @w{and
"270"}.  @w{"no" and} "yes" are equivalent to @w{"0" and "90"},
respectively.  "180" and "270" are supported only if @code{HPGL_VERSION}
@w{is "2"} (the default).

@emph{Opaque} filling and the drawing of visible white lines are
supported only if @code{HPGL_VERSION} is "2" (the default) and the
environment variable @code{HPGL_OPAQUE_MODE} is "yes" (the default).
@w{If the} value is "no" then opaque filling will not be used, and white
lines (@w{if any}), which are normally drawn with @w{pen #0}, will not
be drawn.  This feature is to accommodate older HP-GL/2 devices.
HP-GL/2 pen plotters, @w{for example}, do not support opacity or the use
of @w{pen #0} to draw visible white lines.  Some older HP-GL/2 devices
reportedly malfunction if asked to draw opaque objects.

@w{By default}, @code{plot -T hpgl} will draw with a fixed set of pens.
Which pens are present may be specified by setting the @code{HPGL_PENS}
environment variable.  If @code{HPGL_VERSION} @w{is "1"}, the default
value of @code{HPGL_PENS} is "1=black"; if @code{HPGL_VERSION} is
"1.5" @w{or "2"}, the default value of @code{HPGL_PENS} is
"1=black:2=red:3=green:4=yellow:5=blue:6=magenta:7=cyan".  The format
should be self-explanatory.  By setting @code{HPGL_PENS}, you may
specify a color for any pen in the range #1@dots{}#31.  For information
on what color names are recognized, see @ref{Color Names}.  @w{Pen #1}
must always be present, though it need not be black. Any other pen in
the range #1@dots{}#31 may be omitted.

If @code{HPGL_VERSION} is "2" then @code{plot -T hpgl} will also be
affected by the environment variable @code{HPGL_ASSIGN_COLORS}@.  @w{If
the} value of this variable is "yes", then @code{plot -T hpgl} will not
be restricted to the palette specified in @code{HPGL_PENS}: @w{it will}
assign colors to ``logical pens'' in the range #1@dots{}#31, @w{as
needed}.  The default value is "no" because other than color LaserJet
printers and DesignJet plotters, not many HP-GL/2 devices allow the
assignment of colors to logical pens.  In particular, HP-GL/2 pen
plotters do not.

@code{plot -T tek}, which produces output for a Tektronix terminal or
emulator, checks the @code{TERM} environment variable.  @w{If the} value
of @code{TERM} is a string beginning with "xterm", "nxterm", or "kterm",
@w{it is} taken as a sign that @code{plot} is running in an @w{X Window}
System VT100 terminal emulator: @w{an @code{xterm}}, @code{nxterm}, or
@code{kterm}.  Before drawing graphics, @code{plot -T tek} will emit an
escape sequence that causes the terminal emulator's auxiliary Tektronix
window, which is normally hidden, to @w{pop up}.  After the graphics are
drawn, an escape sequence that returns control to the original VT100
window will be emitted.  The Tektronix window will remain on the screen.

If the value of @code{TERM} is a string beginning with "kermit",
"ansi.sys", or "nansi.sys", @w{it is} taken as a sign that @code{plot}
is running in the VT100 terminal emulator provided by the MS-DOS version
of @code{kermit}.  Before drawing graphics, @code{plot -T tek} will emit
an escape sequence that switches the terminal emulator to Tektronix
mode.  Also, some of the Tektronix control codes emitted by @code{plot
-T tek} will be @code{kermit}-specific.  There will be a limited amount
of color support, which is not normally the case (the 16 @code{ansi.sys}
colors will be supported).  After drawing graphics, @code{plot -T tek}
will emit an escape sequence that returns the emulator to VT100 mode.
The key sequence `@w{ALT minus}' can be employed manually within
@code{kermit} to switch between the two modes.

@node pic2plot, tek2plot, plot, Top
@chapter The @code{pic2plot} Program

@menu
* pic2plot Introduction::     What pic2plot is used for
* pic2plot Invocation::       Command-line options
* pic2plot Environment::      Environment variables
@end menu

@node pic2plot Introduction, pic2plot Invocation, pic2plot, pic2plot
@section What @code{pic2plot} is used for

The @code{pic2plot} program takes one or more files in the pic language,
and either displays the figures that they contain on an @w{X Window}
System display, or produces an output file containing the figures.  Many
graphics file formats are supported.

The pic language is a `little language' that was developed at Bell
Laboratories for creating box-and-arrow diagrams of the kind frequently
found in technical papers and textbooks.  @w{A directory} containing
documentation on the pic language is distributed along with the plotting
utilities.  @w{On most} systems it is installed as
@file{/usr/share/pic2plot} or @file{/usr/local/share/pic2plot}.  The
directory includes Brian Kernighan's original technical report on the
language, @w{Eric S.} Raymond's tutorial on the GNU implementation, and
some sample pic macros contributed by the late @w{W. Richard} Stevens.

The pic language was originally designed to work with the @code{troff}
document formatter.  In that context it is read by a translator called
@code{pic}, or its GNU counterpart @code{gpic}.  Since extensive
documentation on @code{pic} and @code{gpic} is available, this section
simply gives an example of an input file, and mentions some extra
features supported by @code{pic2plot}.

A pic file contains one or more figures, each of the box-and-arrow type.
Each figure is begun by a line reading @t{.PS}, and ended by a line
reading @t{.PE}@.  Lines that are not contained in a
@t{.PS}@dots{}@t{.PE} pair are ignored.  @w{Each figure} is built from
geometrical objects, such as rectangular boxes, circles, ellipses,
quarter circles (``arcs''), polygonal lines, and splines.  Arcs,
polygonal lines, and spline may be equipped with arrowheads.  Any object
may be labeled with one or more lines of text.

Objects are usually positioned not by specifying their positions in
absolute coordinates, but rather by specifying their positions relative
to other, previously drawn objects.  The following figure is an example.

@example
.PS
box "START"; arrow; circle dashed filled; arrow
circle diam 2 thickness 3 "This is a" "big, thick" "circle" dashed; up
arrow from top of last circle; ellipse "loopback" dashed
arrow dotted from left of last ellipse to top of last box
arc cw radius 1/2 from top of last ellipse; arrow
box "END"
.PE
@end example

@noindent
If you put this example in a file and run @samp{pic2plot -T X} on the
file, a window containing the figure will be @w{popped up} on your @w{X
display}.  Similarly, if you run @samp{pic2plot -T ps} on the file, a
Postscript file containing the figure will be written to standard
output.  The Postscript file may be edited with the @code{idraw} drawing
editor.  Other graphics formats such as PNG format, PNM format,
pseudo-GIF format, SVG format, WebCGM format, or Fig format (which is
editable with the @code{xfig} drawing editor) may be obtained similarly.
You would use the options @samp{-T png}, @samp{-T pnm}, @samp{-T gif},
@code{samp -T svg}, @samp{-T cgm}, and @samp{-T fig}, respectively.

The above example illustrates some of the features of the pic language.
By default, successive objects are drawn so as to touch each other.  The
drawing proceeds in a certain direction, which at startup is
left-to-right.  The @samp{up} command changes this direction to
bottom-to-top, so that the next object (the arrow extending from the top
of the big circle) will point upward rather than to the right.

Objects have sizes and other attributes, which may be set globally, or
specified on a per-object basis.  For example, the diameter of a circle
may be specified, or the radius of an arc.  @w{An arc} may be oriented
clockwise rather than counterclockwise by specifying the @samp{cw}
attribute.  The line style of most objects may be altered by specifying
the @samp{dashed} or @samp{dotted} attribute.  Also, any object may be
labeled, by specifying one or more text strings as attributes.  @w{A
text} string may contain escape sequences that shift the font, append
subscripts or superscripts, or include non-ASCII characters and
mathematical symbols.  @xref{Text String Format}.

Most sizes and positions are expressed in terms of `virtual inches'.
The use of virtual inches is peculiar to @code{pic2plot}.  The graphics
display used by @code{pic2plot}, i.e., its drawing region, is defined to
be a square, @w{8 virtual} inches wide and @w{8 virtual} inches high.
If the page size for the output file is the "letter" size, which is the
default for Postscript output, virtual inches will the same as real
inches.  But a different page size may be specified; for example, by
using the @samp{--page-size a4} option.  @w{If so}, a virtual inch will
simply equal one-eighth of the width of the graphics display.  @w{On A4}
paper, the graphics display is a square of size 19.81@dmn{}cm.

By default, each figure is centered in the graphics display.  You may
turn off centering, so that you can use absolute coordinates, by using
the @samp{-n} option.  For example, a figure consisting only of the
object @samp{arrow from (8,8) to (4,4)} will be positioned in the
absence of centering so that the head of the arrow is at the center of
the display.  Its tail will be at the upper right corner.

The thickness of lines is not specified in terms of virtual inches.  For
compatibility with @code{gpic}, it is specified in terms of virtual
points.  The example above, which specifies the @samp{thickness}
attribute of one of the objects, illustrates this.  There are @w{72
virtual} points per virtual inch.

If there is more than one figure to be displayed, they will appear in
different @w{X windows}, or on successive pages of the output file.
Some output formats (@w{such as} PNG, PNM, pseudo-GIF, SVG, Illustrator,
and Fig) support only a single page of graphics.  @w{If any} of those
output formats is chosen, only the first figure will appear in the
output file.  Currently, @code{pic2plot} cannot produce animated
pseudo-GIFs.

The preceding survey does not do justice to the pic language, which is
actually a full-featured programming language, with support for
variables, looping constructs, etc.  Its advanced features make the
drawing of large, repetitive diagrams quite easy.

@node pic2plot Invocation, pic2plot Environment, pic2plot Introduction, pic2plot
@section @code{pic2plot} command-line options

The @code{pic2plot} program translates files in the pic language, which
is used for creating box-and-arrow diagrams of the kind frequently found
in technical papers and textbooks, to other graphics formats.  The
output format or display type is specified with the @samp{-T} option.
The possible output formats are the same formats that are supported by
the GNU @code{graph} and @code{plot} programs.

Input file names may be specified anywhere on the command line.  That
is, the relative order of file names and command-line options does not
matter.  If no files are specified, or the file @w{name @samp{-}} is
specified, the standard input is read.  An output file is written to
standard output, unless the @samp{-T X} option is specified.  @w{In
that} case the output is displayed in one or more windows on an @w{X
Window} System display, and there is no output file.

The full set of command-line options is listed below.  There are three
sorts of option:

@enumerate
@item
General options.
@item
Options relevant only to raw @code{pic2plot}, i.e., relevant only if no
display type or output format is specified with the @samp{-T} option.
@item
Options requesting information (e.g., @samp{--help}).
@end enumerate

@noindent
Each option that takes an argument is followed, in parentheses, by the
type and default value of the argument.

The following are general options.

@table @samp
@item -T @var{type}
@itemx --display-type @var{type}
(String, default "meta".)  Select a display type or output format of
type @var{type}, which may be one of the strings "X", "png", "pnm",
"gif", "svg", "ai", "ps", "cgm", "fig", "pcl", "hpgl", "regis", "tek",
and "meta".  These refer respectively to the @w{X Window System}, PNG
format, portable anymap (PBM/PGM/PPM) format, pseudo-GIF format, the new
XML-based Scalable Vector Graphics format, the format used by Adobe
Illustrator, @code{idraw}-editable Postscript, the WebCGM format for
Web-based vector graphics, the format used by the @code{xfig} drawing
editor, the Hewlett--Packard @w{PCL 5} printer language, the
Hewlett--Packard Graphics Language (@w{by default}, HP-GL/2), the ReGIS
(remote graphics instruction set) format developed @w{by DEC}, Tektronix
format, and device-independent GNU graphics metafile format.

@item -d
@itemx --precision-dashing
Draw dashed and dotted lines carefully, i.e., draw each dash and dot as
a separately positioned object.  The default is to use the support for
dashed and dotted lines provided by the underlying graphics library, GNU
@code{libplot}.

This option may produce slightly better-looking dashed and dotted lines.
However, it will come at a price: if an editable output file is produced
(@w{i.e., an} output file in Illustrator, Postscript or Fig format),
@w{it will} be difficulty to modify its dashed and dotted lines with a
drawing editor.

@item -f @var{font_size}
@itemx --font-size @var{font_size}
(Float, default 0.0175.)  Set the size of the font used for rendering
text, as a fraction of the width of the graphics display, to
@var{font_size}.

@item -F @var{font_name}
@itemx --font-name @var{font_name}
(String, default "Helvetica" except for @code{pic2plot -T pcl}, for
which "Univers" is the default, and @code{pic2plot -T png},
@code{pic2plot -T pnm}, @code{pic2plot -T gif}, @code{pic2plot -T hpgl},
@code{pic2plot -T regis}, @code{pic2plot -T tek}, and raw
@code{pic2plot}, for all of which "HersheySerif" is the default.)  Set
the font used for text to @var{font_name}.  Font names are
case-insensitive.  @w{If the} specified font is not available, the
default font will be used.  Which fonts are available depends on which
@samp{-T} option is used.  For a list of all fonts, see @ref{Text
Fonts}.  The @code{plotfont} utility will produce a character map of any
available font.  @xref{plotfont}.

@item -n
@itemx --no-centering
Turn off the automatic centering of each figure.  If this option is
specified, the position of the objects in each figure may be specified
in terms of absolute coordinates.  E.g., @samp{line from (0,0) to (4,4)}
will draw a line segment from the lower left corner to the center of the
graphics display, since the display width and display height are defined
to equal @w{8 virtual} inches.

@item -W @var{line_width}
@itemx --line-width @var{line_width}
(Float, default @minus{}1.0.)  Set the default thickness of lines, as a
fraction of the size (i.e., minimum dimension) of the graphics display,
to @var{line_width}.  @w{A negative} value means that the default value
provided by the GNU @code{libplot} graphics library should be used.
This is usually 1/850 times the size of the display, although if
@samp{-T X}, @samp{-T png}, @samp{-T pnm}, or @samp{-T gif} is
specified, it is zero.  By convention, a zero-thickness line is the
thinnest line that can be drawn.  This is the case in all output
formats.  Note, however, that the drawing editors @code{idraw} and
@code{xfig} treat zero-thickness lines as invisible.

@code{pic2plot -T hpgl} does not support drawing lines with other than a
default thickness if the environment variable @code{HPGL_VERSION} is set
to a value less @w{than "2"} (the default).

@item --bg-color @var{name}
(String, default "white".)  Set the color used for the background to be
@var{name}.  This is relevant only to @code{pic2plot @w{-T X}},
@code{pic2plot -T png}, @code{pic2plot -T pnm}, @code{pic2plot -T gif},
@code{pic2plot -T cgm}, @code{pic2plot -T regis}, and @code{pic2plot -T
meta}.  @w{An unrecognized} name sets the color to the default.  For
information on what names are recognized, see @ref{Color Names}.  The
environment variable @code{BG_COLOR} can equally well be used to specify
the background color.

If the @samp{-T png} or @samp{-T gif} option is used, a transparent PNG
file or a transparent pseudo-GIF, respectively, may be produced by
setting the @code{TRANSPARENT_COLOR} environment variable to the name of
the background color.  @xref{pic2plot Environment}.  @w{If the} @samp{-T
svg} or @samp{-T cgm} option is used, an output file without a
background may be produced by setting the background color to "none".

@item --bitmap-size @var{bitmap_size}
(String, default "570x570".)  Set the size of the graphics display in
which the plot will be drawn, in terms of pixels, to be
@var{bitmap_size}.  This is relevant only to @code{pic2plot @w{-T X}},
@code{pic2plot -T png}, @code{pic2plot -T pnm}, and @code{pic2plot -T
gif}, for all of which the size can be expressed in terms of pixels.
The environment variable @code{BITMAPSIZE} may equally well be used to
specify the size.

The graphics display used by @code{pic2plot -T X} is a popped-up @w{X
window}.  Command-line positioning of this window on an @w{X Window}
System display is supported.  For example, if @var{bitmap_size} is
"570x570+0+0" then the window will be @w{popped up} in the upper left
corner.

If you choose a rectangular (non-square) window size, the fonts in the
plot will be scaled anisotropically, i.e., by different factors in the
horizontal and vertical direction.  For this, @code{pic2plot @w{-T X}}
requires an X11R6 display.  Any font that cannot be anisotropically
scaled will be replaced by a default scalable font, such as the Hershey
vector font "HersheySerif".

For backward compatibility, @code{pic2plot -T X} allows the user to set
the window size and position by setting the @w{X resource}
@code{Xplot.geometry}, instead of @samp{--bitmap-size} or
@code{BITMAPSIZE}@.

@item --emulate-color @var{option}
(String, default "no".)  If @var{option} is "yes", replace each color in
the output by an appropriate shade of gray.  This is seldom useful,
except when using @samp{pic2plot -T pcl} to prepare output for a @w{PCL
5} device.  (Many monochrome @w{PCL 5} devices, such as monochrome
LaserJets, do a poor job of emulating color on their own.  They usually
map HP-GL/2's seven standard pen colors, including even yellow, to
black.)  You may equally well request color emulation by setting the
environment variable @code{EMULATE_COLOR} to "yes".

@item --max-line-length @var{max_line_length}
(Integer, default 500.)  Set the maximum number of points that a
polygonal line may contain, before it is flushed to the output device,
to equal @var{max_line_length}.  If this flushing occurs, the polygonal
line will be split into two or more sub-lines, though the splitting
should not be noticeable.

The reason for splitting long polygonal lines is that some display
devices (e.g., old Postscript printers and HP-GL pen plotters) have
limited buffer sizes.  The environment variable @code{MAX_LINE_LENGTH}
can also be used to specify the maximum line length.  This option has no
effect on raw @code{pic2plot}, since it draws polylines in real time and
has no buffer limitations.

@item --page-size @var{pagesize}
(String, default "letter".)  Set the size of the page on which the plot
will be positioned.  This is relevant only to @code{pic2plot -T svg},
@code{pic2plot -T ai}, @code{pic2plot -T ps}, @code{pic2plot -T cgm},
@code{pic2plot -T fig}, @code{pic2plot -T pcl}, and @code{pic2plot
@w{-T} hpgl}.  "letter" means an 8.5@dmn{in} by 11@dmn{in} page.  Any
ISO page size in the range "a0"@dots{}"a4" or ANSI page size in the
range "a"@dots{}"e" may be specified ("letter" is an alias @w{for "a"}
and "tabloid" is an alias @w{for "b"}).  "legal", "ledger", @w{and "b5"}
are recognized page sizes also.  The environment variable
@code{PAGESIZE} can equally well be used to specify the page size.

For @code{pic2plot -T ai}, @code{pic2plot -T ps}, @code{pic2plot -T
pcl}, and @code{pic2plot -T fig}, the graphics display (or `viewport')
within which the plot is drawn will be, by default, a square region
centered on the specified page.  For @code{pic2plot -T hpgl}, it will be
a square region of the same size, but may be positioned differently.
Either or both of the dimensions of the graphics display can be
specified explicitly.  For example, @var{pagesize} could be specified as
"letter,xsize=4in", or "a4,xsize=10cm,ysize=15cm".  The dimensions are
allowed to be negative (@w{a negative} dimension results in a
reflection).

The position of the graphics display, relative to its default position,
may optionally be adjusted by specifying an offset vector.  For example,
@var{pagesize} could be specified as "letter,yoffset=1.2in", or
"a4,xoffset=@minus{}5mm,yoffset=2.0cm".  @w{It is} also possible to
position the graphics display precisely, by specifying the location of
its lower left corner relative to the lower left corner of the page.
For example, @var{pagesize} could be specified as
"letter,xorigin=2in,yorigin=3in", or "a4,xorigin=0.5cm,yorigin=0.5cm".
The preceding options may be intermingled.  @code{pic2plot -T svg} and
@code{pic2plot -T cgm} ignore the "xoffset", "yoffset", "xorigin", and
"yorigin" options, since SVG format and WebCGM format have no notion of
the Web page on which the graphics display will ultimately be
positioned.  For more on page sizes, see @ref{Page and Viewport Sizes}.

@item --pen-color @var{name}
(String, default "black".)  Set the pen color to be @var{name}.  An
unrecognized name sets the pen color to the default.  For information on
what color names are recognized, see @ref{Color Names}.

@item --rotation @var{angle}
(Integer, default 0.)  Set the rotation angle of the graphics display to
be @var{angle} degrees.  Recognized values are @w{0, 90}, 180, @w{and
270}.  The rotation is counterclockwise.  The environment variable
@code{ROTATION} can equally well be used to specify the rotation angle.

This option is used for switching between portrait and landscape
orientations.  Postmodernists may also find it useful.
@end table

The following option is relevant only to raw @code{pic2plot}, i.e.,
relevant only if no display type or output format is specified with the
@samp{-T} option.  In this case @code{pic2plot} outputs a graphics
metafile, which may be translated to other formats by invoking
@code{plot}.

@table @samp
@item -O
@itemx --portable-output
Output the portable (human-readable) version of GNU metafile format,
rather than a binary version (the default).  This can also be requested
by setting the environment variable @code{META_PORTABLE} to "yes".
@end table

The following options request information.

@table @samp
@item --help
Print a list of command-line options, and then exit.

@item --help-fonts
Print a table of available fonts, and then exit.  The table will depend
on which display type or output format is specified with the @samp{-T}
option.  @code{pic2plot @w{-T X}}, @code{pic2plot -T svg},
@code{pic2plot -T ai}, @code{pic2plot -T ps}, @code{pic2plot -T cgm},
and @code{pic2plot -T fig} each support the 35 standard Postscript
fonts.  @code{pic2plot -T svg}, @code{pic2plot -T ai}, @code{pic2plot -T
pcl}, and @code{pic2plot -T hpgl} support the 45 standard @w{PCL 5}
fonts, and @code{pic2plot -T pcl} and @code{pic2plot -T hpgl} support a
number of Hewlett--Packard vector fonts.  All of the preceding, together
with @code{pic2plot -T png}, @code{pic2plot -T pnm}, @code{pic2plot -T
gif}, @code{pic2plot -T regis}, and @code{pic2plot -T tek}, support a
set of 22 Hershey vector fonts.  Raw @code{pic2plot} @w{in principle}
supports any of these fonts, since its output must be translated to
other formats with @code{plot}.  The @code{plotfont} utility will
produce a character map of any available font.  @xref{plotfont}.

@item --list-fonts
Like @samp{--help-fonts}, but lists the fonts in a single column to
facilitate piping to other programs.  @w{If no} display type or output
format is specified with the @samp{-T} option, the full set of supported
fonts is listed.

@item --version
Print the version number of @code{pic2plot} and the plotting utilities
package, and exit.
@end table

@node pic2plot Environment, , pic2plot Invocation, pic2plot
@section Environment variables

The behavior of @code{pic2plot} is affected by several environment
variables.  We have already mentioned the environment variables
@code{BITMAPSIZE}, @code{PAGESIZE}, @code{BG_COLOR},
@code{EMULATE_COLOR}, @code{MAX_LINE_LENGTH}, and @code{ROTATION}@.
They serve as backups for the several options @samp{--bitmap-size},
@samp{--page-size}, @samp{--bg-color}, @samp{--emulate-color},
@samp{--max-line-length}, and @samp{--rotation}.  The remaining
environment variables are specific to individual output formats.

@code{pic2plot @w{-T X}}, which pops up a window on an @w{X Window}
System display for each figure, checks the @code{DISPLAY} environment
variable.  The value of this variable determines the display on which
the windows will be @w{popped up}.

@code{pic2plot -T png} and @code{pic2plot -T gif}, which produce output
in PNG format and pseudo-GIF format respectively, are affected by two
environment variables.  If the value of the @code{INTERLACE} variable is
"yes", the output file will be interlaced.  Also, if the value of the
@code{TRANSPARENT_COLOR} environment variable is the name of a color
that appears in the output file, that color will be treated as
transparent by most applications.  For information on what color names
are recognized, see @ref{Color Names}.

@code{pic2plot -T pnm}, which produces output in Portable Anymap
(PBM/PGM/PPM) format, is affected by the @code{PNM_PORTABLE} environment
variable.  If its value is "yes", the output file will be in the
portable (human readable) version of PBM, PGM, or PPM format, rather
than the default (binary) version.

@code{pic2plot -T cgm}, which produces CGM files that comply with the
WebCGM profile for Web-based vector graphics, is affected by two
environment variables.  By default, a @w{version 3} CGM file is
generated.  Many older CGM interpreters and viewers, such as the ones
built into Microsoft Office and other commercial software, only support
@w{version 1} CGM files.  The @code{CGM_MAX_VERSION} environment
variable may be set to "1", "2", "3", @w{or "4"} (the default) to
specify a maximum value for the version number.  The @code{CGM_ENCODING}
variable may also be set, to specify the type of encoding used in the
CGM file.  Supported values are "clear_text" (i.e., human readable) and
"binary" (the default).  The WebCGM profile requires that the binary
encoding be used.

@code{pic2plot -T pcl}, which produces @w{PCL 5} output for
Hewlett--Packard printers, is affected by the environment variable
@code{PCL_ASSIGN_COLORS}@.  It should be set to "yes" when producing
@w{PCL 5} output for a color printer or other color device.  This will
ensure accurate color reproduction by giving the output device complete
freedom in assigning colors, internally, to its ``logical pens''.  If it
is "no" then the device will use a fixed set of colored pens, and will
emulate other colors by shading.  The default is "no" because monochrome
@w{PCL 5} devices, which are more common than colored ones, must use
shading to emulate color.

@code{pic2plot -T hpgl}, which produces Hewlett--Packard Graphics
Language output, is also affected by several environment variables.  The
most important is @code{HPGL_VERSION}, which may be set to "1", "1.5",
@w{or "2"} (the default).  @w{"1" means} that the output should be
generic HP-GL, @w{"1.5" means} that the output should be suitable for
the HP7550A graphics plotter and the HP758x, HP7595A and HP7596A
drafting plotters (HP-GL with some HP-GL/2 extensions), and @w{"2"
means} that the output should be modern HP-GL/2.  @w{If the} version is
"1" @w{or "1.5"} then the only available fonts will be vector fonts, and
all lines will be drawn with a default thickness (the @samp{-W} option
will not work).  Additionally, if the version @w{is "1"} then the
filling of arbitrary curves with solid color will not be supported
(circles and rectangles aligned with the coordinate axes may be filled,
though).

The position of the @code{pic2plot -T hpgl} graphics display on the page
can be rotated @w{90 degrees} counterclockwise by setting the
@code{HPGL_ROTATE} environment variable to "yes".  This is not the same
as the rotation obtained with the @samp{--rotation} option, since it
both rotates the graphics display and repositions its lower left corner
toward another corner of the page.  Besides "no" and "yes", recognized
values for the @code{HPGL_ROTATE} variable are "0", "90", "180", @w{and
"270"}.  @w{"no" and} "yes" are equivalent to @w{"0" and "90"},
respectively.  "180" and "270" are supported only if @code{HPGL_VERSION}
@w{is "2"} (the default).

@emph{Opaque} filling and the drawing of visible white lines are
supported only if @code{HPGL_VERSION} is "2" (the default) and the
environment variable @code{HPGL_OPAQUE_MODE} is "yes" (the default).
@w{If the} value is "no" then opaque filling will not be used, and white
lines (@w{if any}), which are normally drawn with @w{pen #0}, will not
be drawn.  This feature is to accommodate older HP-GL/2 devices.
HP-GL/2 pen plotters, @w{for example}, do not support opacity or the use
of @w{pen #0} to draw visible white lines.  Some older HP-GL/2 devices
reportedly malfunction if asked to draw opaque objects.

@w{By default}, @code{pic2plot -T hpgl} will draw with a fixed set of
pens.  Which pens are present may be specified by setting the
@code{HPGL_PENS} environment variable.  If @code{HPGL_VERSION} @w{is
"1"}, the default value of @code{HPGL_PENS} is "1=black"; if
@code{HPGL_VERSION} is "1.5" @w{or "2"}, the default value of
@code{HPGL_PENS} is
"1=black:2=red:3=green:4=yellow:5=blue:6=magenta:7=cyan".  The format
should be self-explanatory.  By setting @code{HPGL_PENS}, you may
specify a color for any pen in the range #1@dots{}#31.  For information
on what color names are recognized, see @ref{Color Names}.  @w{Pen #1}
must always be present, though it need not be black. Any other pen in
the range #1@dots{}#31 may be omitted.

If @code{HPGL_VERSION} is "2" then @code{pic2plot -T hpgl} will also be
affected by the environment variable @code{HPGL_ASSIGN_COLORS}@.  @w{If
the} value of this variable is "yes", then @code{plot -T hpgl} will not
be restricted to the palette specified in @code{HPGL_PENS}: @w{it will}
assign colors to ``logical pens'' in the range #1@dots{}#31, @w{as
needed}.  The default value is "no" because other than color LaserJet
printers and DesignJet plotters, not many HP-GL/2 devices allow the
assignment of colors to logical pens.  In particular, HP-GL/2 pen
plotters do not.

@code{pic2plot -T tek}, which produces output for a Tektronix terminal
or emulator, checks the @code{TERM} environment variable.  @w{If the}
value of @code{TERM} is a string beginning with "xterm", "nxterm", or
"kterm", @w{it is} taken as a sign that @code{pic2plot} is running in an
@w{X Window} System VT100 terminal emulator: @w{an @code{xterm}},
@code{nxterm}, or @code{kterm}.  Before drawing graphics, @code{pic2plot
-T tek} will emit an escape sequence that causes the terminal emulator's
auxiliary Tektronix window, which is normally hidden, to @w{pop up}.
After the graphics are drawn, an escape sequence that returns control to
the original VT100 window will be emitted.  The Tektronix window will
remain on the screen.

If the value of @code{TERM} is a string beginning with "kermit",
"ansi.sys", or "nansi.sys", @w{it is} taken as a sign that
@code{pic2plot} is running in the VT100 terminal emulator provided by
the MS-DOS version of @code{kermit}.  Before drawing graphics,
@code{pic2plot -T tek} will emit an escape sequence that switches the
terminal emulator to Tektronix mode.  Also, some of the Tektronix
control codes emitted by @code{pic2plot -T tek} will be
@code{kermit}-specific.  There will be a limited amount of color
support, which is not normally the case (the 16 @code{ansi.sys} colors
will be supported).  After drawing graphics, @code{pic2plot -T tek} will
emit an escape sequence that returns the emulator to VT100 mode.  The
key sequence `@w{ALT minus}' can be employed manually within
@code{kermit} to switch between the two modes.

@node tek2plot, plotfont, pic2plot, Top
@chapter The @code{tek2plot} Program

@menu
* tek2plot Introduction::     What tek2plot is used for
* tek2plot Invocation::       Command-line options
* tek2plot Environment::      Environment variables
@end menu

@node tek2plot Introduction, tek2plot Invocation, tek2plot, tek2plot
@section What @code{tek2plot} is used for

GNU @code{tek2plot} is a command-line Tektronix translator.  It displays
Tektronix graphics files, or translates them to other formats.  The
@samp{-T} option is used to specify the output format or display type.
Supported output formats include "X", "png", "pnm", "gif", "svg", "ai",
"ps", "cgm", "fig", "pcl", "hpgl", "regis", "tek", and "meta" (the
default).  These are the same formats that are supported by the GNU
@code{graph}, @code{plot}, and @code{pic2plot} programs.
@code{tek2plot} will take input from a file specified on the command
line or from standard input, just as the plot filter @code{plot} does.

Tektronix graphics files are produced by many older applications, such
as @uref{http://tdc-www.harvard.edu/software/skymap, SKYMAP}, a powerful
astronomical display program.  @w{A directory} containing sample
Tektronix graphics files, which you may experiment with, is distributed
along with the GNU plotting utilities.  @w{On most} systems it is
installed as @file{/usr/share/tek2plot} or
@file{/usr/local/share/tek2plot}.

Tektronix graphics format is defined as a noninteractive version of the
graphics format understood by Tektronix 4010/4014 terminals, as
documented in the @cite{4014 Service Manual}, Tektronix Inc., 1974
(Tektronix Part #070-1648-00).  @code{tek2plot} does not support
interactive features such as graphics input mode (``GIN mode'') or
status enquiry.  However, it does support a few additional features
provided by popular Tektronix emulators, such as the color extensions
supported by the Tektronix emulator contained in the MS-DOS version of
@code{kermit}.

@node tek2plot Invocation, tek2plot Environment, tek2plot Introduction, tek2plot
@section @code{tek2plot} command-line options

The @code{tek2plot} program translates the Tektronix graphics files
produced by many older applications to other formats.  The output format
or display type is specified with the @samp{-T} option.  The possible
output formats are the same formats that are supported by the GNU
@code{graph}, @code{plot}, and @code{pic2plot} programs.

Input file names may be specified anywhere on the command line.  That
is, the relative order of file names and command-line options does not
matter.  If no files are specified, or the file @w{name @samp{-}} is
specified, the standard input is read.  An output file is written to
standard output, unless the @samp{-T X} option is specified.  @w{In
that} case the output is displayed in one or more windows on an @w{X
Window} System display, and there is no output file.

The full set of command-line options is listed below.  There are three
sorts of option:

@enumerate
@item
General options.
@item
Options relevant only to raw @code{tek2plot}, i.e., relevant only if no
display type or output format is specified with the @samp{-T} option.
@item
Options requesting information (e.g., @samp{--help}).
@end enumerate

@noindent
Each option that takes an argument is followed, in parentheses, by the
type and default value of the argument.

The following are general options.

@table @samp
@item -T @var{type}
@itemx --display-type @var{type}
(String, default "meta".)  Select a display type or output format of
type @var{type}, which may be one of the strings "X", "png", "pnm",
"gif", "svg", "ai", "ps", "cgm", "fig", "pcl", "hpgl", "regis", "tek",
and "meta".  These refer respectively to the @w{X Window System}, PNG
format, portable anymap (PBM/PGM/PPM) format, pseudo-GIF format, the new
XML-based Scalable Vector Graphics format, the format used by Adobe
Illustrator, @code{idraw}-editable Postscript, the WebCGM format for
Web-based vector graphics, the format used by the @code{xfig} drawing
editor, the Hewlett--Packard @w{PCL 5} printer language, the
Hewlett--Packard Graphics Language (@w{by default}, HP-GL/2), the ReGIS
(remote graphics instruction set) format developed @w{by DEC}, Tektronix
format, and device-independent GNU graphics metafile format.

@item -p @var{n}
@itemx --page-number @var{n}
(Nonnegative integer.) Display only page number @var{n}, within the
Tektronix file or sequence of Tektronix files that is being translated.
Tektronix files may consist of one or more pages, numbered beginning
with zero.

The default behavior, if the @samp{-p} option is not used, is to display
all nonempty pages in succession.  For example, @code{tek2plot @w{-T X}}
displays each page in its own @w{X window}.  @w{If the} @samp{-T png}
option, the @samp{-T pnm} option, the @samp{-T gif} option, the @samp{-T
svg} option, the @samp{-T ai} option, or the @samp{-T fig} option is
used, the default behavior is to display only the first page, since
files in PNG, PNM, pseudo-GIF, SVG, AI, or Fig format may contain only a
single page of graphics.

Most Tektronix files consist of either one page (page #0) or
two pages (@w{an empty} @w{page #0}, and @w{page #1}).  Tektronix files
produced by the GNU plotting utilities (e.g., by @code{graph -T tek})
are normally of the latter sort.

@item -F @var{font_name}
@itemx --font-name @var{font_name}
(String, default "Courier" except for @code{tek2plot -T png},
@code{tek2plot -T pnm}, @code{tek2plot -T gif}, @code{tek2plot -T hpgl},
@code{tek2plot -T regis}, and raw @code{tek2plot}, for all of which
"HersheySerif" is the default.)  Set the font used for text to
@var{font_name}.  Font names are case-insensitive.  @w{If a} font
outside the Courier family is chosen, the @samp{--position-chars} option
(see below) should probably be used.  For a list of all fonts, see
@ref{Text Fonts}.  @w{If the} specified font is not available, the
default font will be used.

If you intend to print a @w{PCL 5} file prepared with @code{tek2plot -T
pcl} on a LaserJet III, you should specify a font other than Courier.
That is because the LaserJet III, which was Hewlett--Packard's first
@w{PCL 5} printer, did not come with a scalable Courier typeface.  The
only @w{PCL 5} fonts it supported were the eight fonts in the CGTimes
and Univers families.  See @ref{Text Fonts}.

@item -W @var{line_width}
@itemx --line-width @var{line_width}
(Float, default @minus{}1.0.)  Set the thickness of lines, as a fraction
of the size (i.e., minimum dimension) of the graphics display, to
@var{line_width}.  @w{A negative} value means that the default value
provided by the GNU @code{libplot} graphics library should be used.
This is usually 1/850 times the size of the display, although if
@samp{-T X}, @samp{-T png}, @samp{-T pnm}, or @samp{-T gif} is
specified, it is zero.  By convention, a zero-thickness line is the
thinnest line that can be drawn.  This is the case in all output
formats.  Note, however, that the drawing editors @code{idraw} and
@code{xfig} treat zero-thickness lines as invisible.

@code{tek2plot -T regis} does not support drawing lines with other than
a default thickness, and @code{tek2plot -T hpgl} does not support doing
so if the environment variable @code{HPGL_VERSION} is set to a value
less @w{than "2"} (the default).

@item --bg-color @var{name}
(String, default "white".)  Set the color used for the background to be
@var{name}.  This is relevant only to @code{tek2plot @w{-T X}},
@code{tek2plot -T png}, @code{tek2plot -T pnm}, @code{tek2plot -T gif},
@code{tek2plot -T cgm}, @code{tek2plot -T regis}, and @code{tek2plot -T
meta}.  @w{An unrecognized} name sets the color to the default.  For
information on what names are recognized, see @ref{Color Names}.  The
environment variable @code{BG_COLOR} can equally well be used to specify
the background color.

If the @samp{-T png} or @samp{-T gif} option is used, a transparent PNG
file or a transparent pseudo-GIF, respectively, may be produced by
setting the @code{TRANSPARENT_COLOR} environment variable to the name of
the background color.  @xref{tek2plot Environment}.  @w{If the} @samp{-T
svg} or @samp{-T cgm} option is used, an output file without a
background may be produced by setting the background color to "none".

@item --bitmap-size @var{bitmap_size}
(String, default "570x570".)  Set the size of the graphics display in
which the plot will be drawn, in terms of pixels, to be
@var{bitmap_size}.  This is relevant only to @code{tek2plot @w{-T X}},
@code{tek2plot -T png}, @code{tek2plot -T pnm}, and @code{tek2plot -T
gif}, for all of which the size can be expressed in terms of pixels.
The environment variable @code{BITMAPSIZE} may equally well be used to
specify the size.

The graphics display used by @code{tek2plot -T X} is a popped-up @w{X
window}.  Command-line positioning of this window on an @w{X Window}
System display is supported.  For example, if @var{bitmap_size} is
"570x570+0+0" then the window will be @w{popped up} in the upper left
corner.

If you choose a rectangular (non-square) window size, the fonts in the
plot will be scaled anisotropically, i.e., by different factors in the
horizontal and vertical direction.  For this, @code{tek2plot @w{-T X}}
requires an X11R6 display.  Any font that cannot be anisotropically
scaled will be replaced by a default scalable font, such as the Hershey
vector font "HersheySerif".

For backward compatibility, @code{tek2plot -T X} allows the user to set
the window size and position by setting the @w{X resource}
@code{Xplot.geometry}, instead of @samp{--bitmap-size} or
@code{BITMAPSIZE}@.

@item --emulate-color @var{option}
(String, default "no".)  If @var{option} is "yes", replace each color in
the output by an appropriate shade of gray.  This is seldom useful,
except when using @samp{tek2plot -T pcl} to prepare output for a @w{PCL
5} device.  (Many monochrome @w{PCL 5} devices, such as monochrome
LaserJets, do a poor job of emulating color on their own.  They usually
map HP-GL/2's seven standard pen colors, including even yellow, to
black.)  You may equally well request color emulation by setting the
environment variable @code{EMULATE_COLOR} to "yes".

@item --max-line-length @var{max_line_length}
(Integer, default 500.)  Set the maximum number of points that a
polygonal line may contain, before it is flushed to the output device,
to equal @var{max_line_length}.  If this flushing occurs, the polygonal
line will be split into two or more sub-lines, though the splitting
should not be noticeable.

The reason for splitting long polygonal lines is that some display
devices (e.g., old Postscript printers and HP-GL pen plotters) have
limited buffer sizes.  The environment variable @code{MAX_LINE_LENGTH}
can also be used to specify the maximum line length.  This option has no
effect on raw @code{tek2plot}, since it draws polylines in real time and
has no buffer limitations.

@item --page-size @var{pagesize}
(String, default "letter".)  Set the size of the page on which the plot
will be positioned.  This is relevant only to @code{tek2plot -T svg},
@code{tek2plot -T ai}, @code{tek2plot -T ps}, @code{tek2plot -T cgm},
@code{tek2plot -T fig}, @code{tek2plot -T pcl}, and @code{tek2plot
@w{-T} hpgl}.  "letter" means an 8.5@dmn{in} by 11@dmn{in} page.  Any
ISO page size in the range "a0"@dots{}"a4" or ANSI page size in the
range "a"@dots{}"e" may be specified ("letter" is an alias @w{for "a"}
and "tabloid" is an alias @w{for "b"}).  "legal", "ledger", @w{and "b5"}
are recognized page sizes also.  The environment variable
@code{PAGESIZE} can equally well be used to specify the page size.

For @code{tek2plot -T ai}, @code{tek2plot -T ps}, @code{tek2plot -T
pcl}, and @code{tek2plot -T fig}, the graphics display (or `viewport')
within which the plot is drawn will be, by default, a square region
centered on the specified page.  For @code{tek2plot -T hpgl}, it will be
a square region of the same size, but may be positioned differently.
Either or both of the dimensions of the graphics display can be
specified explicitly.  For example, @var{pagesize} could be specified as
"letter,xsize=4in", or "a4,xsize=10cm,ysize=15cm".  The dimensions are
allowed to be negative (@w{a negative} dimension results in a
reflection).

The position of the graphics display, relative to its default position,
may optionally be adjusted by specifying an offset vector.  For example,
@var{pagesize} could be specified as "letter,yoffset=1.2in", or
"a4,xoffset=@minus{}5mm,yoffset=2.0cm".  @w{It is} also possible to
position the graphics display precisely, by specifying the location of
its lower left corner relative to the lower left corner of the page.
For example, @var{pagesize} could be specified as
"letter,xorigin=2in,yorigin=3in", or "a4,xorigin=0.5cm,yorigin=0.5cm".
The preceding options may be intermingled.  @code{tek2plot -T svg} and
@code{tek2plot -T cgm} ignore the "xoffset", "yoffset", "xorigin", and
"yorigin" options, since SVG format and WebCGM format have no notion of
the Web page on which the graphics display will ultimately be
positioned.  For more on page sizes, see @ref{Page and Viewport Sizes}.

@item --pen-color @var{name}
(String, default "black".)  Set the pen color to be @var{name}.  An
unrecognized name sets the pen color to the default.  For information on
what color names are recognized, see @ref{Color Names}.

@item --position-chars
Position the characters in each text string individually on the display.
@w{If the} text font is not a member of the Courier family, and
especially if it is not a fixed-width font, this option is recommended.
@w{It will} improve the appearance of text strings, at the price of
making it difficult to edit the output file with @code{xfig} or
@code{idraw}.

@item --rotation @var{angle}
(Integer, default 0.)  Set the rotation angle of the graphics display to
be @var{angle} degrees.  Recognized values are @w{0, 90}, 180, @w{and
270}.  The rotation is counterclockwise.  The environment variable
@code{ROTATION} can equally well be used to specify the rotation angle.

This option is used for switching between portrait and landscape
orientations.  Postmodernists may also find it useful.

@item --use-tek-fonts
Use the bitmap fonts that were used on the original Tektronix 4010/4014
terminal.  This option is relevant only to @code{tek2plot @w{-T X}}.
The four relevant bitmap fonts are distributed with most versions of the
plotting utilities package, under the names
@code{tekfont0}@dots{}@code{tekfont3}.  They may easily be installed on
any modern @w{X Window} System display.  For this option to work
properly, you must also select a window size of 1024x1024 pixels, either
by using the @samp{--bitmap-size 1024x1024} option or by setting the
value of the @code{Xplot.geometry} resource.  The reason for this
restriction is that bitmap fonts, unlike the scalable fonts that the
plotting utilities normally use, cannot be rescaled.

This option is useful only if you have a file in Tektronix format that
draws text using native Tektronix fonts.  Tektronix files produced by
the GNU plotting utilities (e.g., by @code{graph -T tek}) @w{do not} use
native Tektronix fonts to draw text.
@end table

The following option is relevant only to raw @code{tek2plot}, i.e.,
relevant only if no display type or output format is specified with the
@samp{-T} option.  In this case @code{tek2plot} outputs a graphics
metafile, which may be translated to other formats by invoking
@code{plot}.

@table @samp
@item -O
@itemx --portable-output
Output the portable (human-readable) version of GNU metafile format,
rather than a binary version (the default).  This can also be requested
by setting the environment variable @code{META_PORTABLE} to "yes".
@end table

The following options request information.

@table @samp
@item --help
Print a list of command-line options, and then exit.

@item --help-fonts
Print a table of available fonts, and then exit.  The table will depend
on which display type or output format is specified with the @samp{-T}
option.  @code{tek2plot @w{-T X}}, @code{tek2plot -T svg},
@code{tek2plot -T ai}, @code{tek2plot -T ps}, @code{tek2plot -T cgm},
and @code{tek2plot -T fig} each support the 35 standard Postscript
fonts.  @code{tek2plot -T svg}, @code{tek2plot -T ai}, @code{tek2plot -T
pcl}, and @code{tek2plot -T hpgl} support the 45 standard @w{PCL 5}
fonts, and @code{tek2plot -T pcl} and @code{tek2plot -T hpgl} support a
number of Hewlett--Packard vector fonts.  All of the preceding, together
with @code{tek2plot -T png}, @code{tek2plot -T pnm}, @code{tek2plot -T
gif}, @code{tek2plot -T regis}, and @code{tek2plot -T tek}, support a
set of 22 Hershey vector fonts.  Raw @code{tek2plot} @w{in principle}
supports any of these fonts, since its output must be translated to
other formats with @code{plot}.  The @code{plotfont} utility will
produce a character map of any available font.  @xref{plotfont}.

@item --list-fonts
Like @samp{--help-fonts}, but lists the fonts in a single column to
facilitate piping to other programs.  @w{If no} display type or output
format is specified with the @samp{-T} option, the full set of supported
fonts is listed.

@item --version
Print the version number of @code{tek2plot} and the plotting utilities
package, and exit.
@end table

@node tek2plot Environment, , tek2plot Invocation, tek2plot
@section Environment variables

The behavior of @code{tek2plot} is affected by several environment
variables, which are the same as those that affect @code{graph} and
@code{plot}.  For convenience, we list them here.

We have already mentioned the environment variables @code{BITMAPSIZE},
@code{PAGESIZE}, @code{BG_COLOR}, @code{EMULATE_COLOR},
@code{MAX_LINE_LENGTH}, and @code{ROTATION}@.  They serve as backups for
the several options @samp{--bitmap-size}, @samp{--page-size},
@samp{--bg-color}, @samp{--emulate-color}, @samp{--max-line-length}, and
@samp{--rotation}.  The remaining environment variables are specific to
individual output formats.

@code{tek2plot @w{-T X}}, which pops up a window on an @w{X Window}
System display and draws graphics @w{in it}, checks the @code{DISPLAY}
environment variable.  The value of this variable determines the display
on which the window will be @w{popped up}.

@code{tek2plot -T png} and @code{tek2plot -T gif}, which produce output
in PNG format and pseudo-GIF format respectively, are affected by two
environment variables.  If the value of the @code{INTERLACE} variable is
"yes", the output file will be interlaced.  Also, if the value of the
@code{TRANSPARENT_COLOR} environment variable is the name of a color
that appears in the output file, that color will be treated as
transparent by most applications.  For information on what color names
are recognized, see @ref{Color Names}.

@code{tek2plot -T pnm}, which produces output in Portable Anymap
(PBM/PGM/PPM) format, is affected by the @code{PNM_PORTABLE} environment
variable.  If its value is "yes", the output file will be in the
portable (human readable) version of PBM, PGM, or PPM format, rather
than the default (binary) version.

@code{tek2plot -T cgm}, which produces CGM files that comply with the
WebCGM profile for Web-based vector graphics, is affected by two
environment variables.  By default, a @w{version 3} CGM file is
generated.  Many older CGM interpreters and viewers, such as the ones
built into Microsoft Office and other commercial software, only support
@w{version 1} CGM files.  The @code{CGM_MAX_VERSION} environment
variable may be set to "1", "2", "3", @w{or "4"} (the default) to
specify a maximum value for the version number.  The @code{CGM_ENCODING}
variable may also be set, to specify the type of encoding used in the
CGM file.  Supported values are "clear_text" (i.e., human readable) and
"binary" (the default).  The WebCGM profile requires that the binary
encoding be used.

@code{tek2plot -T pcl}, which produces @w{PCL 5} output for
Hewlett--Packard printers, is affected by the environment variable
@code{PCL_ASSIGN_COLORS}@.  It should be set to "yes" when producing
@w{PCL 5} output for a color printer or other color device.  This will
ensure accurate color reproduction by giving the output device complete
freedom in assigning colors, internally, to its ``logical pens''.  If it
is "no" then the device will use a fixed set of colored pens, and will
emulate other colors by shading.  The default is "no" because monochrome
@w{PCL 5} devices, which are more common than colored ones, must use
shading to emulate color.

@code{tek2plot -T hpgl}, which produces Hewlett--Packard Graphics
Language output, is also affected by several environment variables.  The
most important is @code{HPGL_VERSION}, which may be set to "1", "1.5",
@w{or "2"} (the default).  @w{"1" means} that the output should be
generic HP-GL, @w{"1.5" means} that the output should be suitable for
the HP7550A graphics plotter and the HP758x, HP7595A and HP7596A
drafting plotters (HP-GL with some HP-GL/2 extensions), and @w{"2"
means} that the output should be modern HP-GL/2.  @w{If the} version is
"1" @w{or "1.5"} then the only available fonts will be vector fonts, and
all lines will be drawn with a default thickness (the @samp{-W} option
will not work).

The position of the @code{tek2plot -T hpgl} graphics display on the page
can be rotated @w{90 degrees} counterclockwise by setting the
@code{HPGL_ROTATE} environment variable to "yes".  This is not the same
as the rotation obtained with the @samp{--rotation} option, since it
both rotates the graphics display and repositions its lower left corner
toward another corner of the page.  Besides "no" and "yes", recognized
values for the @code{HPGL_ROTATE} variable are "0", "90", "180", @w{and
"270"}.  @w{"no" and} "yes" are equivalent to @w{"0" and "90"},
respectively.  "180" and "270" are supported only if @code{HPGL_VERSION}
@w{is "2"} (the default).

The drawing of visible white lines is supported only if
@code{HPGL_VERSION} is "2" and the environment variable
@code{HPGL_OPAQUE_MODE} is "yes" (the default).  @w{If the} value is
"no" then white lines (@w{if any}), which are normally drawn with @w{pen
#0}, will not be drawn.  This feature is to accommodate older HP-GL/2
devices.  HP-GL/2 pen plotters, @w{for example}, do not support the use
of @w{pen #0} to draw visible white lines.  Some older HP-GL/2 devices
may, @w{in fact}, malfunction if asked to draw opaque objects.

@w{By default}, @code{tek2plot -T hpgl} will draw with a fixed set of
pens.  Which pens are present may be specified by setting the
@code{HPGL_PENS} environment variable.  If @code{HPGL_VERSION} @w{is
"1"}, the default value of @code{HPGL_PENS} is "1=black"; if
@code{HPGL_VERSION} is "1.5" @w{or "2"}, the default value of
@code{HPGL_PENS} is
"1=black:2=red:3=green:4=yellow:5=blue:6=magenta:7=cyan".  The format
should be self-explanatory.  By setting @code{HPGL_PENS}, you may
specify a color for any pen in the range #1@dots{}#31.  For information
on what color names are recognized, see @ref{Color Names}.  @w{Pen #1}
must always be present, though it need not be black. Any other pen in
the range #1@dots{}#31 may be omitted.

If @code{HPGL_VERSION} is "2" then @code{tek2plot -T hpgl} will also be
affected by the environment variable @code{HPGL_ASSIGN_COLORS}@.  @w{If
the} value of this variable is "yes", then @code{tek2plot -T hpgl} will
not be restricted to the palette specified in @code{HPGL_PENS}: @w{it
will} assign colors to ``logical pens'' in the range #1@dots{}#31, @w{as
needed}.  The default value is "no" because other than color LaserJet
printers and DesignJet plotters, not many HP-GL/2 devices allow the
assignment of colors to logical pens.  In particular, HP-GL/2 pen
plotters do not.

@node plotfont, spline, tek2plot, Top
@chapter The @code{plotfont} Utility

@menu
* plotfont Examples::         How to use plotfont
* plotfont Invocation::       Command-line options
* plotfont Environment::      Environment variables
@end menu

@node plotfont Examples, plotfont Invocation, plotfont, plotfont
@section How to use @code{plotfont}

GNU @code{plotfont} is a simple utility that will produce a character
map for any font available to the GNU plotting utilities @code{graph},
@code{plot}, @code{pic2plot}, and @code{tek2plot}, and the GNU
@code{libplot} graphics library on which they are based.  The map may be
displayed on an @w{X Window} System display, or produced in any of
several output formats.  The @samp{-T} option is used to specify the
desired output format.  Supported output formats include "X", "png",
"pnm", "gif", "svg", "ai", "ps", "cgm", "fig", "pcl", "hpgl", "regis",
"tek", and "meta" (the default).

Which fonts are available depends on the choice of display or output
format.  @w{To get} a list of the available fonts, use the
@samp{--help-fonts} option.  For example,

@example
plotfont -T ps --help-fonts
@end example

@noindent
will list the fonts that are available when producing Postscript output.
One of these fonts is "Times-Roman".  Doing

@example
plotfont -T ps Times-Roman > map.ps
@end example

@noindent
will produce a character map of the lower half of this font, which
consists of printable ASCII characters.  The map will be a 12x8 grid,
with a character centered in each grid cell.  If you include the
@samp{-2} option, you will get a map of the upper half of the font.

Most built-in fonts are ISO-Latin-1 fonts, which means that the upper
half is arranged according to the ISO-Latin-1 encoding.  The
"HersheyCyrillic" font is one that is not.  If you do

@example
plotfont -T ps -2 HersheyCyrillic > map.ps
@end example

@noindent
you will get a map that illustrates its arrangment, which is called
@w{KOI8-R}@.  The @w{KOI8-R} arrangement is the standard for Unix and
networking applications in the former Soviet Union.  So-called dingbats
fonts, such as "ZapfDingbats" and "Wingdings", also have an
individualistic layout.  In most installations of the plotting
utilities, the Wingdings font is not available when producing Postscript
output.  However, @w{it is} available when producing output in @w{PCL 5}
or HP-GL/2 format.  If you do

@example
plotfont -T hpgl Wingdings > map.plt
@end example

@noindent
you will get a Wingdings character map, in HP-GL/2 format, that may be
imported into any application that understands HP-GL/2.  Similarly,
@code{plot -T pcl Wingdings} will produce a Wingdings character map in
@w{PCL 5} format, which may be printed on a LaserJet or other @w{PCL 5}
device.  

In all, more than a hundred fonts are built into the plotting utilities.
@xref{Text Fonts}.  Actually, if you are using the plotting utilities to
display output on an @w{X display}, you are not restricted to the
built-in fonts.  Doing

@example
plotfont -T X --help-fonts
@end example

@noindent
produces a list of the built-in fonts that are available, including both
Hershey and Postscript fonts.  But fonts available on your @w{X display}
may also be used.  The @code{xlsfonts} command will list the fonts
available on your @w{X display}, most font names being given in what is
called XLFD format.  The plotting utilities refer to @w{X fonts} by
shortened versions of their XLFD names.  For example, the font
"Utopia-Regular" is available on many @w{X displays}.  Its XLFD name is
"-adobe-utopia-medium-r-normal--0-0-0-0-p-0-iso8859-1", and its
shortened XLFD name is "utopia-medium-r-normal".  If you do

@example
plotfont -T X utopia-medium-r-normal
@end example

@noindent
then a character map for this font will be displayed in a popped-up
@w{X window}.

When using the @samp{-T X} option, you may also use the
@samp{--bitmap-size} option to choose the size of the popped-up window.
Modern @w{X displays} can scale fonts by different amounts in the
horizontal and vertical directions.  If, for example, you add
@samp{--bitmap-size 600x300} to the above command line, both the
character map and the Utopia-Regular font @w{within it} will be scaled
in this way.  @w{If your} @w{X display} does not support font scaling,
@w{a scalable} font will be substituted.

@node plotfont Invocation, plotfont Environment, plotfont Examples, plotfont
@section @code{plotfont} command-line options

The @code{plotfont} font display utility will produce a character map
for any of the fonts available to the GNU plotting utilities
@code{graph}, @code{plot}, @code{pic2plot}, and @code{tek2plot}, and the
GNU @code{libplot} graphics library on which they are based.  The map
may be produced in any supported output format, or displayed on an @w{X
Window} System display.  The output format or display type is specified
with the @samp{-T} option.

The names of the fonts for which a character map will be produced may
appear anywhere on the @code{plotfont} command line.  That is, the
relative order of font names and command-line options does not matter.
The character map is written to standard output, unless the @samp{-T X}
option is specified.  @w{In that} case the character map is displayed in
a window on an @w{X Window} System display, and there is no output file.

The possible options are listed below.  There are three sorts of option:

@enumerate
@item
General options.
@item
Options relevant only to raw @code{plotfont}, i.e., relevant only if no
display type or output format is specified with the @samp{-T} option.
@item
Options requesting information (e.g., @samp{--help}).
@end enumerate

@noindent
Each option that takes an argument is followed, in parentheses, by the
type and default value of the argument.  

The following are general options.

@table @samp
@item -1
@itemx --lower-half
Generate a character map for the lower half of each specified font.
This is the default.

@item -2
@itemx --upper-half
Generate a character map for the upper half of each specified font.

@item -o
@itemx --octal
Number the characters in octal rather than in decimal (the default).

@item -x
@itemx --hexadecimal
Number the characters in hexadecimal rather than in decimal (the default).

@item --box
Surround each character with a box, showing its extent to left and
right.  The default is not to do this.

@item -j @var{row}
@itemx --jis-row @var{row}
Generate a character map for row @var{row} of a Japanese font arranged
according to JIS [Japanese Industrial Standard] X0208.  The only such
font currently available is the HersheyEUC [Extended Unix Code] font.
@w{If used}, this option overrides the @samp{-1} and @samp{-2} options.

The valid rows are 1@dots{}94.  In the JIS X0208 standard, Roman
characters are located in @w{row 3}, and Japanese syllabic characters
(Hiragana and Katakana) are located in rows 4 @w{and 5}.  Greek and
Cyrillic characters are located in rows 6 @w{and 7}.  Japanese
ideographic characters (Kanji) are located in rows 16@dots{}84.  Rows
16@dots{}47 contain the JIS @w{Level 1} Kanji, which are the most
frequently used.  They are arranged according @w{to On} (old Chinese)
reading.  Rows 48@dots{}84 contain the less frequently used JIS @w{Level
2} Kanji.

The HersheyEUC font contains 596 of the 2965 @w{Level 1} Kanji, and
seven of the @w{Level 2} Kanji.  @w{It uses} the 8-bit EUC-JP encoding.
This encoding is a multibyte encoding that includes the ASCII character
set @w{as well} as the JIS X0208 characters.  It represents each ASCII
character in the usual way, i.e., as a single byte that does not have
its high bit set.  Each JIS X0208 character is represented as two bytes,
each with the high bit set.  The first byte contains the row number
@w{(plus 32)}, and the second byte contains the character number.

@item -T @var{type}
@itemx --display-type @var{type}
(String, default "meta".)  Select a display type or output format of
type @var{type}, which may be one of the strings "X", "png", "pnm",
"gif", "svg", "ai", "ps", "cgm", "fig", "pcl", "hpgl", "regis", "tek",
and "meta".  These refer respectively to the @w{X Window System}, PNG
format, portable anymap (PBM/PGM/PPM) format, pseudo-GIF format, the new
XML-based Scalable Vector Graphics format, the format used by Adobe
Illustrator, @code{idraw}-editable Postscript, the WebCGM format for
Web-based vector graphics, the format used by the @code{xfig} drawing
editor, the Hewlett--Packard @w{PCL 5} printer language, the
Hewlett--Packard Graphics Language (@w{by default}, HP-GL/2), the ReGIS
(remote graphics instruction set) format developed @w{by DEC}, Tektronix
format, and device-independent GNU graphics metafile format.

Files in PNG, PNM, pseudo-GIF, SVG, AI, or Fig format may contain only a
single page of graphics.  So if the @samp{-T png} option, the @samp{-T
pnm} option, the @samp{-T gif} option, the @samp{-T svg} option, the
@samp{-T ai} option, or the @samp{-T fig} option is used, a character
map will be produced for only the first-specified font.

@item --bg-color @var{name}
(String, default "white".)  Set the color used for the background to be
@var{name}.  This is relevant only to @code{plotfont @w{-T X}},
@code{plotfont -T png}, @code{plotfont -T pnm}, @code{plotfont -T gif},
@code{plotfont -T cgm}, @code{plotfont -T regis}, and @code{plotfont -T
meta}.  @w{An unrecognized} name sets the color to the default.  For
information on what names are recognized, see @ref{Color Names}.  The
environment variable @code{BG_COLOR} can equally well be used to specify
the background color.

If the @samp{-T png} or @samp{-T gif} option is used, a transparent PNG
file or a transparent pseudo-GIF, respectively, may be produced by
setting the @code{TRANSPARENT_COLOR} environment variable to the name of
the background color.  @xref{plotfont Environment}.  @w{If the} @samp{-T
svg} or @samp{-T cgm} option is used, an output file without a
background may be produced by setting the background color to "none".

@item --bitmap-size @var{bitmap_size}
(String, default "570x570".)  Set the size of the graphics display in
which the character map will be drawn, in terms of pixels, to be
@var{bitmap_size}.  This is relevant only to @code{plotfont @w{-T X}},
@code{plotfont -T png}, @code{plotfont -T pnm}, and @code{plotfont -T
gif}, for all of which the size can be expressed in terms of pixels.
The environment variable @code{BITMAPSIZE} may equally well be used to
specify the size.

The graphics display used by @code{plotfont -T X} is a popped-up @w{X
window}.  Command-line positioning of this window on an @w{X Window}
System display is supported.  For example, if @var{bitmap_size} is
"570x570+0+0" then the window will be @w{popped up} in the upper left
corner.

If you choose a rectangular (non-square) window size, the fonts in the
plot will be scaled anisotropically, i.e., by different factors in the
horizontal and vertical direction.  For this, @code{plotfont @w{-T X}}
requires an X11R6 display.  Any font that cannot be anisotropically
scaled will be replaced by a default scalable font, such as the Hershey
vector font "HersheySerif".

For backward compatibility, @code{plotfont -T X} allows the user to set
the window size and position by setting the @w{X resource}
@code{Xplot.geometry}, instead of @samp{--bitmap-size} or
@code{BITMAPSIZE}@.

@item --emulate-color @var{option}
(String, default "no".)  If @var{option} is "yes", replace each color in
the output by an appropriate shade of gray.  This is seldom useful,
except when using @samp{plotfont -T pcl} to prepare output for a @w{PCL
5} device.  (Many monochrome @w{PCL 5} devices, such as monochrome
LaserJets, do a poor job of emulating color on their own.  They usually
map HP-GL/2's seven standard pen colors, including even yellow, to
black.)  You may equally well request color emulation by setting the
environment variable @code{EMULATE_COLOR} to "yes".

@item --numbering-font-name @var{font_name}
(String, default "Helvetica" except for @code{plotfont -T pcl}, for
which "Univers" is the default, and @code{plotfont -T png},
@code{plotfont -T pnm}, @code{plotfont -T gif}, @code{plotfont -T hpgl},
@code{plotfont -T regis}, and @code{plotfont -T tek}, for all of which
"HersheySerif" is the default.)  Set the font used for the numbering of
the characters in the character map(s) to be @var{font_name}.

@item --page-size @var{pagesize}
(String, default "letter".)  Set the size of the page on which the
character map(s) will be drawn.  This is relevant only to @code{plotfont
-T svg}, @code{plotfont -T ai}, @code{plotfont -T ps}, @code{plotfont -T
fig}, @code{plotfont -T pcl}, and @code{plotfont @w{-T} hpgl}.  "letter"
means an 8.5@dmn{in} by 11@dmn{in} page.  Any ISO page size in the range
"a0"@dots{}"a4" or ANSI page size in the range "a"@dots{}"e" may be
specified ("letter" is an alias @w{for "a"} and "tabloid" is an alias
@w{for "b"}).  "legal", "ledger", @w{and "b5"} are recognized page sizes
also.  The environment variable @code{PAGESIZE} can equally well be used
to specify the page size.

For @code{plotfont -T ai}, @code{plotfont -T ps}, @code{plotfont -T
pcl}, and @code{plotfont -T fig}, the graphics display (or `viewport')
within which the character map is drawn will be, by default, a square
region centered on the specified page.  For @code{plotfont -T hpgl}, it
will be a square region of the same size, but may be positioned
differently.  Either or both of the dimensions of the graphics display
can be specified explicitly.  For example, @var{pagesize} could be
specified as "letter,xsize=4in", or "a4,xsize=10cm,ysize=15cm".  The
dimensions are allowed to be negative (@w{a negative} dimension results
in a reflection).

The position of the graphics display, relative to its default position,
may optionally be adjusted by specifying an offset vector.  For example,
@var{pagesize} could be specified as "letter,yoffset=1.2in", or
"a4,xoffset=@minus{}5mm,yoffset=2.0cm".  @w{It is} also possible to
position the graphics display precisely, by specifying the location of
its lower left corner relative to the lower left corner of the page.
For example, @var{pagesize} could be specified as
"letter,xorigin=2in,yorigin=3in", or "a4,xorigin=0.5cm,yorigin=0.5cm".
The preceding options may be intermingled.  @code{plotfont -T svg} and
@code{plotfont -T cgm} ignore the "xoffset", "yoffset", "xorigin", and
"yorigin" options, since SVG format and WebCGM format have no notion of
the Web page on which the graphics display will ultimately be
positioned.  For more on page sizes, see @ref{Page and Viewport Sizes}.

@item --pen-color @var{name}
(String, default "black".)  Set the pen color to be @var{name}.  An
unrecognized name sets the pen color to the default.  For information on
what color names are recognized, see @ref{Color Names}.

@item --rotation @var{angle}
(Integer, default 0.)  Set the rotation angle of the graphics display to
be @var{angle} degrees.  Recognized values are @w{0, 90}, 180, @w{and
270}.  The rotation is counterclockwise.  The environment variable
@code{ROTATION} can equally well be used to specify the rotation angle.

This option is used for switching between portrait and landscape
orientations.  Postmodernists may also find it useful.

@item --title-font-name @var{font_name}
(String) Set the font used for the title of each character map to be
@var{font_name}.  Normally the font used for the title is the same as
the font whose character set is being displayed.  This option is useful
when producing character maps for unusual fonts such as "ZapfDingbats"
and "Wingdings".
@end table

The following option is relevant only to raw @code{plotfont}, i.e.,
relevant only if no display type or output format is specified with the
@samp{-T} option.  In this case @code{plotfont} outputs a graphics
metafile, which may be translated to other formats by invoking
@code{plot}.

@table @samp
@item -O
@itemx --portable-output
Output the portable (human-readable) version of GNU metafile format,
rather than a binary version (the default).  This can also be requested
by setting the environment variable @code{META_PORTABLE} to "yes".
@end table

The following options request information.

@table @samp
@item --help
Print a list of command-line options, and then exit.

@item --help-fonts
Print a table of available fonts, and then exit.  The table will depend
on which display type or output format is specified with the @samp{-T}
option.  @code{plotfont @w{-T X}}, @code{plotfont -T svg},
@code{plotfont -T ai}, @code{plotfont -T ps}, @code{plotfont -T cgm},
and @code{plotfont -T fig} each support the 35 standard Postscript
fonts.  @code{plotfont -T svg}, @code{plotfont -T ai}, @code{plotfont -T
pcl}, and @code{plotfont -T hpgl} support the 45 standard @w{PCL 5}
fonts, and @code{plotfont -T pcl} and @code{plotfont -T hpgl} support a
number of Hewlett--Packard vector fonts.  All of the preceding, together
with @code{plotfont -T png}, @code{plotfont -T pnm}, @code{plotfont -T
gif}, @code{plotfont -T regis}, and @code{plotfont -T tek}, support a
set of 22 Hershey vector fonts.  Raw @code{plotfont} @w{in principle}
supports any of these fonts, since its output must be translated to
other formats with @code{plot}.

@item --list-fonts
Like @samp{--help-fonts}, but lists the fonts in a single column to
facilitate piping to other programs.  @w{If no} display type or output
format is specified with the @samp{-T} option, the full set of supported
fonts is listed.

@item --version
Print the version number of @code{plotfont} and the plotting utilities
package, and exit.
@end table

@node plotfont Environment, , plotfont Invocation, plotfont
@section Environment variables

The behavior of @code{plotfont} is affected by several environment
variables, which are the same as those that affect @code{graph},
@code{plot}, and @code{tek2plot}.  For convenience, we list them here.

We have already mentioned the environment variables @code{BITMAPSIZE},
@code{PAGESIZE}, @code{BG_COLOR}, @samp{EMULATE_COLOR}, and
@code{ROTATION}@.  They serve as backups for the several options
@samp{--bitmap-size}, @samp{--page-size}, @samp{--bg-color},
@code{--emulate-color}, and @samp{--rotation}.  The remaining
environment variables are specific to individual output formats.

@code{plotfont @w{-T X}}, which pops up a window on an @w{X Window}
System display and draws a character map @w{in it}, checks the
@code{DISPLAY} environment variable.  The value of this variable
determines the display on which the window will be @w{popped up}.

@code{plotfont -T png} and @code{plotfont -T gif}, which produce output
in PNG format and pseudo-GIF format respectively, are affected by two
environment variables.  If the value of the @code{INTERLACE} variable is
"yes", the output file will be interlaced.  Also, if the value of the
@code{TRANSPARENT_COLOR} environment variable is the name of a color
that appears in the output file, that color will be treated as
transparent by most applications.  For information on what color names
are recognized, see @ref{Color Names}.

@code{plotfont -T pnm}, which produces output in Portable Anymap
(PBM/PGM/PPM) format, is affected by the @code{PNM_PORTABLE} environment
variable.  If its value is "yes", the output file will be in the
portable (human readable) version of PBM, PGM, or PPM format, rather
than the default (binary) version.

@code{plotfont -T cgm}, which produces CGM files that comply with the
WebCGM profile for Web-based vector graphics, is affected by two
environment variables.  By default, a @w{version 3} CGM file is
generated.  Many older CGM interpreters and viewers, such as the ones
built into Microsoft Office and other commercial software, only support
@w{version 1} CGM files.  The @code{CGM_MAX_VERSION} environment
variable may be set to "1", "2", "3", @w{or "4"} (the default) to
specify a maximum value for the version number.  The @code{CGM_ENCODING}
variable may also be set, to specify the type of encoding used in the
CGM file.  Supported values are "clear_text" (i.e., human readable) and
"binary" (the default).  The WebCGM profile requires that the binary
encoding be used.

@code{plotfont -T pcl}, which produces @w{PCL 5} output for
Hewlett--Packard printers, is affected by the environment variable
@code{PCL_ASSIGN_COLORS}@.  It should be set to "yes" when producing
@w{PCL 5} output for a color printer or other color device.  This will
ensure accurate color reproduction by giving the output device complete
freedom in assigning colors, internally, to its ``logical pens''.  If it
is "no" then the device will use a fixed set of colored pens, and will
emulate other colors by shading.  The default is "no" because monochrome
@w{PCL 5} devices, which are more common than colored ones, must use
shading to emulate color.

@code{plotfont -T hpgl}, which produces Hewlett--Packard Graphics
Language output, is also affected by several environment variables.  The
most important is @code{HPGL_VERSION}, which may be set to "1", "1.5",
@w{or "2"} (the default).  @w{"1" means} that the output should be
generic HP-GL, @w{"1.5" means} that the output should be suitable for
the HP7550A graphics plotter and the HP758x, HP7595A and HP7596A
drafting plotters (HP-GL with some HP-GL/2 extensions), and @w{"2"
means} that the output should be modern HP-GL/2.  @w{If the} version is
"1" @w{or "1.5"} then the only available fonts will be vector fonts.

The position of the @code{plotfont -T hpgl} graphics display on the page
can be rotated @w{90 degrees} counterclockwise by setting the
@code{HPGL_ROTATE} environment variable to "yes".  This is not the same
as the rotation obtained with the @samp{--rotation} option, since it
both rotates the graphics display and repositions its lower left corner
toward another corner of the page.  Besides "no" and "yes", recognized
values for the @code{HPGL_ROTATE} variable are "0", "90", "180", @w{and
"270"}.  @w{"no" and} "yes" are equivalent to @w{"0" and "90"},
respectively.  "180" and "270" are supported only if @code{HPGL_VERSION}
@w{is "2"} (the default).

@w{By default}, @code{plotfont -T hpgl} will draw with a fixed set of
pens.  Which pens are present may be specified by setting the
@code{HPGL_PENS} environment variable.  If @code{HPGL_VERSION} @w{is
"1"}, the default value of @code{HPGL_PENS} is "1=black"; if
@code{HPGL_VERSION} is "1.5" @w{or "2"}, the default value of
@code{HPGL_PENS} is
"1=black:2=red:3=green:4=yellow:5=blue:6=magenta:7=cyan".  The format
should be self-explanatory.  By setting @code{HPGL_PENS}, you may
specify a color for any pen in the range #1@dots{}#31.  For information
on what color names are recognized, see @ref{Color Names}.  @w{Pen #1}
must always be present, though it need not be black. Any other pen in
the range #1@dots{}#31 may be omitted.

If @code{HPGL_VERSION} is "2" then @code{plotfont -T hpgl} will also be
affected by the environment variable @code{HPGL_ASSIGN_COLORS}@.  @w{If
the} value of this variable is "yes", then @code{plotfont -T hpgl} will
not be restricted to the palette specified in @code{HPGL_PENS}: @w{it
will} assign colors to ``logical pens'' in the range #1@dots{}#31, @w{as
needed}.  The default value is "no" because other than color LaserJet
printers and DesignJet plotters, not many HP-GL/2 devices allow the
assignment of colors to logical pens.  In particular, HP-GL/2 pen
plotters do not.

@code{plotfont -T tek}, which produces output for a Tektronix terminal
or emulator, checks the @code{TERM} environment variable.  @w{If the}
value of @code{TERM} is a string beginning with "xterm", "nxterm", or
"kterm", @w{it is} taken as a sign that @code{plotfont} is running in an
@w{X Window} System VT100 terminal emulator: @w{an @code{xterm}},
@code{nxterm}, or @code{kterm}.  Before drawing graphics, @code{plotfont
-T tek} will emit an escape sequence that causes the terminal emulator's
auxiliary Tektronix window, which is normally hidden, to @w{pop up}.
After the graphics are drawn, an escape sequence that returns control to
the original VT100 window will be emitted.  The Tektronix window will
remain on the screen.

If the value of @code{TERM} is a string beginning with "kermit",
"ansi.sys", or "nansi.sys", @w{it is} taken as a sign that
@code{plotfont} is running in the VT100 terminal emulator provided by
the MS-DOS version of @code{kermit}.  Before drawing graphics,
@code{plotfont -T tek} will emit an escape sequence that switches the
terminal emulator to Tektronix mode.  Also, some of the Tektronix
control codes emitted by @code{plotfont -T tek} will be
@code{kermit}-specific.  There will be a limited amount of color
support, which is not normally the case (the 16 @code{ansi.sys} colors
will be supported).  After drawing graphics, @code{plotfont -T tek} will
emit an escape sequence that returns the emulator to VT100 mode.  The
key sequence `@w{ALT minus}' can be employed manually within
@code{kermit} to switch between the two modes.

@node spline, ode, plotfont, Top
@chapter The @code{spline} Program

@menu
* spline Examples::         How to use spline
* Advanced Use of spline::  More sophisticated uses
* spline Invocation::       Command-line options
@end menu

@node spline Examples, Advanced Use of spline, spline, spline
@section How to use @code{spline}

GNU @code{spline} is a program for interpolating between the data points
in one or more datasets.  Each dataset would consist of values for an
independent variable and a dependent variable, which may be a vector of
specified fixed length.  When discussing interpolation, we call these
variables `@math{t}' and `@math{y}', respectively.  @w{To emphasize:}
@w{@math{t} is a scalar}, but @w{in general} the dependent variable
@w{@math{y} may} be a vector.

The simplest case is when there is a single input file, which is in
ASCII format, and the @w{vector @math{y}} is one-dimensional.  This is
the default.  For example, the input file could contain the dataset

@example
@group
0.0  0.0
1.0  1.0
2.0  0.0
@end group
@end example

@noindent
which are the coordinates @math{(t,y)} of the data points (0,0), (1,1),
and (2,0).  Data points do not need to be on different lines, nor do the
@math{t} @w{and @math{y}} coordinates of a data point need to be on the
same line.  However, there should be no blank lines in the input if it
is to be viewed as forming a single dataset.  Also, @w{by default} the
@math{t} coordinate should be monotonically increasing, so that
@w{@math{y} may} be viewed as a function @w{of @math{t}}.

You would construct a spline (the graph of an `interpolating function')
passing through the points in this dataset by doing

@example
spline input_file > output_file
@end example

@noindent
To produce a Postscript plot of the spline with the @code{graph}
utility, you would do

@example
spline input_file | graph -T ps > output.ps
@end example

@noindent
To display a spline on an @w{X Window} System display, you could do

@example
echo 0 0 1 1 2 0 | spline | graph -T X
@end example

@noindent
Notice that the last example avoids the use of the input file
altogether.  @code{spline} will read from standard input if no files are
specified on the command line, or if the special file @w{name @samp{-}}
is specified.

What exactly does @code{spline} do?  First, it fits a curve (the graph
of an interpolating function) through the points in the dataset.  Then
it splits the interval over which the independent @w{variable @math{t}}
ranges into 100 sub-intervals, and computes the @w{@math{y} values} at
each of the 101 subdivision points.  @w{It then} outputs each of the
pairs @math{(t, y)}.  These are the coordinates of 101 points that lie
along a curve that interpolates between the points in the dataset.  If
there is more than one dataset in the input (separated by blank lines),
each dataset is interpolated separately.

You may use the @samp{-n} option to replace `100' by any other positive
integer.  You may also use the @samp{-t} option to specify an
interpolation interval that differs from the default (the interval over
which the independent variable ranges).  For example, the command

@example
echo 0 0 1 1 2 0 | spline -n 20 -t 1.0 1.5 > output_file
@end example

@noindent
will produce a dataset consisting of 21 (rather than 101) data points,
with @w{@math{t} values} spaced regularly between 1.0 and 1.5 (rather
than between 0.0 and 2.0).  The data points will lie along a curve
passing through (0,0), (1,1), and (2,0).  This curve will be a parabola.

In general, the interpolating function will be a piecewise cubic spline.
That is, between each pair of adjacent `knots' (points in the input
dataset), @w{@math{y} will} be a cubic function @w{of @math{t}}.  This
function will differ, depending on which pair of knots @w{@math{y} lies}
between.  At each knot, both the slope and curvature of the cubic pieces
to either side will match.  In mathematical terms, the interpolating
curve will be twice continuously differentiable.

@code{spline} supports `adding tension' to the interpolating curve.
@w{A nonzero} value for the tension can be specified with the @samp{-T}
option.  For example, a spline under considerable tension can be
computed and displayed by doing

@example
echo 0 0 1 0 2 0 | spline -T 10 | graph -T X
@end example

@noindent
As the tension parameter is increased to positive infinity, the spline
will converge to a polygonal line.  You are meant to think of the spline
as being drawn taut.  Actually, tension may be negative @w{as well} as
positive.  @w{A spline} with negative tension will tend to bow outward,
@w{in fact} to oscillate sinusoidally.  But as the tension decreases to
negative infinity, the spline, though oscillatory, will again converge
to a polygonal line.

If the tension is positive, its reciprocal will be the maximum range of
the independent @w{variable @math{t}} over which the spline will `like
to curve'.  Increasing the tension far above zero will accordingly force
the spline to consist of short curved sections, centered on the data
points, and sections that are almost straight.  It follows that tension
is a `dimensionful' quantity.  @w{If the} tension is nonzero, then when
the values of the independent variable are multiplied by some common
positive factor, the tension should be divided by the same factor to
obtain a scaled version of the original spline.  @w{If the} tension is
zero (the default, or cubic spline case), then the computation of the
spline will be unaffected by linear scaling of the data.

In mathematical terms, a spline under tension will satisfy the
differential equation 
@ifnottex
@math{y''''=sgn(tension)*(tension^2)y''} 
@end ifnottex
@tex
$$y''''={\rm sgn}({\sl tension}){\sl tension}^2\thinspace y''$$
@end tex
between each successive pair of knots.  If the tension equals zero,
which is the default, the fourth derivative of @math{y} with respect
@w{to @math{t}} will equal zero at every point.  In this case, @math{y}
as a function @w{of @math{t}} will reduce to a cubic polynomial between
each successive pair of knots.  But if the tension is nonzero, @math{y}
will not be a polynomial function @w{of @math{t}}.  @w{It may} be expressed
@w{in terms} of exponential functions, however.

Irrespective of whether or not the spline is under tension, you may
specify the @samp{-p} option if you wish the spline to be a periodic
function @w{of @math{t}}.  This will only work if the @math{y} values for
the first and last points in the dataset are equal.  Otherwise, it would
make no sense to compute a periodic interpolation.

It is sometimes useful to interpolate between data points at the same
time as they are generated by an auxiliary program.  @w{That is}, @w{it
is} useful for @code{spline} to function as a real-time filter.
@code{spline} does not normally act as a filter, since computing an
interpolating curve that is as smooth as possible is a global task.  But
if the @samp{-f} option is specified, @code{spline} will indeed function
as a filter.  @w{A different} interpolation algorithm (cubic Bessel
interpolation, which is local rather than global) will be used.  @w{If
@samp{-f}} is specified, @samp{-p} may not be specified.  Also, if
@samp{-f} is specified then an interpolation interval (@w{a range} of
@w{@math{t} values}) must be requested explicitly with the @samp{-t}
option.

Cubic Bessel interpolation is inherently less smooth than the
construction of a global cubic spline.  @w{If the} @samp{-f} option is
specified, the slope of the spline at each knot will be chosen by
fitting a parabola through that knot, and the two adjacent knots.  The
slopes of the two interpolating segments to either side of each interior
knot will match at that knot, but typically their curvatures will not.
In mathematical terms, the interpolating curve will be continuously
differentiable, but in general not twice continuously differentiable.
This loss of differentiability is the price that is paid for functioning
as a real-time filter.

@node Advanced Use of spline, spline Invocation, spline Examples, spline
@section Advanced use of @code{spline}

The preceding section explains how @code{spline} can be employed to
interpolate a function @math{y} of a scalar variable @math{t}, in the
case when @math{y} is a scalar.  In this section we explain how to
perform more sophisticated interpolations.  This includes
multidimensional interpolations, and interpolations that are splinings
of curves, rather than of functions.

@code{spline} can handle the case when @w{@math{y} is} a vector of
arbitrary specified dimensionality.  The dimension can be specified with
the @samp{-d} option.  For example, an input file could contain the
multidimensional dataset

@example
@group
0.0  0.0  1.0
1.0  1.0  0.0
2.0  0.0  1.0
@end group
@end example

@noindent
which are the coordinates @math{(t,y)} of the data points (0,0,1),
(1,1,0), and (2,0,1).  You would construct a spline (the graph of an
interpolating function) passing through the points in this dataset by
doing

@example
spline -d 2 input_file > output_file
@end example

@noindent
The option @samp{-d 2} is used because in this example, the dependent
variable @math{y} is a two-dimensional vector.  Each of the components
of @math{y} will be interpolated independently, and the output file will
contain points that lie along the graph of the resulting interpolating
function.

When doing multidimensional splining, you may use any of the options
that apply in the default one-dimensional case.  For example, the
@samp{-f} option will yield real-time cubic Bessel interpolation.  @w{As
in} the one-dimensional case, if the @samp{-f} option is used then the
@samp{-t} option must be used @w{as well}, to specify an interpolation
interval (@w{a range} of @w{@math{t} values}).  The @samp{-p} option
will yield a periodic spline, i.e., the graph of a periodic
vector-valued function.  For this, the first and last dataset
@w{@math{y} values} must be the same.

@code{spline} can also be used to draw a curve through arbitrarily
chosen points in the plane, or @w{in general} through arbitrarily chosen
points in @math{d}-dimensional space.  This is not the same as splining,
@w{at least} as the term is conventionally defined.  The reason is that
`splining' refers to construction of a function, rather than the
construction of a curve that may or may not be the graph of a function.
Not every curve is the graph of a function.

The following example shows how you may `spline a curve'.  The command

@example
echo 0 0 1 0 1 1 0 1 | spline -d 2 -a -s | graph -T X
@end example

@noindent
will construct a curve in the plane through the four points (0,0),
(1,0), (1,1), and (0,1), and graph it on an @w{X Window} System display.
The @samp{-d 2} option specifies that the dependent variable @math{y} is
two-dimensional.  The @samp{-a} option specifies that @w{@math{t}
values} are missing from the input, and should be automatically
generated.  @w{By default}, the first @w{@math{t} value} @w{is 0}, the
second @w{is 1}, etc.  The @samp{-s} option specifies that the
@w{@math{t} values} should be stripped from the output.

The same technique may be used to spline a closed curve.  For example,
doing

@example
echo 0 0 1 0 0 1 0 0 | spline -d 2 -a -s -p | graph -T X
@end example

@noindent
will construct and graph a closed, lozenge-shaped curve through the
three points (0,0), (1,0), and (0,1).  The construction of a closed
curve is guaranteed by the @samp{-p} (i.e., @samp{--periodic}) option,
and by the repetition of the initial point (0,0) at the end of the
sequence.

When splining a curve, whether open or closed, you may wish to
substitute the @samp{-A} option for the @samp{-a} option.  Like the
@samp{-a} option, the @samp{-A} option specifies that @w{@math{t}
values} are missing from the input and should be automatically
generated.  However, the increment from one @w{@math{t} value} to the
next will be the distance between the corresponding values @w{of
@math{y}}.  This scheme for generating @w{@math{t} values}, when
constructing a curve through a sequence of data points, is the scheme
that is used in the @w{well known} FITPACK subroutine library.  @w{It
is} probably the best approach when the distances between successive
points fluctuate considerably.

A curve through a sequence of points in the plane, whether open or
closed, may cross itself.  Some interesting visual effects can be
obtained by adding negative tension to such a curve.  For example, doing

@example
echo 0 0 1 0 1 1 0 0 | spline -d 2 -a -s -p -T -14 -n 500 | graph -T X
@end example

@noindent
will construct a closed curve through the three points (0,0), (1,0), 
and (0,1), which is wound into curlicues.  The @samp{-n 500} option is
included because there are so many windings.  @w{It specifies} that 501
points should be generated, which is enough to draw a smooth curve.

@noindent
@node spline Invocation, , Advanced Use of spline, spline
@section @code{spline} command-line options

The @code{spline} program will interpolate vector-valued functions of a
scalar @w{variable @math{t}}, and curves in @math{d}-dimensional space.
The algorithms used by @code{spline} are similar to those discussed in
@w{D. Kincaid} and @w{[E.] W.} Cheney, @cite{Numerical Analysis} (2nd
ed., Brooks/Cole, 1996), section 6.4, and @w{C. de Boor}, @cite{A
Practical Guide to Splines} (Springer-Verlag, 1978), @w{Chapter 4}.

Input file names may be specified anywhere on the command line.  That
is, the relative order of font names and command-line options does not
matter.  If no file names are specified, or the file @w{name @samp{-}}
is specified, the standard input is read.

An input file may contain more than a single dataset.  Unless the
@samp{-a} or @samp{-A} options are used (see below), each dataset is
expected to consist of a sequence of data points, given as alternating
@math{t} @w{and @math{y}} values.  @w{@math{t} is} the scalar
independent variable, and @w{@math{y} is} the vector-valued dependent
variable.  The dimensionality @w{of @math{y}} is specified with the
@samp{-d} option (the default @w{is @math{1}}).

If the input file is in ASCII format (the default), its datasets are
separated by blank lines.  An input file may also contain any number of
comment lines, which must begin with the comment @w{character `#'}.
Comment lines are ignored.  They are not treated as blank, i.e., they do
not interrupt a dataset in progress.

The options to @code{spline} are listed below.  There are three sorts of
option:

@enumerate
@item
Options specifying the type of interpolation to be performed on each dataset.
@item
Options specifying the input or output format.
@item
Options requesting information (e.g., @samp{--help}).
@end enumerate

@noindent
Options that take an argument are followed, in parentheses, by the type
and default value of the argument.

The following options specify the type of interpolation to be performed
on each dataset.

@table @samp
@item -f
@itemx --filter
Use a local interpolation algorithm (the cubic Bessel algorithm), so
that @code{spline} can be used as a real-time filter.  The slope of the
interpolating curve at each point in a dataset will be chosen by fitting
a quadratic function through that point and the two adjacent points in
the dataset.  If @samp{-f} is specified then the @samp{-t} option,
otherwise optional, must be used @w{as well}.  Also, if @samp{-f} is
specified then the @samp{-k}, @samp{-p}, and @samp{-T} options may not
be used.

If @samp{-f} is @emph{not} specified, then a different (global)
interpolation algorithm will be used.

@item -k @var{k}
@itemx --boundary-condition @var{k}
(Float, default 1.0.)  Set the boundary condition parameter for each
constructed spline to @w{be @var{k}}.  In each of its components, the
spline will satisfy the two boundary conditions @math{y''[0]=ky''[1]}
and @math{y''[n]=ky''[n-1]}.  Here @math{y[0]} and @math{y[1]} signify
the values of a specified component of the vector-valued dependent
variable @math{y} at the first two points of a dataset, and
@math{y[n-1]} and @math{y[n]} the values at the last two points.
Setting @var{k} to zero will yield a `natural' spline, i.e., one that
has zero curvature at the two ends of the dataset.  The @samp{-k} option
may not be used if @samp{-f} or @samp{-p} is specified.

@item -n @var{n}
@itemx --number-of-intervals @var{n}
(Positive integer, default 100.)  Subdivide the interval over which
interpolation occurs into @var{n} subintervals.  The number of data
points computed, and written to the output, will be @math{n+1}.

@item -p
@itemx --periodic
Construct a periodic spline.  If this option is specified, the @math{y}
values for the first and last points in each dataset must be equal.  The
@samp{-f} and @samp{-k} options may not be used if @samp{-p} is
specified.

@item -T @var{tension}
@itemx --tension @var{tension}
(Float, default 0.0.)  Set the tension in each interpolating spline to
be @var{tension}.  Between each pair of successive points in a dataset,
the constructed spline will satisfy the differential equation
@ifnottex
@math{y''''=sgn(tension)*(tension^2)y''}
@end ifnottex
@tex
$y''''={\rm sgn}({\sl tension}){\sl tension}^2\thinspace y''$
@end tex
in each of its components.  If @var{tension} equals zero, the spline
will be piecewise cubic.  As @var{tension} increases to positive
infinity, the spline will converge to a polygonal line.  The @samp{-T}
option may not be used if @samp{-f} is specified.

@item -t @var{tmin} @var{tmax} [@var{tspacing}]
@itemx --t-limits @var{tmin} @var{tmax} [@var{tspacing}]
For each dataset, set the interval over which interpolation occurs to be
the interval between @var{tmin} @w{and @var{tmax}}.  If @var{tspacing}
is not specified, the interval will be divided into the number of
subintervals specified by the @samp{-n} option.  @w{If the} @samp{-t}
option is not used, the interval over which interpolation occurs will be
the entire range of the independent variable in the dataset.  The
@samp{-t} option must always be used if the @samp{-f} option is used to
request filter-like behavior (see above).
@end table

@noindent
The following options specify the format of the input file(s) and the
output file.

@table @samp
@item -d @var{dimension}
@itemx --y-dimension @var{dimension}
(Integer, default 1.)  Set the dimensionality of the dependent variable
@math{y} in the input and output files to be @var{dimension}. 

@item -I @var{data-format}
@itemx --input-format @var{data-format}
(Character, default @samp{a}.)  Set the data format for the input file(s)
to be @var{data-format}.  The possible data formats are as follows.

@table @samp
@item a  
ASCII format.  Each file is a sequence of floating point numbers,
interpreted as the @math{t} @w{and @math{y}} coordinates of the
successive data points in a dataset.  If @math{y} is
@math{d}-dimensional, there will be @math{d+1} numbers for each point.
The @math{t} @w{and @math{y}} coordinates of a point need not appear on
the same line, and points need not appear on different lines.  But if a
blank line occurs (i.e., two newlines in succession are seen), @w{it is}
interpreted as the end of a dataset, and the beginning of the next.

@item f
@ifnottex
Single precision binary format.  Each file is a sequence of floating
point numbers, interpreted as the @math{t} @w{and @math{y}} coordinates
of the successive data points in a dataset.  If @math{y} is
@math{d}-dimensional, there will be @math{d+1} numbers for each point.
Successive datasets are separated by a single occurrence of the quantity
@code{FLT_MAX}, which is the largest possible single precision floating
point number.  @w{On most} machines this is approximately 3.4x10^38.
@end ifnottex
@tex
Single precision binary format.  Each file is a sequence of floating
point numbers, interpreted as the @math{t} @w{and @math{y}} coordinates
of the successive data points in a dataset.  If @math{y} is
@math{d}-dimensional, there will be @math{d+1} numbers for each point.
Successive datasets are separated by a single occurrence of the quantity
@code{FLT_MAX}, which is the largest possible single precision floating
point number.  @w{On most} machines this is approximately
$3.4\times10^{38}$.
@end tex

@item d
@ifnottex
Double precision binary format.  Each file is a sequence of double
precision floating point numbers, interpreted as the @math{t} @w{and
@math{y}} coordinates of the successive data points in a dataset.  If
@math{y} is @math{d}-dimensional, there will be @math{d+1} numbers for
each point.  Successive datasets are separated by a single occurrence of
the quantity @code{DBL_MAX}, which is the largest possible double
precision floating point number.  @w{On most} machines this is
approximately 1.8x10^308.
@end ifnottex
@tex
Double precision binary format.  Each file is a sequence of double
precision floating point numbers, interpreted as the @math{t} @w{and
@math{y}} coordinates of the successive data points in a dataset.  If
@math{y} is @math{d}-dimensional, there will be @math{d+1} numbers for
each point.  Successive datasets are separated by a single occurrence of
the quantity @code{DBL_MAX}, which is the largest possible double
precision floating point number.  @w{On most} machines this is
approximately $1.8\times10^{308}$.
@end tex

@item i
@ifnottex
Integer binary format.  Each file is a sequence of integers, interpreted
as the @math{t} @w{and @math{y}} coordinates of the successive data
points in a dataset.  If @math{y} is @math{d}-dimensional, there will be
@math{d+1} numbers for each point.  Successive datasets are separated by
a single occurrence of the quantity @code{INT_MAX}, which is the largest
possible integer.  @w{On most} machines this is 2^31-1.
@end ifnottex
@tex
Integer binary format.  Each file is a sequence of integers, interpreted
as the @math{t} @w{and @math{y}} coordinates of the successive data
points in a dataset.  If @math{y} is @math{d}-dimensional, there will be
@math{d+1} numbers for each point.  Successive datasets are separated by
a single occurrence of the quantity @code{INT_MAX}, which is the largest
possible integer.  @w{On most} machines this is $2^{31}-1$.
@end tex
@end table

@item -a [@var{step_size} [@var{lower_limit}]]
@itemx --auto-abscissa [@var{step_size} [@var{lower_limit}]]
(Floats, defaults 1.0 and 0.0.)  Automatically generate values for the
independent @w{variable (@math{t})}.  Irrespective of data format
(@samp{a}, @samp{f}, @samp{d}, @w{or @samp{i}}), this option specifies
that the values of the independent variable (@math{t}) are missing from
the input file: the dataset(s) to be read contain only values of the
dependent @w{variable (@math{y})}, @w{so that} if @math{y} is
@math{d}-dimensional, there will be only @w{@math{d} numbers} for each
point.  The increment from each @w{@math{t} value} to the next will be
@var{step_size}, and the first @w{@math{t} value} will be
@var{lower_limit}.

@item -A 
@itemx --auto-dist-abscissa
Automatically generate values for the independent @w{variable
(@math{t})}.  This is a variant form of the @samp{-a} option.  The
increment from each @w{@math{t} value} to the next will be the distance
between the corresponding @w{@math{y}} values, and the first @w{@math{t}
value} will be 0.0.  This option is useful when interpolating curves
rather than functions (@pxref{Advanced Use of spline}).

@item -O @var{data-format}
@itemx --output-format @var{data-format}
(Character, default @samp{a}.)  Set the data format for the output file
to be @var{data-format}.  The interpretation of the @var{data-format}
argument is the same as for the @samp{-I} option.

@item -P @var{significant-digits}
@itemx --precision @var{significant-digits}
(Positive integer, default 6.)  Set the numerical precision for the
@math{t} and @math{y} values in the output file to be
@var{significant-digits}.  This takes effect only if the output file is
written in @samp{a} format, i.e., in ASCII@.

@item -s
@itemx --suppress-abscissa
Omit the independent variable @math{t} from the output file; for each
point, supply only the dependent @w{variable @math{y}}.  If @math{y} is
@math{d}-dimensional, there will be only @w{@math{d} numbers} for each
point, @w{not @math{d+1}}.  This option is useful when interpolating
curves rather than functions (@pxref{Advanced Use of spline}).
@end table

@noindent
The following options request information.

@table @samp
@item --help
Print a list of command-line options, and then exit.

@item --version
Print the version number of @code{spline} and the plotting utilities
package, and exit.
@end table

@node ode, libplot, spline, Top
@chapter The @code{ode} Program

The GNU @code{ode} utility can produce a numerical solution to the
initial value problem for many systems of first-order ordinary
differential equations (ODE's).  @code{ode} can also be used to solve
systems of higher-order ODE's, since a simple procedure converts an
@math{n}'th-order equation into @w{@math{n} first-order} equations.  The
output of @code{ode} can easily be piped to @code{graph}, so that one or
more solution curves may be plotted as they are generated.

Three distinct schemes for numerical solution are implemented:
Runge--Kutta--Fehlberg (the default), Adams--Moulton, and Euler.  The
Runge--Kutta--Fehlberg and Adams--Moulton schemes are available with
adaptive stepsize.

@menu
* Basic Math::                  Ordinary differential equations
* Simple ode Examples::         Simple examples using ode
* Additional ode Examples::     Additional examples using ode
* ode Invocation::              ode command-line options
* Diagnostics::                 Diagnostic messages
* Numerical Error::             Numerical error and how to avoid it
* Running Time::                Time spent running ode
* Input Language::              The ode input language formally specified
* ODE Bibliography::            Bibliography on ode and ODE's

@end menu

@node Basic Math, Simple ode Examples, ode, ode
@section Mathematical basics

We begin with some standard definitions.  A @emph{differential equation}
is an equation involving an unknown function and its derivatives.  @w{A
differential} equation is @emph{ordinary} if the unknown function
depends on only one independent variable, often @w{denoted @math{t}}.
The @emph{order} of the differential equation is the order of the
highest-order derivative in the equation.  One speaks of a family, or
@emph{system} of equations when more than one equation is involved.
@w{If the} equations are dependent on one another, they are said to be
@emph{coupled}.  @w{A @emph{solution}} is any function satisfying the
equations.  An @emph{initial value problem} is present when there exist
subsidiary conditions on the unknown function and its derivatives, all
of which are given at the same value of the independent variable.  In
principle, such an `initial condition' specifies a unique solution.
Questions about the existence and uniqueness of a solution, along with
further terminology, are discussed in any introductory text.  (See
@w{Chapter 1} of Birkhoff and Rota's @cite{Ordinary Differential
Equations}.  For this and other references relevant to @code{ode}, see
@ref{ODE Bibliography}.)

In practical problems, the solution of a differential equation is
usually not expressible @w{in terms} of elementary functions.  Hence the
need for a numerical solution.

A numerical scheme for solving an initial value problem produces an
approximate solution, using only functional evaluations and the
operations of arithmetic.  @code{ode} solves first-order initial value
problems of the form:

@ifnottex
@example
@group
@math{x' = f(t,x,y,@dots{},z)}
@math{y' = g(t,x,y,@dots{},z)}
   .
   .
   .
@math{z' = h(t,x,y,@dots{},z)}
@end group
@end example
@end ifnottex
@tex
@example
@group
$x' = f(t,x,y,@ldots{},z)$
$y' = g(t,x,y,@ldots{},z)$
   .
   .
   .
$z' = h(t,x,y,@ldots{},z)$
@end group
@end example
@end tex

@noindent
given the initial values for each dependent variable at the initial
value of the independent @w{variable @math{t}}, i.e.,

@example
@group
@math{x(a) = b}
@math{y(a) = c}
     .
     .
     .
@math{z(a) = d}
@math{t = a}
@end group
@end example

@tex
@noindent
where $a,b,c,\ldots,d$ are constants.
@end tex
@ifnottex
@noindent
where @math{a,b,c,...,d} are constants.
@end ifnottex

@tex
For @code{ode} to be able to solve such a problem numerically, the
functions $f,g,\ldots,h$ must be expressed, using the usual operators
(plus, minus, multiplication, division, and exponentiation), @w{in
terms} of certain basic functions that @code{ode} recognizes.  These are
the same functions that the plotting program @code{gnuplot} recognizes.
Moreover, each of $f,g,\ldots,h$ must be given explicitly.  @code{ode}
cannot deal with a system in which one or more of the first derivatives
is defined implicitly rather than explicitly.
@end tex
@ifnottex
For @code{ode} to be able to solve such a problem numerically, the
functions f,g,@dots{},h must be expressed, using the usual operators
(@w{@math{+}, @math{-}}, @math{*}, @math{/}, @w{and ^}), @w{in terms} of
certain basic functions that @code{ode} recognizes.  These are the same
functions that the plotting program @code{gnuplot} recognizes.
Moreover, each of f,g,@dots{},h must be given explicitly.  @code{ode}
cannot deal with a system in which one or more of the first derivatives
is defined implicitly rather than explicitly.
@end ifnottex

All schemes for numerical solution involve the calculation of an
approximate solution at discrete values of the independent @w{variable
@math{t}}, where the `stepsize' (the difference between any two
successive values @w{of @math{t}}, usually @w{denoted @math{h}}) may be
constant or chosen adaptively.  @w{In general}, as the stepsize
decreases the solution becomes more accurate.  @w{In @code{ode}}, the
stepsize can be adjusted by the user.

@node Simple ode Examples, Additional ode Examples, Basic Math, ode
@section Simple examples using @code{ode}

The following examples should illustrate the procedure of stating an
initial value problem and solving it with @code{ode}.  @w{If these}
examples are too elementary, see @ref{Input Language}, for a formal
specification of the @code{ode} input language.  There is also a
directory containing examples of @code{ode} input, which is distributed
along with the GNU plotting utilities.  @w{On most} systems it is
installed as @file{/usr/share/ode} or @file{/usr/local/share/ode}.

Our first example is a simple one, namely

@example
@math{y'(t) = y(t)}
@end example

@noindent
with the initial condition

@example
@math{y(0) = 1}
@end example

@noindent
The solution to this differential equation is 

@ifnottex
@example
@math{y(t) = e^t}.
@end example
@end ifnottex
@tex
@example
@math{y(t) = e^t}.
@end example
@end tex

@noindent
In particular

@ifnottex
@example
@math{y(1) = e^1 = 2.718282}
@end example
@end ifnottex
@tex
@example
@math{y(1) = e^1 = 2.718282}
@end example
@end tex

@noindent
to seven digits of accuracy.

You may obtain this result with the aid of @code{ode} by typing on the
command line the sequence of commands

@example
@group
ode
y' = y
y = 1
print t, y
step 0, 1
@end group
@end example

@noindent
Two columns of numbers will appear.  Each line will show the value of
the independent @w{variable @math{t}}, and the value of the
@w{variable @math{y}}, as @math{t} is `stepped' from 0 @w{to 1}.  The
last line will be

@example
1 2.718282
@end example

@noindent
as expected.  You may use the @samp{-p} option to change the precision.
If, @w{for example}, you type @samp{ode -p 10} rather than @samp{ode},
you will get ten digits of accuracy in the output, rather than seven
(the default).

After the above output, @code{ode} will wait for further instructions.
Entering for example the line

@example
step 1, 0
@end example

@noindent
should yield two more columns of numbers, containing the values of
@math{t} and @math{y} that are computed when @w{@math{t} is} stepped
back from 1 @w{to 0}.  You could type instead

@example
step 1, 2
@end example

@noindent
to increase rather than @w{decrease @math{t}}.  @w{To exit} @code{ode},
you would type a line containing only @samp{.}, i.e.@: @w{a single} period,
and tap `return'.  @code{ode} will also exit if it sees an end-of-file
indicator in its input stream, which you may send from your terminal by
typing control-D@.

Each line of the preceding example should be self-explanatory.  @w{A
@samp{step}} statement sets the beginning and the end of an interval
over which the independent variable (@w{here, @math{t}}) will range, and
causes @code{ode} to set the numerical scheme in motion.  The initial
value appearing in the first @samp{step} statement (@w{i.e., 0}) and the
assignment statement

@example
y = 1
@end example

@noindent
are equivalent to the initial condition @math{y(0) = 1}.  The statements
@w{@samp{y' = y}} and @samp{y = 1} are very different: @samp{y' = y}
defines a way of computing the derivative @w{of @math{y}}, while @samp{y
= 1} sets the initial value @w{of @math{y}}.  Whenever a @samp{step}
statement is encountered, @code{ode} tries to step the independent
variable through the interval it specifies.  Which values are to be
printed at each step is specified by the most recent @samp{print}
statement.  @w{For example},

@example
print t, y, y'
@end example

@noindent
would cause the current value of the independent @w{variable @math{t}},
the @w{variable @math{y}}, and its derivative to be printed at each
step.

To illustrate @code{ode}'s ability to take its input or the initial part
of its input from a file, you could prepare a file containing the
following lines:

@example
@group
# an ode to Euler
y  = 1
y' = y
print t, y, y'
@end group
@end example

@noindent
Call this file @file{euler}.  (The @samp{#} line is a comment line,
which may appear at any point.  Everything from @w{the @samp{#}} to the
end of the line on which it appears will be ignored.)  @w{To process}
this file with @code{ode}, you could type on your terminal

@example
@group
ode -f euler
step 0, 1
@end group
@end example

@noindent
These two lines cause @code{ode} to read the file @file{euler}, and the
stepping to take place.  You will now get three quantities (@math{t},
@math{y}, and @math{y'}) printed at each of the values @w{of @math{t}}
between 0 @w{and 1}.  @w{At the} conclusion of the stepping, @code{ode}
will wait for any further commands to be input from the terminal.  This
example illustrates that

@example
ode -f euler
@end example

@noindent
is not equivalent to

@example
ode < euler
@end example

@noindent
The latter would cause @code{ode} to take all its input from the file
@file{euler}, while the former allows subsequent input from the
terminal.  For the latter to produce output, you would need to include a
@samp{step} line at the end of the file.  You would not need to include
a @samp{.} line, however.  @w{@samp{.} is} used to terminate input only
when input is being read from a terminal.

A second simple example involves the numerical solution of a
second-order differential equation.  Consider the initial value problem

@example
@group
@math{y''(t) = -y(t)}
@math{y(0) = 0}
@math{y'(0) = 1}
@end group
@end example

@noindent
Its solution would be

@ifnottex
@example
@math{y(t) = sin(t)}
@end example
@end ifnottex
@tex
@example
@math{y(t) = \sin(t)}
@end example
@end tex

@noindent
To solve this problem using @code{ode}, you must express this
second-order equation as two first-order equations.  Toward this end you
would introduce a new function, called @math{yp} say, of the independent
@w{variable @math{t}}.  The pair of equations

@example
@group
@math{y' = yp}
@math{yp' = -y}
@end group
@end example

@noindent
would be equivalent to the single equation above.  This sort of
reduction of an @math{n}'th order problem to @math{n} first order
problems is a standard technique.

To plot the variable @math{y} as a function of the @w{variable
@math{t}}, you could create a file containing the lines

@example
@group
# sine : y''(t) = -y(t), y(0) = 0, y'(0) = 1
sine' = cosine
cosine' = -sine
sine = 0
cosine = 1
print t, sine
@end group
@end example

@noindent
(@math{y} and @math{yp} have been renamed @i{sine} and @i{cosine}, since
that is what they will be.)  Call this file @file{sine}.  To display the
generated data points on an @w{X Window} System display as they are
generated, you would type

@example
@group
ode -f sine | graph -T X -x 0 10 -y -1 1
step 0, 2*PI
.
@end group
@end example

@noindent
After you type the @code{ode} line, @code{graph @w{-T X}} will @w{pop
up} a window, and after you type the @samp{step} line, the generated
dataset will be drawn @w{in it}.  The @samp{-x 0 10} and @samp{-y -1 1}
options, which set the bounds for the two axes, are necessary if you
wish to display points in @w{real time}: as they are generated.  
@w{If the} axis bounds were not specified on the command line, 
@code{graph @w{-T X}} would wait until all points are read from the 
input before determining the bounds, and drawing the plot.

A slight modification of this example, showing how @code{ode} can
generate several datasets in succession and plot them on the same graph,
would be the following.  Suppose that you type on your terminal the
following lines.

@example
@group
ode -f sine | graph -T X -C -x 0 10 -y -1 1
step 0, PI
step PI, 2*PI
step 2*PI, 3*PI
.
@end group
@end example

@noindent
Then the sine curve will be traced out in three stages.  Since the
output from each @samp{step} statement ends with a blank line,
@code{graph @w{-T X}} will treat each section of the sine curve as a
different dataset.  If you are using a color display, each of the three
sections will be plotted in a different color.  This is a feature
provided by @code{graph}, which normally changes its linemode after each
dataset it reads.  If you do not like this feature, you may turn it off
by using @code{graph -T X -B} instead of @code{graph @w{-T X}}.

In the above examples, you could use any of the other variants of
@code{graph} instead of @code{graph @w{-T X}}.  For example, you could use
@code{graph -T ps} to obtain a plot in encapsulated Postscript format,
by typing

@example
@group
ode -f sine | graph -T ps > plot.ps
step 0, 2*PI
.
@end group
@end example

@noindent
You should note that of the variants of @code{graph}, the variants
@code{graph -T png}, @code{graph -T pnm}, @code{graph -T gif},
@code{graph -T svg}, @code{graph -T ai}, @code{graph -T ps}, @code{graph
-T cgm}, @code{graph -T fig}, @code{graph -T pcl} and @code{graph -T
hpgl} do not produce output in real time, even when the axis bounds are
specified with the @samp{-x} @w{and @samp{-y}} options.  @w{So if} any
of these variants is used, the plot will be produced only when input
from @code{ode} is terminated, which will occur when you @w{type
@samp{.}}.

In the preceding examples, the derivatives of the dependent variables
were specified by comparatively simple expressions.  They are allowed to
be arbitrarily complicated functions of the dependent variables and the
independent variable.  They may also involve any of the functions that
are built into @code{ode}.  @code{ode} has a fair number of functions
@w{built in}, including @t{abs}, @t{sqrt}, @t{exp}, @t{log}, @t{log10},
@t{sin}, @t{cos}, @t{tan}, @t{asin}, @t{acos}, @t{atan}, @t{sinh},
@t{cosh}, @t{tanh}, @t{asinh}, @t{acosh}, and @t{atanh}.  Less familiar
functions which are built @w{into it} are @t{besj0}, @t{besj1},
@t{besy0}, @t{besy1}, @t{erf}, @t{erfc}, @t{inverf}, @t{lgamma},
@t{gamma}, @t{norm}, @t{invnorm}, @t{ibeta}, and @t{igamma}.  These have
the same definitions as in the plotting program @code{gnuplot}.  (All
functions take a single argument, except for @t{ibeta}, which takes
three, and @t{igamma}, which takes two).  @code{ode} also knows the
meaning of the constant @samp{PI}, as the above examples show.  The
names of the preceding functions are reserved, so, e.g., @samp{cos} and
@samp{sin} may not be used as names for variables.

Other than the restriction of avoiding reserved names and keywords, the
names of variables may be chosen arbitrarily.  Any sequence of
alphanumeric characters starting with an alphabetic character may be
used; the first 32 characters are significant.  @w{It is} worth noting
that @code{ode} identifies the independent variable by the fact that it
is (or should be) the only variable that has not appeared on the left
side of a differential equation or an initial value assignment.  @w{If
there} is more than than one such variable then no stepping takes place;
instead, an error message is printed.  @w{If there} is no such variable,
@w{a dummy} independent variable is invented and given the name
@samp{(indep)}, internally.

@node Additional ode Examples, ode Invocation, Simple ode Examples, ode
@section Additional examples using @code{ode}

We explain here how to use some additional features of @code{ode}.
However, the discussion below does not cover all of its capabilities.
For a complete list of command-line options, see @ref{ode Invocation}.

It is easy to use @code{ode} to create plots of great beauty.  An
example would be a plot of a @emph{strange attractor}, namely the Lorenz
attractor.  Suppose that a file named @file{lorenz} contains the
following lines.

@example
@group
# The Lorenz model, a system of three coupled ODE's with parameter r.
x' = -3*(x-y)
y' = -x*z+r*x-y
z' = x*y-z
@end group

@group
r = 26
x = 0; y = 1; z = 0
@end group

@group
print x, y
step 0, 200
@end group
@end example

@noindent
Then executing the command

@example
ode < lorenz | graph -T X -C -x -10 10 -y -10 10
@end example

@noindent
would produce a plot of the Lorenz attractor (strictly speaking, @w{a
plot} of one of its two-dimensional projections).  You may produce a
Postscript plot of the Lorenz attractor, and print it, by doing
something like

@example
ode < lorenz | graph -T ps -x -10 10 -y -10 10 -W 0 | lpr
@end example

@noindent
The @samp{-W 0} (``zero width'') option requests that @code{graph -T ps}
use the thinnest line possible, to improve the visual appearance of the
plot on a printer or other Postscript device.

Besides plotting a visually striking object in real time, the Lorenz
attractor example shows how statements may be separated by semicolons,
rather than appearing on different lines.  @w{It also} shows how to use
symbolic constants.  @w{In the} description read by @code{ode} the
@w{parameter @math{r}} is a variable like @math{x}, @math{y}, @w{and
@math{z}}.  But unlike them it is not updated during stepping, since no
formula for its @w{derivative @math{r'}} is given.

Our second example deals with the interactive construction of a `phase
portrait': @w{a set} of solution curves with different initial
conditions.  Phase portraits are of paramount interest in the
qualitative theory of differential equations, and also possess
@ae{}sthetic appeal.

Since a description read by @code{ode} may contain any number of
@samp{step} statements, multiple solution curves may be plotted in a
single run.  The most recent @samp{print} statement will be used with
each @samp{step} statement.  @w{In practice}, a phase portrait would be
drawn from a few well-chosen solution curves.  Choosing a good set of
solution curves may require experimentation, which makes interactivity
and real-time plotting all-important.

As an example, consider a so-called Lotka--Volterra predator--prey
model.  Suppose that in a lake there are two species of fish: @w{A (the
prey)} who live by eating a plentiful supply of plants, and B (the
predator) who @w{eat A}@.  Let @math{x(t)} be the population @w{of A}
and @math{y(t)} the population @w{of B} at @w{time @math{t}}.  @w{A
crude} model for the interaction of A @w{and B} is given by the
equations

@example
@group
@math{x' = x(a-by)}
@math{y' = y(cx-d)}
@end group
@end example

@noindent
where @math{a, b, c, d} are positive constants.  To draw a phase
portrait for this system interactively, you could type

@example
@group
ode | graph -T X -C -x 0 5 -y 0 5
x' = (a - b*y) * x
y' = (c*x - d) * y
a = 1; b = 1; c = 1; d = 1;
print x, y
@end group
@group
x = 1; y = 2
step 0, 10
x = 1; y = 3
step 0, 10
x = 1; y = 4
step 0, 10
x = 1; y = 5
step 0, 10
.
@end group
@end example

@noindent
Four curves will be drawn in succession, one per @samp{step} line.  They
will be periodic; this periodicity is similar to the fluctuations
between predator and prey populations that occur in real-world
ecosystems.  @w{On a} color display the curves will appear in different
colors, since @w{by default}, @code{graph} changes the linemode between
datasets.  That feature may be @w{turned off} by using @code{graph -T X
-B} rather than @code{graph @w{-T X}}.

It is sometimes useful to use @code{ode} and @code{graph} to plot
discrete points, which are not joined by line segments to form a curve.
Our third example illustrates this.  Suppose the file @file{atwoods}
contains the lines

@example
@group
m = 1
M = 1.0625
a = 0.5; adot = 0
l = 10; ldot = 0
@end group

@group
ldot' = ( m * l * adot * adot - M * 9.8 + m * 9.8 * cos(a) ) / (m + M)
l'    = ldot
adot' = (-1/l) * (9.8 * sin(a) +  2 * adot * ldot)
a'    = adot
@end group

@group
print l, ldot
step 0, 400
@end group
@end example

@noindent
The first few lines describe the functioning of a so-called swinging
Atwood's machine.  An ordinary Atwood's machine consists of a taut cord
draped over a pulley, with a mass attached to the cord at each end.
Normally, the heavier @w{mass (@math{M})} would win against the lighter
@w{mass (@math{m})}, and draw it upward.  @w{A swinging} Atwood's
machine allows the lighter mass to swing back and forth @w{as well} as
move vertically.

The @samp{print l, ldot} statement requests that the vertical position
and vertical velocity of the lighter mass be printed out at each step.
@w{If you} run the command

@example
ode < atwoods | graph -T X -x 9 11 -y -1 1 -m 0 -S 1 -X l -Y ldot
@end example

@noindent
you will obtain a real-time plot.  The @samp{-m 0} option requests that
successive data points not be joined by line segments, and the @samp{-S
1} option requests that plotting @w{symbol #1} (@w{a dot}) be plotted at
the location of each point.  As you will see if you run this command,
the heavy mass does not win against the lighter mass.  Instead the
machine oscillates non-periodically.  Since the motion is non-periodic,
the plot benefits from being drawn as a sequence of unconnected points.

We conclude by mentioning a few features of @code{ode} that may be
useful when things are not going quite right.  One of them is the
@samp{examine} statement.  @w{It may} be used to discover pertinent
information about any variable in a system.  For details, see @ref{Input
Language}.

Another useful feature is that the @samp{print} statement may be used to
print out more than just the value of a variable.  As we have seen, if
the name of the variable is followed by @samp{'}, the derivative of the
variable will be printed instead.  @w{In a} similar way, following the
variable name with @samp{?}, @samp{!}, or @samp{~} prints respectively
the relative single-step error, the absolute single-step error, or the
accumulated error (not currently implemented).  These quantities are
discussed in @ref{Numerical Error}.

The @samp{print} statement may be more complicated than was shown in the
preceding examples.  Its general structure is

@example
print <pr-list> [every <const>] [from <const>]
@end example

@noindent
The bracket notation @samp{[@dots{}]} means that the enclosed statements
are optional.  Until now we have not mentioned the @samp{every} clause
or the @samp{from} clause.  The @t{<pr-list>} is familiar, however; it
is simply a comma-separated list of variables.  For example, in the
statement

@example
print t, y, y' every 5 from 1
@end example

@noindent
the @t{<pr-list>} is @t{<t, y, y'>}.  The clauses @samp{every 5} and
@samp{from 1} specify that printing should take place after every fifth
step, and that the printing should begin when the independent
@w{variable @math{t}} @w{reaches 1}.  @w{An @samp{every}} clause is
useful if you wish to `@w{thin out}' the output generated by a
@samp{step} statement, and a @samp{from} clause is useful if you wish to
view only the final portion of a solution curve.

@node ode Invocation, Diagnostics, Additional ode Examples, ode
@section @code{ode} command-line options

@noindent
The command-line options to @code{ode} are listed below.  There are
several sorts of option:

@enumerate
@item
Options affecting the way in which input is read.
@item
Options affecting the format of the output.
@item
Options affecting the choice of numerical solution scheme, and the
error bounds that will be imposed @w{on it}.
@item
Options that request information.
@end enumerate

@noindent
The following option affects the way input is read.

@table @samp
@item -f @var{filename}
@itemx --input-file @var{filename}
Read input from @var{filename} before reading from standard input.
@end table

@noindent
The following options affect the output format.

@table @samp
@item -p @var{significant-digits}
@itemx --precision @var{significant-digits}
(Positive integer, default 6.)  When printing numerical results, use a
precision specified by @var{significant-digits}.  @w{If this} option is
given, the print format will be scientific notation.

@item -t
@itemx --title
Print a title line at the head of the output, naming the columns.  @w{If
this} option is given, the print format will be scientific notation.
@end table

@noindent
The following options specify the numerical integration scheme.  Only
one of the three basic option @samp{-R}, @samp{-A}, and @samp{-E} may be
specified.  The default is @samp{-R} (Runge--Kutta--Fehlberg).

@table @samp
@item -R [@var{stepsize}]
@itemx --runge-kutta [@var{stepsize}]
Use a fifth-order Runge--Kutta--Fehlberg algorithm, with an adaptive
stepsize unless a constant stepsize is specified.  When a constant
stepsize is specified and no error analysis is requested, then a
classical fourth-order Runge--Kutta scheme is used.

@item -A [@var{stepsize}]
@itemx --adams-moulton [@var{stepsize}]
Use a fourth-order Adams--Moulton predictor--corrector scheme, with an
adaptive stepsize unless a constant stepsize, @var{stepsize}, is
specified.  The Runge--Kutta--Fehlberg algorithm is used to get past
`bad' points (@w{if any}).

@item -E [@var{stepsize}]
@itemx --euler [@var{stepsize}]
Use a `quick and dirty' Euler scheme, with a constant stepsize.  The
default value of @var{stepsize} @w{is 0.1}.  Not recommended for serious
applications.

The error bound options @samp{-r} and @samp{-e} (see below) may not
be used if @samp{-E} is specified.

@item -h @var{hmin} [@var{hmax}]
@itemx --step-size-bound @var{hmin} [@var{hmax}]
Use a lower bound @var{hmin} on the stepsize.  The numerical scheme will
not let the stepsize go below @var{hmin}.  The default is to allow the
stepsize to shrink to the machine limit, i.e., the minimum nonzero
double-precision floating point number.  The optional argument
@var{hmax}, if included, specifies a maximum value for the stepsize.
@w{It is} useful in preventing the numerical routine from skipping
quickly over an interesting region.
@end table

@noindent
The following options set the error bounds on the numerical solution
scheme.

@table @samp
@item -r @var{rmax} [@var{rmin}]
@itemx --relative-error-bound @var{rmax} [@var{rmin}]

@item -e @var{emax} [@var{emin}]
@itemx --absolute-error-bound @var{emax} [@var{emin}]
@ifnottex
The @samp{-r} option sets an upper bound on the relative single-step
error.  If the @samp{-r} option is used, the relative single-step error
in any dependent variable will never exceed @var{rmax} (the default for
which is @math{10^(-9)}).  If this should occur, the solution will be
abandoned and an error message will be printed.  @w{If the} stepsize is
not constant, the stepsize will be decreased `adaptively', so that the
upper bound on the single-step error is not violated.  Thus, choosing a
smaller upper bound on the single-step error will cause smaller
stepsizes to be chosen.  @w{A lower} bound @var{rmin} may optionally be
specified, to suggest when the stepsize should be increased (the default
for @var{rmin} is @var{rmax}/1000).  The @samp{-e} option is similar to
@samp{-r}, but bounds the absolute rather than the relative single-step
error.
@end ifnottex
@tex
The @samp{-r} option sets an upper bound on the relative single-step
error.  If the @samp{-r} option is used, the relative single-step error
in any dependent variable will never exceed @var{rmax} (the default for
which is $10^{-9}$).  If this should occur, the solution will be
abandoned and an error message will be printed.  @w{If the} stepsize is
not constant, the stepsize will be decreased `adaptively', so that the
upper bound on the single-step error is not violated.  Thus, choosing a
smaller upper bound on the single-step error will cause smaller
stepsizes to be chosen.  @w{A lower} bound @var{rmin} may optionally be
specified, to suggest when the stepsize should be increased (the default
for @var{rmin} is @var{rmax}/1000).  The @samp{-e} option is similar to
@samp{-r}, but bounds the absolute rather than the relative single-step
error.
@end tex

@item -s
@itemx --suppress-error-bound
Suppress the ceiling on single-step error, allowing @code{ode} to
continue even if this ceiling is exceeded.  This may result in large
numerical errors.
@end table

@noindent
Finally, the following options request information.

@table @samp
@item --help
Print a list of command-line options, and then exit.

@item --version
Print the version number of @code{ode} and the plotting utilities
package, and exit.
@end table

@node Diagnostics, Numerical Error, ode Invocation, ode
@section Diagnostic messages

@code{ode} is always in one of two states:

@itemize @bullet
@item
Reading input.  The input includes a specification of a system of
ordinary differential equations, together with instructions for
@w{solving it} numerically: @w{a @samp{print}} line and a @samp{step}
line.

@item
Numerically solving a system, and printing the resulting output.
@end itemize

@noindent
@code{ode} moves from the first to the second state after it sees and
processes a @samp{step} line.  @w{It returns} to the first state after
the generated output has been printed.  Errors may occur in the
`reading' state or the `solving' state, and may terminate computations
or even cause @code{ode} to exit.  We now explain the possible sorts of
error.

While reading input, @code{ode} may encounter a syntax error: an
ungrammatical line that it is unable to parse.  (For a summary of its
input grammar, see @ref{Input Language}.)  @w{If so}, it emits the error
message

@example
ode::nnn: syntax error
@end example

@noindent
where @samp{nnn} is the number of the line containing the error.  When
the @samp{-f filename} option is used to specify an input file, 
the error message will read

@example
ode:filename:nnn: syntax error
@end example

@noindent
for errors encountered inside the input file.  Subsequently, when
@code{ode} begins reading the standard input, line numbers will start
over again @w{from 1}.

No effort is made to recover from syntax errors in the input.  However,
there is a meager effort to resynchronize, so that more than one syntax
error in a file may be found at the same time.

It is also possible that a fatal arithmetic exception (such as a
division by zero, or a floating point overflow) may occur while
@code{ode} is reading input.  If such an exception occurs, @code{ode}
will print an ``Floating point exception'' error message and exit.
Arithmetic exceptions are machine-dependent.  @w{On some} machines, the
line

@example
y = 1/0
@end example

@noindent
would induce an arithmetic exception.  Also on some machines (not
necessarily the same ones), the lines

@example
@group
y = 1e100
z = y^4
@end group
@end example

@ifnottex
@noindent
would induce an arithmetic exception.  That is because on most
machines, the double precision quantities that @code{ode} uses
internally are limited to a maximum size of approximately 1.8x10^308.
@end ifnottex
@tex
@noindent
would induce an arithmetic exception.  That is because on most machines,
the double precision quantities that @code{ode} uses internally are
limited to a maximum size of approximately $1.8\times10^{308}$.
@end tex

When @code{ode} is in the `solving' state, i.e., computing a numerical
solution, similar arithmetic exceptions may occur.  If so, the solution
will be interrupted and a message resembling

@example
ode: arithmetic exception while calculating y'
@end example

@noindent
will be printed.  However, @code{ode} will not exit; the exception will
be `caught'.  @code{ode} itself recognizes the following exceptional
conditions: square root of a negative number, logarithm of a
non-positive number, and negative number raised to a non-integer power.
@code{ode} will catch any of these operations before it is performed,
and print an error message specifying which illegal operation it has
encountered.

@example
ode: square root of a negative number while calculating y'
@end example

@noindent
would be a typical error message.

If the machine on which @code{ode} is running supports the
@samp{matherr} facility for reporting errors in the computation of
standard mathematical functions, it will be used.  This facility reports
domain errors and range errors (overflows, underflows, and losses of
significance) that could occur when evaluating such functions as
@samp{log}, @samp{gamma}, etc.; again, before they are performed.  If
the @code{matherr} facility is present, the error message will be fairly
informative.  @w{For example}, the error message

@example
ode: range error (overflow) in lgamma while calculating y'
@end example

@noindent
could be generated if the logarithmic gamma function @samp{lgamma} is
evaluated at a value of its argument that is too large.  The generation
of any such message, except a message warning of an underflow, will
cause the numerical solution to be interrupted.

There is another sort of error that may occur during numerical solution:
the condition that an error ceiling, which the user may set with the
@samp{-r} option or the @samp{-e} option, is exceeded.  This too will
cause the numerical solution to be abandoned, and @code{ode} to switch
back to reading input.

@node Numerical Error, Running Time, Diagnostics, ode
@section Numerical error and how to avoid it

This discussion is necessarily incomplete.  Entire books exist on any
subject mentioned below (e.g., floating point error).  Our goals are
modest: first, to introduce the basic notions of error analysis as they
apply to @code{ode}; second, @w{to steer} you around the more obvious
pitfalls.  You should look through a numerical analysis text (e.g.,
Atkinson's @cite{Introduction to Numerical Analysis}) before beginning
this discussion.

We begin with some key definitions.  The error of greatest concern is
the difference between the actual solution and the numerical
approximation to the solution; this is termed the @emph{accumulated
error}, since the error is @w{built up} during each numerical step.
Unfortunately, an estimate of this error is usually not available
without knowledge of the actual solution.  There are, however, several
more usable notions of error.  The @emph{single-step error}, in
particular, is the difference between the actual solution and the
numerical approximation to the solution after any single step, assuming
the value at the beginning of the step is correct.

@ifnottex
The @emph{relative single-step error} is the single-step error, divided
by the current value of the numerical approximation to the solution.
Why not divided by the current value of the solution itself?  The reason
is that the solution is not exactly known.  When free to choose a
stepsize, @code{ode} will do so on the basis of the relative single-step
error.  @w{By default}, it will choose the stepsize so as to maintain an
accuracy of eight significant digits in each step.  That is, it will
choose the stepsize so as not to violate an upper bound of
@math{10^(-9)} on the relative single-step error.  This ceiling may be
adjusted with the @samp{-r} option.
@end ifnottex
@tex
The @emph{relative single-step error} is the single-step error, divided
by the current value of the numerical approximation to the solution.
Why not divided by the current value of the solution itself?  The reason
is that the solution is not exactly known.  When free to choose a
stepsize, @code{ode} will do so on the basis of the relative single-step
error.  @w{By default}, it will choose the stepsize so as to maintain an
accuracy of eight significant digits in each step.  That is, it will
choose the stepsize so as not to violate an upper bound of $10^{-9}$ on
the relative single-step error.  This ceiling may be adjusted with the
@samp{-r} option.
@end tex

Where does numerical error come from?  There are two sources.  The first
is the finite precision of machine computation.  All computers work with
floating point numbers, which are not real numbers, but only an
approximation to real numbers.  However, all computations performed by
@code{ode} are done to double precision, so floating point error tends
to be relatively small.  You may nonetheless detect the difference
between real numbers and floating point numbers by experimenting with
the @samp{-p 17} option, which will print seventeen significant digits.
@w{On most} machines, that is the precision of a double precision
floating point number.

The second source of numerical error is often called the
@emph{theoretical truncation error}.  @w{It is} the difference between
the actual solution and the approximate solution due solely to the
numerical scheme.  At the root of many numerical schemes is an infinite
series; for ordinary differential equations, @w{it is} a Taylor
expansion.  Since the computer cannot compute all the terms in an
infinite series, @w{a numerical} scheme necessarily uses a truncated
series; hence the term.  The single-step error is the sum of the
theoretical truncation error and the floating point error, though in
practice the floating point error is seldom included.  The single-step
error estimated by @code{ode} consists only of the theoretical
truncation error.

We say that a numerical scheme is @emph{stable}, when applied to a
particular initial value problem, if the error accumulated during the
solution of the problem over a fixed interval decreases as the stepsize
decreases; @w{at least}, over a wide range of step sizes.  With this
definition both the Runge--Kutta--Fehlberg (@samp{-R}) scheme and the
Adams--Moulton (@samp{-A}) scheme are stable (@w{a statement} based more
on experience than on theoretical results) for a wide class of problems.

After these introductory remarks, we list some common sources of
accumulated error and instability in any numerical scheme.  Usually,
problems with large accumulated error and instability are due to the
single-step error in the vicinity of a `bad' point being large.

@enumerate
@item Singularities.

@code{ode} should not be used to generate a numerical solution on any
interval containing a singularity.  That is, @code{ode} should not be
asked to step over points at which the system of differential equations
is singular or undefined.

You will find the definitions of singular point, regular singular point,
and irregular singular point in any good differential equations text.
If you have no favorite, try Birkhoff and Rota's @cite{Ordinary
Differential Equations}, @w{Chapter 9}.  Always locate and classify the
singularities of a system, @w{if any}, before applying @code{ode}.

@item 
Ill-posed problems.

For @code{ode} to yield an accurate numerical solution on an interval,
the true solution must be defined and well-behaved on that interval.
The solution must also be real.  Whenever any of these conditions is
violated, the problem is said to be @emph{ill-posed}.  Ill-posedness may
occur even if the system of differential equations is well-behaved on
the interval.  Strange results, e.g., the stepsize suddenly shrinking to
the machine limit or the solution suddenly @w{blowing up}, may indicate
ill-posedness.

As an example of ill-posedness (in fact, an undefined solution) consider
the innocent-looking problem:

@ifnottex
@example
@group
@math{y' = y^2}
@math{y(1) = -1}
@end group
@end example
@end ifnottex
@tex
@example
@group
$y' = y^2$
$y(1) = -1$
@end group
@end example
@end tex

@noindent
The solution on the domain @math{t > 0} is

@example
@math{y(t) = -1/t}.
@end example

@noindent
With this problem you must not compute a numerical solution on any
interval that includes @math{t=0}.  To convince yourself of this, try to
use the @samp{step} statement

@example
step 1, -1
@end example

@noindent
on this system.  How does @code{ode} react?

As another example of ill-posedness, consider the system

@example
@math{y'=1/y}
@end example

which is undefined at @math{y=0}.  The general solution is

@ifnottex
@example
@math{y = +/- (2(t-C))^(1/2)},
@end example
@end ifnottex
@tex
@example
$y = \pm (2(t-C))^{1/2}$,
@end example
@end tex

@ifnottex
so that if the condition @math{y(2)=2} is imposed, the solution will be
@math{(2t)^(1/2)}.  Clearly, if the domain specified in a @samp{step}
statement includes negative values @w{of @math{t}}, the generated
solution will be bogus.
@end ifnottex
@tex
so that if the condition @math{y(2)=2} is imposed, the solution will be
$(2t)^{1/2}$.  Clearly, if the domain specified in a @samp{step}
statement includes negative values @w{of @math{t}}, the generated
solution will be bogus.
@end tex

In general, when using a constant stepsize you should be careful not to
@w{`step over'} bad points or bad regions.  When allowed to choose a
stepsize adaptively, @code{ode} will often spot bad points, but not
always.

@item 
Critical points.

An @emph{autonomous} system is one that does not include the independent
variable explicitly on the right-hand side of any differential equation.
A @emph{critical point} for such a system is a point at which all
right-hand sides equal zero.  For example, the system

@example
@group
@math{y' = 2x}
@math{x' = 2y}
@end group
@end example

has only one critical point, at @math{(x,y) = (0,0)}.

A critical point is sometimes referred to as a @emph{stagnation point}.
That is because a system at a critical point will remain there forever,
though a system near a critical point may undergo more violent motion.
Under some circumstances, passing near a critical point may give rise to
a large accumulated error.

As an exercise, solve the system above using @code{ode}, with the
initial condition @math{x(0) = y(0) = 0}.  The solution should be
constant in time.  Now do the same with points near the critical point.
What happens?

You should always locate the critical points of a system before
attempting a solution with @code{ode}.  Critical points may be
classified (as equilibrium, vortex, unstable, stable, etc.) and this
classification may be @w{of use}.  To find out more about this, consult
any book dealing with the qualitative theory of differential equations
(e.g., Birkhoff and Rota's @cite{Ordinary Differential Equations},
@w{Chapter 6}).

@item 
Unsuitable numerical schemes

If the results produced by @code{ode} are bad in the sense that
instability appears to be present, or an unusually small stepsize needs
to be chosen needed in order to reduce the single-step error to
manageable levels, it may simply be that the numerical scheme being used
is not suited to the problem.  @w{For example}, @code{ode} currently has
no numerical scheme which handles so-called `stiff' problems very well.

As an example, you may wish to examine the stiff problem:

@example
@group
@math{y' = -100 + 100t + 1}
@math{y(0) = 1}
@end group
@end example

@noindent
on the domain @math{[0,1]}.  The exact solution is

@ifnottex
@example 
@math{y(t) = e^(-100t) + t}.
@end example
@end ifnottex
@tex
@example 
$y(t) = e^{-100t} + t$.
@end example
@end tex

@noindent
It is a useful exercise to solve this problem with @code{ode} using
various numerical schemes, stepsizes, and relative single-step error
bounds, and compare the generated solution curves with the actual
solution.
@end enumerate

There are several rough and ready heuristic checks you may perform on
the accuracy of any numerical solution produced by @code{ode}.  We
discuss them @w{in turn}.

@enumerate
@item Examine the stability of  solution curves: do they converge?

That is, check how changing the stepsize affects a solution curve.  As
the stepsize decreases, the curve should converge.  If it does not, then
the stepsize is not small enough or the numerical scheme is not suited
to the problem.  In practice, you would proceed as follows.

@itemize @bullet
@item
If using an adaptive stepsize, superimpose the solution curves for
successively smaller bounds on the relative single-step error (obtained
with, e.g., @samp{-r 1e-9}, @samp{-r 1e-11}, @samp{-r 1e-13}, @dots{}).
If the curves converge then the solution is to all appearances stable,
and your accuracy is sufficient.

@item
If employing a constant stepsize, perform a similar analysis by
successively halving the stepsize.
@end itemize

The following example is one that you may wish to experiment with.  Make
a file named @file{qcd} containing:

@example
@group
# an equation arising in QCD (quantum chromodynamics)
f'   = fp
fp'  = -f*g^2
g'   = gp
gp'  = g*f^2
f = 0; fp = -1; g = 1; gp = -1
@end group

@group
print t, f
step 0, 5
@end group
@end example

@noindent
Next make a file named @file{stability}, containing the lines:

@example
@group
: sserr is the bound on the relative single-step error
for sserr
do
ode -r $sserr < qcd
done | spline -n 500 | graph -T X -C
@end group
@end example

This is a `shell script', which when run will superimpose numerical
solutions with specified bounds on the relative single-step error.  To
run it, type:

@example
sh stability 1 .1 .01 .001
@end example

and a plot of the solutions with the specified error bounds will be
drawn.  The convergence, showing stability, should be quite
illuminating.

@item Check invariants of the system: are they constant?

Many systems have invariant quantities.  For example, if the system is a
mathematical model of a `conservative' physical system then the `energy'
(@w{a particular} function of the dependent variables of the system)
should be constant in time.  In general, knowledge about the qualitative
behavior of any dependent variable may be used to check the quality of
the solution.

@item Check a family of solution curves: do they diverge?

A rough idea of how error is propagated is obtained by viewing a family
of solution curves about the numerical solution in question, obtained by
varying the initial conditions.  @w{If they} diverge sharply---@w{that
is}, if two solutions which start out very close nonetheless @w{end up}
far apart---then the quality of the numerical solution is dubious.
@w{On the} other hand, if the curves do not diverge sharply then any
error that is present will in all likelihood not increase by more than
an order of magnitude @w{or so} over the interval.  Problems exhibiting
no sharp divergence of neighboring solution curves are sometimes called
@emph{well-conditioned}.
@end enumerate

@node Running Time, Input Language, Numerical Error, ode
@section Running time

The time required for @code{ode} to solve numerically a system of
ordinary differential equations depends on a great many factors.  @w{A
few} of them are: number of equations, complexity of equations (number
of operators and nature of the operators), and number of steps taken
(@w{a very} complicated function of the difficulty of solution, unless
constant stepsizes are used).  The most effective way to gauge the time
required for solution of a system is to clock a short or imprecise run
of the problem, and reason as follows: the time required to take two
steps is roughly twice that required for one; and there is a
relationship between the number of steps required and the relative error
ceiling chosen.  That relationship depends on the numerical scheme being
used, the difficulty of solution, and perhaps on the magnitude of the
error ceiling itself.  @w{A few} carefully planned short runs may be
used to determine this relationship, enabling a long but imprecise run
to be used as an aid in projecting the cost of a more precise run over
the same region.  Lastly, if a great deal of data is printed, @w{it is}
likely that more time is spent in printing the results than in computing
the numerical solution.

@node Input Language, ODE Bibliography, Running Time, ode
@section The @code{ode} input language formally specified

The following is a formal specification of the grammar for @code{ode}'s
input language, in Backus--Naur form.  Nonterminal symbols in the
grammar are enclosed in angle brackets.  Terminal tokens are in all
capitals.  Bare words and symbols stand for themselves.

@example
@group
<program>    ::=        ... empty ...
               |  <program> <statement>
@end group


@group
<statement>  ::=  SEP
               |  IDENTIFIER = <const> SEP
               |  IDENTIFIER ' = <expression> SEP
               |  print <printlist> <optevery> <optfrom> SEP
               |  step <const> , <const> , <const> SEP
               |  step <const> , <const> SEP
               |  examine IDENTIFIER SEP
@end group


@group
<printlist>  ::=  <printitem>
               |  <printlist> , <printitem>
@end group


@group
<printitem>  ::=  IDENTIFIER
               |  IDENTIFIER '
               |  IDENTIFIER ?
               |  IDENTIFIER !
               |  IDENTIFIER ~
@end group


@group
<optevery>   ::=        ... empty ...
               |  every <const>
@end group


@group
<optfrom>    ::=        ... empty ...
               |  from <const>
@end group


@group
<const>      ::=  <expression>
@end group


@group
<expression> ::=  ( <expression> )
               |  <expression> + <expression>
               |  <expression> - <expression>
               |  <expression> * <expression>
               |  <expression> / <expression>
               |  <expression> ^ <expression>
               |  FUNCTION ( <expression> )
               |  - <expression>
               |  NUMBER
               |  IDENTIFIER
@end group
@end example

@noindent
Since this grammar is ambiguous, the following table summarizes the
precedences and associativities of operators within expressions.
Precedences decrease from top to bottom.

@example
@group
Class           Operators    Associativity

Exponential         ^            right
Multiplicative      * /          left
Additive            + -          left
@end group
@end example

As noted in the grammar, there are six types of nontrivial statement.
We now explain the effects (the `semantics') of each type, @w{in turn}.

@enumerate
@item 
@t{IDENTIFIER ' = <expression>}

@noindent This defines a first-order differential equation.  
The derivative of @t{IDENTIFIER} is specified by @t{<expression>}.  If a
dynamic variable does not appear on the left side of a statement of this
form, its derivative is assumed to be zero.  That is, @w{it is} a
symbolic constant.

@item 
@t{IDENTIFIER = <const>}

@noindent
This sets the value of @t{IDENTIFIER} to the current value of
@t{<expression>}.  Dynamic variables that have not been initialized in
this way are set to zero.

@item 
@t{step <const> , <const>}
@item 
@t{step <const> , <const> , <const>}

@noindent
A @samp{step} statement causes the numerical scheme to be executed.  The
first @t{<const>} is the initial value of the independent variable.  The
second is its final value.  The third is a stepsize; if given, it
overrides any stepsize that may be specified on the command line.
Usually the stepsize is not specified, and it varies adaptively as the
computation proceeds.

@item 
@t{print <printlist> [ every <const> ] [ from <const> ]}

@noindent
A @samp{print} statement controls the content and frequency of the
numerical output.  @t{<printlist>} is a comma-separated list of
@t{IDENTIFIER}s, where each @t{IDENTIFIER} may be followed by @samp{'},
denoting the derivative, or @samp{?}, denoting the relative single-step
error, or @samp{!}, denoting the absolute single-step error, or
@samp{~}, denoting the accumulated error (not currently implemented).
The specified values are printed in the order they are found.  Both the
@samp{every} clause and the @samp{from} clause are optional.  @w{If the}
@samp{every} clause is present, a printing occurs every @t{<const>}
iterations of the numerical algorithm.  The default is to print on every
iteration (i.e.@: @samp{every 1}).  The first and last values are always
printed.  @w{If the} @samp{from} clause is present, it means to begin
printing when the independent variable reaches or exceeds @t{<const>}.
The default is to begin printing immediately.

If no @samp{print} statement has been supplied, then the independent
variable and all dependent variables which have differential equations
associated with them are printed.  The independent variable is printed
first; the dependent variables follow in the order their equations were
given.

@item 
@t{examine IDENTIFIER}

@noindent
An @samp{examine} statement, when executed, causes a table of
interesting information about the named variable to be printed on the
standard output.  For example, if the statement @samp{examine y} were
encountered after execution of the `ode to Euler' example discussed
elsewhere, the output would be:

@example
@group
"y" is a dynamic variable
value:2.718282
prime:2.718282
sserr:1.121662e-09
aberr:3.245638e-09
acerr:0
 code:  push "y"
@end group
@end example

The phrase `dynamic variable' means that there is a differential
equation describing the behavior @w{of @t{y}}.  The numeric items in the
table are:

@table @t
@item value
Current value of the variable.

@item prime   
Current derivative of the variable.

@item sserr   
Relative single-step error for the last step taken.

@item aberr   
Absolute single-step error for the last step taken.

@item acerr   
Total error accumulated during the most recent @samp{step} statement.
Not currently implemented.
@end table

The @samp{code} section of the table lists the stack operations required
to compute the derivative @w{of @t{y}} (somewhat reminiscent of a
reverse Polish calculator).  This information may be useful in
discovering whether the precedences in the differential equation
statement were interpreted correctly, or in determining the time or
space expense of a particular calculation.  @samp{@t{push "y"}} means to
load @t{y}'s value on the stack, which is all that is required to
compute its derivative in this case.
@end enumerate

The grammar for the @code{ode} input language contains four types of
terminal token: @t{FUNCTION}, @t{IDENTIFIER}, @t{NUMBER}, @w{and
@t{SEP}}.  They have the following meanings.

@enumerate
@item
@t{FUNCTION}

One of the words: @t{abs}, @t{sqrt}, @t{exp}, @t{log}, @t{ln},
@t{log10}, @t{sin}, @t{cos}, @t{tan}, @t{asin}, @t{acos}, @t{atan},
@t{sinh}, @t{cosh}, @t{tanh}, @t{asinh}, @t{acosh}, @t{atanh},
@t{floor}, @t{ceil}, @t{besj0}, @t{besj1}, @t{besy0}, @t{besy1},
@t{erf}, @t{erfc}, @t{inverf}, @t{lgamma}, @t{gamma}, @t{norm},
@t{invnorm}, @t{ibeta}, @t{igamma}.  These are defined to have the same
meaning as in the plotting program @code{gnuplot}.  All functions take a
single argument, except for @t{ibeta}, which takes three, and
@t{igamma}, which takes two.  For trigonometric functions, all arguments
are expressed in radians.  The @t{atan} function is defined to give a
value between @minus{}PI/2 and PI/2 (inclusive).

@item
@t{IDENTIFIER}

A sequence of alphanumeric characters starting with an alphabetic
character.  The first 32 characters are significant.  Upper and
lower-case letters are distinct.  In identifiers, the underscore
character is considered alphabetic.  Function names and keywords may not
be used as identifiers, nor may @samp{PI}@.

@item
@t{NUMBER}

A non-empty sequence of digits possibly containing a decimal point and
possibly followed by an exponent.  An exponent is @samp{e} @w{or
@samp{E}}, followed by an (optionally signed) one, two, or three-digit
number.  All numbers and all parts of numbers are @w{radix 10}.  @w{A
number} may not contain any white space.  The special word @samp{PI} is
a number.

@item
@t{SEP}

A separator: a semicolon or a (non-escaped) newline.
@end enumerate

In the @code{ode} input language, upper and lower-case letters are
distinct.  Comments begin with the character @samp{#} and continue to
the end of the line.  Long lines may be continued onto a second line by
ending the first line with a @w{backslash (@samp{\})}.  That is because
the combination backslash-newline is equivalent to a space.  

Spaces or tabs are required in the input whenever they are needed to
separate identifiers, numbers, and keywords from one another.  Except as
separators, they are ignored.

@node ODE Bibliography, , Input Language, ode
@section Bibliography on @code{ode} and solving differential equations

@itemize @asis
@item
K. E. Atkinson, @cite{An Introduction to Numerical Analysis}, Wiley,
1978.  @w{Chapter 6} contains a discussion of the literature on the
numerical solution of ordinary differential equations.

@item
G. Birkhoff and G. Rota, @cite{Ordinary Differential Equations}, 4th
ed., Wiley, 1989.

@item
N. B. Tufillaro, T. Abbott, and J. Reilly, @cite{An Experimental
Approach to Nonlinear Dynamics and Chaos}, Addison--Wesley, 1992.
@w{Appendix C} discusses an earlier version of @code{ode}.

@item
N. B. Tufillaro, E. F. Redish, and J. S. Risley, ``@code{ode}: @w{A
numerical} simulation of ordinary differential equations,'' 
pp.@: 480--481 in @cite{Proceedings of the Conference on Computers in 
Physics Instruction}, Addison--Wesley, 1990.
@end itemize

@node libplot, Appendices, ode, Top
@chapter @code{libplot}, a 2-D Vector Graphics Library

@ifnottex
This is the documentation for version 4.1 of GNU libplot, which is
a free function library for drawing two-dimensional vector graphics.
@end ifnottex

@menu
* libplot Overview::    Programming with libplot: An overview
* C Programming::       C programming with libplot
* C++ Programming::     C++ programming with libplotter
* Functions::           A list of functions contained in libplot
* Plotter Parameters::  Plotter parameters
@end menu

@node libplot Overview, C Programming, libplot, libplot
@section Programming with @code{libplot}: An overview

GNU @code{libplot} 4.1 is a free function library for drawing
two-dimensional vector graphics.  It can produce smooth, double-buffered
animations for the @w{X Window} System, and can export graphics files in
many file formats.  @w{It is} `device-independent' in the sense that its
API (application programming interface) is to a large extent independent
of the display type or output file format.  The API is thread-safe, so
it may be used in multithreaded programs.

There are bindings for C, C++, and other languages.  The @w{C binding},
which is the most frequently used, is also called @code{libplot}, and
the C++ binding, when it needs to be distinguished, is called
@code{libplotter}.  @w{In this} section we use @code{libplot} to refer
to the library itself, irrespective of binding.

The graphical objects that @code{libplot} can draw include paths,
`adjusted labels' (i.e., justified text strings), marker symbols, and
points (i.e., pixels).  Paths may be simple or compound.  @w{A simple}
path is a contiguous sequence of line segments, circular arcs, elliptic
arcs, quadratic Bezier curves, and/or cubic Bezier curves.  @w{A simple}
path may also be a circle, an ellipse, or a rectangle.  @w{A compound}
path consists of one or more nested simple paths.  User-specified
filling of paths, both simple and compound, is supported (fill color and
fill rule, @w{as well} as pen color, may be specified).

There is support for maintaining a Postscript-style stack of graphics
contexts, i.e., @w{a stack} of drawing attribute sets.  Path-related
attributes include pen color, line thickness, line type, cap type, join
type, miter limit, fill color, fill rule, and transformation matrix, and
text-related attributes include font name, font size, text angle, and
transformation matrix.

The fundamental abstraction provided by @code{libplot} is that of a
@emph{Plotter}.  A Plotter is an object with an interface for the
drawing of vector graphics which is similar to the interface provided by
a traditional pen plotter.  There are many types of Plotter, which
differ in the output format they produce.  Any number of Plotters, of
the same or different types, may exist simultaneously in an application.

The drawing operations supported by Plotters of different types are
identical, in agreement with the principle of device independence.
@w{So a} graphics application that is linked with @code{libplot} may
easily be written so as to produce output in any or all of the
supported output formats.

The following are the currently supported types of Plotter.

@itemize @bullet
@item 
X Plotters.  An X Plotter, when opened, pops up a window on an @w{X
Window} System display and draws graphics @w{in it}.  The window will be
`@w{spun off}' when the Plotter is closed; if it is subsequently
reopened, a new window will be @w{popped up}.  A spun-off window will
remain on the screen but will vanish if you type @samp{q} or click your
mouse @w{in it}.  Future releases may permit @w{X Plotters}, when
reopened, to reuse an existing window.

@item 
X Drawable Plotters.  An X Drawable Plotter draws graphics in one or two
specified drawables associated with an @w{X Window System} display.
@w{A `drawable'} is either a window or a pixmap.  The drawables must be
passed to the Plotter as parameters.  (@xref{Plotter Parameters}.)

@item
PNG Plotters.  A PNG Plotter produces a single page of output in PNG
(Portable Network Graphics) format, and directs it to a file or other
specified output stream.  The file may be viewed or edited with many
applications, such as the free image display application @code{xv} and
the free @code{ImageMagick} package.

@item
PNM Plotters.  A PNM Plotter produces a single page of output in
``portable anymap'' format, and directs it to a file or other specified
output stream.  There are three types of portable anymap: PBM (portable
bitmap, for monochrome graphics), PGM (portable graymap), and PPM
(portable pixmap, for colored graphics).  The output file will be in
whichever of these three formats is most appropriate.  The file may be
viewed or edited with many applications, such as @code{xv} and the
@code{ImageMagick} package.

@item
GIF Plotters.  A GIF Plotter produces a single page of output in a
pseudo-GIF format.  Unlike true GIF format, the pseudo-GIF format does
not use LZW compression: @w{it uses} run-length encoding instead.  @w{So
it} does not transgress the Unisys patent that restricts the use of LZW
compression.  However, the output file may be viewed or edited with any
application that understands GIF format, such as @code{xv} and the
@code{ImageMagick} package.  The creation of animated pseudo-GIFs is
supported.

@item
SVG Plotters.  An SVG Plotter produces a single page of output in
Scalable Vector Graphics format and directs it to a file or other
specified output stream.  SVG is a new XML-based format for vector
graphics on the Web, which is being developed by the
@uref{http://www.w3.org/Graphics, Graphics Activity} of the
@uref{http://www.w3.org, @w{W3 Consortium}}.  The output conforms to the
@w{3 March} 2000 version of the SVG specification.

@item
Illustrator Plotters.  An Illustrator Plotter produces a single page of
output in the format used by Adobe Illustrator, and directs it to a file
or other specified output stream.  The file may be edited with Adobe
Illustrator (@w{version 5}, and more recent versions), or other
applications.

@item 
Postscript Plotters.  A Postscript Plotter produces Postscript output
and directs it to a file or other specified output stream.  If only a
single page of graphics is drawn on the Plotter then its output is in
EPS (encapsulated Postscript) format, so it may be included in another
document.  @w{It may} also be edited with the free @code{idraw} drawing
editor.  See @ref{idraw}.

@item
CGM Plotters.  A CGM Plotter produces output in Computer Graphics
Metafile format and directs it to a file or other specified output
stream.  By default, binary-encoded @w{version 3} CGM format is used.
The output complies with the WebCGM profile for Web-based vector
graphics, so it may be displayed in any Web browser with WebCGM support.
The @uref{http://www.cgmopen.org, CGM Open Consortium} has more
information on WebCGM.

@item 
Fig Plotters.  A Fig Plotter produces a single page of output in Fig
format and directs it to a file or other specified output stream.  The
output may be edited with the free @code{xfig} drawing editor.  The
@code{xfig} editor can export drawings in various other formats for
inclusion in documents.  See @ref{xfig}.

@item 
PCL Plotters.  A PCL Plotter produces output in @w{PCL 5} format and
directs it to a file or other specified output stream.  @w{PCL 5} is a
powerful version of Hewlett--Packard's Printer Control Language, which
supports vector graphics.  The output may be sent to a @w{PCL 5} device
such as a LaserJet printer or high-end inkjet.

@item
HP-GL Plotters.  An HP-GL Plotter produces output in the
Hewlett--Packard Graphics Language (@w{by default}, in HP-GL/2), and
directs it to a file or other specified output stream.  The output may
be imported into another application, or sent to a plotter.

@item
ReGIS Plotters.  A ReGIS Plotter produces output in ReGIS (remote
graphics instruction set) format and directs it to a file or other
specified output stream.  The output may be displayed on any terminal or
emulator that understands ReGIS format.  This includes several terminals
from DEC (in particular, the VT340, VT330, VT241, and VT240 terminals),
and @code{dxterm}, the DECwindows terminal emulation program.

@item
Tektronix Plotters.  A Tektronix Plotter produces output in Tektronix
4014 format and directs it to a file or other specified output stream.
The output may be displayed on any Tektronix 4014 emulator.  Such an
emulator is built into @code{xterm}, the @w{X Window} System terminal
emulation program.  The MS-DOS version of @code{kermit} also includes
such an emulator.

@item
Metafile Plotters.  A Metafile Plotter produces output in GNU graphics
metafile format and directs it to a file or other specified output
stream.  This format is an extended version of the `plot(5)' format
found on some other operating systems.  (@xref{Metafiles}.)  @w{It may}
be translated to other formats by an invocation of GNU @code{plot}.
(@xref{plot}.)
@end itemize

A distinction among these types of Plotter is that all except X and @w{X
Drawable} Plotters write graphics to a file or other output stream.  An
@w{X Plotter} @w{pops up} its own windows, and an @w{X Drawable} Plotter
draws graphics in one or two @w{X drawables}.

Another distinction is that the first five types of Plotter (X, @w{X
Drawable}, PNG, PNM, and GIF) produce bitmap output, while the remaining
types produce output in a vector graphics format.  In bitmap output the
structure of the graphical objects is lost, but in a vector format it is
retained.

An additional distinction is that X, X Drawable, ReGIS, Tektronix and
Metafile Plotters are real-time.  This means that they draw graphics or
write to an output stream as the drawing operations are invoked on them.
The remaining types of Plotter are not real-time, since their output
streams can only be emitted after all functions have been called.  For
PNM and GIF Plotters, this is because the bitmap must be constructed
before it is written out.  For Illustrator and Postscript Plotters,
@w{it is} because a `bounding box' line must be placed at the head of
the output file.  For a Fig Plotter, @w{it is} because color definitions
must be placed at the head of the output file.

The most important operations supported by any Plotter are @code{openpl}
and @code{closepl}, which open and @w{close it}.  Graphics may be drawn,
and drawing attributes set, only within an
@code{openpl}@dots{}@code{closepl} pair.  The graphics produced within
each @code{openpl}@dots{}@code{closepl} pair constitute a `page'.  In
principle, any Plotter may be opened and closed arbitrarily many times.
An @w{X Plotter} displays each page in a separate @w{X window}, and
Postscript, PCL, and HP-GL Plotters render each page as a separate
physical page.  @w{X Drawable}, ReGIS and Tektronix Plotters manipulate
a single drawable or display, on which pages are displayed in
succession.  Plotters that do not draw in real time (PNG, PNM, GIF,
Illustrator, Postscript, CGM, Fig, PCL, and HP-GL Plotters) may wait
until their existence comes to an end (i.e., until they are deleted)
before outputting their pages of graphics.

In the current release of @code{libplot}, Postscript and CGM Plotters
delay outputting graphics in this way, but PCL and HP-GL Plotters output
each page of graphics individually, i.e., when @code{closepl} is
invoked.  PNG, PNM, GIF, SVG, Illustrator and Fig Plotters are similar,
but output only the first page.  That is because PNG, PNM, GIF, SVG,
Illustrator and Fig formats support only a single page of graphics.

The graphics display, or `viewport', that is @w{drawn in} by a Plotter
is normally a square or rectangular region on its output device.  But
when using any Plotter to draw graphics, @w{a user} will specify the
coordinates of graphical objects in device-independent `user'
coordinates, not in device coordinates.  @w{A Plotter} transforms user
coordinates to device coordinates by performing an affine
transformation.

After invoking @code{openpl} to open a Plotter, an application would
usually invoke @code{space}.  @code{space} specifies a rectangular
`window' in the user coordinate system that will be mapped affinely to
the viewport on the output device.  (The default window is a square,
with opposite corners (0,0) @w{and (1,1)}.)  The transformation from
user coordinates to device coordinates may be updated at any later time
by reinvoking @code{space}, or by invoking @code{fconcat}.  The
@code{fconcat} operation will concatenate (i.e., compose) the current
affine transformation with any specified affine transformation.  This
sort of concatenation is a capability familiar from, e.g., Postscript.

Each Plotter maintains a Postscript-style stack of graphics contexts.
This makes possible the rapid, efficient drawing of complicated pages of
graphics.  @w{A graphics} context includes the current affine
transformation from user coordinates to device coordinates.  @w{It also}
includes such modal drawing attributes as graphics cursor position, pen
color, line type, line thickness, fill color, and the font used for
drawing text.  The state of any uncompleted path @w{(if any)} is
included @w{as well}, since paths may be drawn incrementally, one
portion (line segment, arc, or Bezier curve) at a time.

@strong{Warning}: Much as in Postscript, the current graphics context
may be pushed onto the stack by calling @code{savestate}, and @w{popped
off} by calling @code{restorestate}.  However, @code{libplot}'s and
Postscript's drawing models are significantly different.  In
@code{libplot}, the new graphics context created by @code{savestate}
contains no path.  So a new path may be constructed @w{in it} from
scratch, and drawn.  Afterwards, the path in the former graphics context
will be @w{returned to} when @code{restorestate} is called, at which
time it may be extended further.  Another difference from Postscript is
that in @code{libplot}, there is no need to start a new path by calling
a `@code{newpath}' function.  Instead, you just start drawing.  @w{At
least} in theory, you do need to end a path explicitly, by calling
@code{endpath} to request that it be drawn on the graphics display.  But
the call to @code{endpath} can usually be omitted.  For example, calling
@code{restorestate} automatically invokes @code{endpath} to end the path
(@w{if any}) contained in the current graphics context.

To permit vector graphics animation, any page of graphics may be split
into `frames'.  @w{A frame} is ended, and a new frame is begun, by
invoking the @code{erase} operation.  This first terminates the path
under construction, @w{if any}.  What then happens depends on whether
the Plotter does real-time plotting.  @w{If it} does (i.e., if the
Plotter is @w{an X}, @w{X Drawable}, ReGIS, Tektronix, or Metafile
Plotter), @code{erase} removes all plotted objects from the graphics
display, allowing a new frame to be drawn.  Displaying a sequence of
frames in succession creates the illusion of smooth animation.

@w{On most} Plotters that do not do real-time plotting (i.e., PNG, PNM,
SVG, Illustrator, Postscript, CGM, Fig, PCL, or HP-GL Plotters),
invoking @code{erase} deletes all plotted objects from an internal
buffer.  For this reason, most Plotters that do not do real-time
plotting will display only the final frame of any multiframe page.

GIF Plotters are in a class by themselves.  Even though they do not do
real time plotting, @w{a GIF} Plotter can produce multi-image output,
i.e., an animated pseudo-GIF file, from a multiframe page.  @w{As noted}
above, the pseudo-GIF file produced by a GIF Plotter will contain only
the first page of graphics.  But if this page consists of multiple
frames, then each invocation of @code{erase} after the first will be
treated, @w{by default}, as a separator between successive images.

@node C Programming, C++ Programming, libplot Overview, libplot
@section C Programming with @code{libplot}

@menu
* The C API::                   The C application programming interface
* Older C APIs::                Older C interfaces
* C Compiling and Linking::     C compiling and linking
* Sample C Drawings::           Sample drawings in C
* Paths and Subpaths::          Simple paths and compound paths
* Drawing on a Page::           Drawing on a physical page
* Animated GIFs::               Animated GIFs in C
* X Animations::                X Window System animations in C
* X Programming::		Advanced X Window System programming
@end menu

@node The C API, Older C APIs, C Programming, C Programming
@subsection The C application programming interface

GNU @code{libplot} has bindings for several programming languages.
Regardless of which binding is used, the concepts behind @code{libplot}
(Plotters, and a fixed set of operations that may be applied to any
Plotter) remain the same.  However, the ways in which Plotters are
manipulated (created, selected @w{for use}, and deleted) may differ
between bindings.  This section discusses the current @w{C binding}.
For information on older @w{C bindings}, see @ref{Older C APIs}.

In the @w{C binding}, a Plotter is implemented as an opaque datatype,
@code{plPlotter}, which must be accessed through a pointer.  Each
drawing operation takes a pointer to a @code{plPlotter} as its first
argument.  The functions @code{pl_newpl_r} and @code{pl_deletepl_r} are
the constructor and destructor for the @code{plPlotter} datatype.  The
final argument of @code{pl_newpl_r} must be a pointer to a
@code{plPlotterParams} object, which specifies Plotter parameters.
@code{pl_newpl_r} returns a pointer to a @code{plPlotter}.

You should always call @code{pl_deletepl_r} when you are finished using
a Plotter.  In general, Plotters that do not plot graphics in real time
(Postscript Plotters and CGM Plotters in particular) @w{write out}
graphics only when @code{pl_deletepl_r} is called.

The following tables summarize the action of the Plotter manipulation
functions in the @w{C binding}.

@table @asis
@item plPlotter * @t{pl_newpl_r} (const char *@var{type}, FILE *@var{infile}, FILE *@var{outfile}, FILE *@var{errfile}, plPlotterParams *@var{params});
Create a Plotter of type @var{type}, where @var{type} may be "X",
"Xdrawable", "png", "pnm", "gif", "svg", "ai", "ps", "cgm", "fig",
"pcl", "hpgl", "regis", "tek", or "meta".  The Plotter will have input
stream @var{infile}, output stream @var{outfile}, and error stream
@var{errfile}.  Any or all of these three may be NULL@.  Currently, all
Plotters are write-only, so @var{infile} is ignored.  @w{X Plotters} and
@w{X Drawable} Plotters write graphics to an @w{X Window} System display
rather than to an output stream, so if @var{type} is "X" or "Xdrawable"
then @var{outfile} is ignored @w{as well}.  Error messages (@w{if any})
are written to the stream @var{errfile}, unless @var{errfile} is NULL@.

All Plotter parameters will be copied from the @code{plPlotterParams}
object pointed to by @var{params}.  @w{A NULL} return value indicates
the Plotter could not be created.

@item int @t{pl_deletepl_r} (plPlotter *@var{plotter});
Delete the specified Plotter.  A negative return value indicates the
Plotter could not be deleted.
@end table

The functions @code{pl_newplparams}, @code{pl_deleteplparams}, and
@code{pl_copyplparams} are the constructor, destructor, and copy
constructor for the @code{plPlotterParams} datatype.  The function
@code{pl_setplparam} sets any single Plotter parameter in a
@code{plPlotterParams} object.

@table @asis
@item plPlotterParams * @t{pl_newplparams} ();

@item int @t{pl_deleteplparams} (plPlotterParams *@var{plotter_params});

@item plPlotterParams * @t{pl_copyplparams} (const plPlotterParams *@var{params});

@item int @t{pl_setplparam} (plPlotterParams *@var{params}, const char *@var{parameter}, void *@var{value});
Set the value of the parameter @var{parameter} to @var{value} in the
object pointed to by @var{params}.  For most parameters, @var{value}
should be a @code{char *}, i.e., a string.  @w{If @var{value}} is NULL,
the parameter is unset.

For a list of recognized parameters and their meaning, see @ref{Plotter
Parameters}.  Unrecognized parameters are ignored.
@end table

The reason why the @code{plPlotterParams} datatype exists is that even
though the Plotter interface is largely Plotter-independent, @w{it is}
useful to be able to specify certain aspects of a Plotter's behavior at
creation time.  @w{If a} a parameter has been set in the specified
@code{plPlotterParams} object, that will be the value used by the
Plotter.  @w{If a} parameter is @emph{not} set, the Plotter will use a
default value @w{for it}, unless the parameter is string-valued and
there is an environment variable of the same name, in which case the
value of that environment variable will be used.  This rule increases
run-time flexibility: @w{an application} programmer may allow
non-critical Plotter parameters to be specified by the user via
environment variables.

In the C binding, each drawing operation that may be invoked on a
Plotter is represented by a function whose name begins with "pl_" and
ends with "_r".  For example, the @code{openpl} operation is invoked on
a Plotter by calling the function @code{pl_openpl_r}, the first argument
of which is a pointer to the corresponding @code{plPlotter} object.

@node Older C APIs, C Compiling and Linking, The C API, C Programming
@subsection Older C application programming interfaces

The current C API (application programming interface), which is
thread-safe, is a revision of an older API that is not thread-safe.
That is why most functions in the current API have names that end @w{in
"_r"}, which stands for `revised' or `reentrant'.

In the old C API, the Plotter on which an operation was performed is not
specified as an argument of the function that was called to perform the
operation.  Instead, a Plotter is first `selected'.  Then the API
function is called.  @code{pl_openpl} was one such function; @w{it
opens} the currently selected Plotter, i.e., begins a page of graphics.

The old API is deprecated, but is still supported.  The four functions
in the old API that perform Plotter manipulation have the following
semantics.

@table @asis
@item int @t{pl_newpl} (const char *@var{type}, FILE *@var{infile}, FILE *@var{outfile}, FILE *@var{errfile});
Create a Plotter of type @var{type}, where @var{type} may be "X",
"Xdrawable", "png", "pnm", "gif", "svg", "ai", "ps", "fig", "pcl",
"hpgl", "regis", "tek", or "meta".  The Plotter will have input stream
@var{infile}, output stream @var{outfile}, and error stream
@var{errfile}.  The return value is a `handle': @w{a nonnegative}
integer by which the newly created Plotter is @w{referred to}.  @w{A
negative} return value indicates the Plotter could not be created.

@item int @t{pl_selectpl} (int @var{handle});
Select a Plotter, referred to by its handle, for use.  Only one Plotter
may be selected at a time.  @w{A negative} return value indicates the
specified Plotter could not be selected.  Otherwise, the return value is
the handle of the previously selected Plotter.

At startup, a single Metafile Plotter that writes to standard output
(with @w{handle `0'}) is automatically created and selected.

@item int @t{pl_deletepl} (int @var{handle});
Delete a Plotter, specified by its handle.  The Plotter must not be
selected at the time it is deleted.  @w{A negative} return value
indicates the Plotter could not be deleted.

@item int @t{pl_parampl} (const char *@var{parameter}, void *@var{value});
Set the global value of the Plotter parameter @var{parameter} to
@var{value}.  The parameter values @w{in effect} at the time any Plotter
is created will be copied @w{into it}.
@end table

@noindent
In the old API, selecting a Plotter with @code{pl_selectpl} and setting
a value for a Plotter parameter with @code{pl_parampl} are global
operations.  That is why the old API is not thread-safe.

An even older @w{C API} omitted the prefix "pl_" from the names of
@code{libplot} functions.  The prefix "pl_" was added @w{in part} to
distinguish GNU @code{libplot} from pre-GNU versions of @code{libplot}.
@w{If you} need to compile code written for very early versions of GNU
@code{libplot} or for pre-GNU @code{libplot}, you should include the
header file @code{plotcompat.h}.  @code{plotcompat.h} redefines
@code{openpl} as @code{pl_openpl}, and @w{so forth}.  @xref{C Compiling
and Linking}.

@node C Compiling and Linking, Sample C Drawings, Older C APIs, C Programming
@subsection C compiling and linking

The source code for a graphics application written in C, if it is to use
the GNU @code{libplot} @w{C API} (@w{C application} programming
interface), must contain the lines

@example
@group
#include <stdio.h>
#include <plot.h>
@end group
@end example

@noindent
The header file @file{plot.h} is distributed with @code{libplot}, and
should have been installed on your system where your @w{C compiler} will
find it.  @w{It contains} a prototype for each of the functions in the
@w{C API}, and some miscellaneous definitions.

To each Plotter operation there corresponds a function in the @w{C API}
whose name begins with "pl_" and ends @w{with "_r"}.  @w{To invoke} the
Plotter operation, this function would be called.  For example, the
@code{openpl} operation would be invoked on a Plotter by calling the
function @code{pl_openpl_r}, the first argument of which is a pointer to
the Plotter.  All such functions are declared in @file{plot.h}.

In releases of GNU @code{libplot} before @code{libplot} 3.0, Plotter
operations were performed in a different way.  For example, there was a
function @code{pl_openpl} that operated on a Plotter that was
`selected', rather than specified as an argument.  The old @w{C API} is
still supported by @file{plot.h}.  For more information @w{on it}, see
@ref{Older C APIs}.

In even older releases of GNU @code{libplot}, and in the non-GNU
versions of @code{libplot} that preceded it, the "pl_" prefix was not
used.  @w{If you} need to compile code written for early versions of GNU
@code{libplot} or for non-GNU @code{libplot}, you should also include
the header file @code{plotcompat.h}.  That file redefines @code{openpl}
as @code{pl_openpl}, and @w{so forth}.

To link your application with GNU @code{libplot}, you would use the
appropriate @samp{-l} option(s) on the command line when compiling it.
You would use

@example
-lplot -lXaw -lXmu -lXt -lXext -lX11 -lpng -lz -lm
@end example

@noindent
or, in recent releases of the @w{X Window} System,

@example
-lplot -lXaw -lXmu -lXt -lSM -lICE -lXext -lX11 -lpng -lz -lm
@end example

@noindent
These linking options assume that your version of @code{libplot} has
been compiled with PNG support; @w{if not}, you would omit the
@samp{-lpng -lz} options.

As an alternative to the preceding, you may need to use @samp{-lplot
-lXm -lXt -lXext -lX11 -lpng -lz -lm}, @samp{-lplot -lXm -lXt -lXext
-lX11 -lpng -lz -lm -lc -lgen}, or @samp{-lplot -lXm -lXt -lXext -lX11
-lpng -lz -lm -lc -lPW}, on systems that provide Motif widgets instead
of Athena widgets.  In recent releases of the @w{X Window} System, you
would insert @samp{-lSM -lICE}@.  Recent releases of Motif require
@samp{-lXp} and possibly @samp{-lXpm} @w{as well}.)

On some platforms, the directories in which @code{libplot} or the other
libraries are stored must be specified on the command line.  @w{For
example}, the options @samp{-lXaw -lXmu -lXt -lSM -lICE -lXext -lX11},
which specify @w{X Window} System libraries, may need to be preceded by
an option like @samp{-L/usr/X11/lib}.

On most systems @code{libplot} is installed as a shared library.  This
means that the linking with your application will take place at run time
rather than compile time.  The environment variable
@code{LD_LIBRARY_PATH} lists the directories which will be searched for
shared libraries at run time.  For your application to be executable,
this environment variable should include the directory in which
@code{libplot} is stored.

@node Sample C Drawings, Paths and Subpaths, C Compiling and Linking, C Programming
@subsection Sample drawings in C

The following is a sample application, written in C, that invokes GNU
@code{libplot} operations to draw vector graphics.  @w{It draws} an
intricate and beautiful path (Bill Gosper's @w{``C'' curve}, discussed
as Item #135 in @cite{HAKMEM}, MIT Artificial Intelligence Laboratory
Memo #239, 1972).  @w{As the} numeric constant @code{MAXORDER} (here
equal @w{to 12}) is increased, the path will @w{take on} the shape of a
curly @w{letter ``C''}, which is the envelope of a myriad of epicyclic
octagons.

@example
@group
#include <stdio.h>
#include <plot.h>
#define MAXORDER 12
@end group

@group
void draw_c_curve (plPlotter *plotter, double dx, double dy, int order)
@{
  if (order >= MAXORDER)
    /* continue path along (dx, dy) */
    pl_fcontrel_r (plotter, dx, dy);
@end group
@group
  else
    @{
      draw_c_curve (plotter,
                    0.5 * (dx - dy), 0.5 * (dx + dy), order + 1);
      draw_c_curve (plotter,
                    0.5 * (dx + dy), 0.5 * (dy - dx), order + 1);      
    @}
@}
@end group

@group
int main ()
@{
  plPlotter *plotter;
  plPlotterParams *plotter_params;

  /* set a Plotter parameter */
  plotter_params = pl_newplparams ();
  pl_setplparam (plotter_params, "PAGESIZE", "letter");  
@end group

@group
  /* create a Postscript Plotter that writes to standard output */
  if ((plotter = pl_newpl_r ("ps", stdin, stdout, stderr,
                             plotter_params)) == NULL)
    @{
      fprintf (stderr, "Couldn't create Plotter\n");
      return 1;
    @}
@end group

@group
  if (pl_openpl_r (plotter) < 0)      /* open Plotter */
    @{
      fprintf (stderr, "Couldn't open Plotter\n");
      return 1;
    @}
@end group
@group
  pl_fspace_r (plotter, 0.0, 0.0, 1000.0, 1000.0); /* set coor system */
  pl_flinewidth_r (plotter, 0.25);    /* set line thickness */
  pl_pencolorname_r (plotter, "red"); /* use red pen */
@end group
@group
  pl_erase_r (plotter);               /* erase graphics display */
  pl_fmove_r (plotter, 600.0, 300.0); /* position the graphics cursor */
  draw_c_curve (plotter, 0.0, 400.0, 0);
@end group
@group
  if (pl_closepl_r (plotter) < 0)     /* close Plotter */
    @{
      fprintf (stderr, "Couldn't close Plotter\n");
      return 1;
    @}
@end group

@group
  if (pl_deletepl_r (plotter) < 0)    /* delete Plotter */
    @{
      fprintf (stderr, "Couldn't delete Plotter\n");
      return 1;
    @}
  return 0;
@}
@end group
@end example

As you can see, this application begins by creating a
@code{plPlotterParams} object to hold Plotter parameters, and sets the
@code{PAGESIZE} parameter.  @w{It then} calls the @code{pl_newpl_r}
function to create a Postscript Plotter.  The Postscript Plotter will
produce output for a US letter-sized page, though any other standard
page size, e.g., "a4", could be substituted.  This would be arranged by
altering the call to @code{pl_setplparam}.  The @code{PAGESIZE}
parameter is one of several Plotter parameters that an application
programmer may set.  For a list, see @ref{Plotter Parameters}.

After the Plotter is created, the application @w{opens it} and draws the
@w{``C'' curve} recursively.  The drawing of the curve is accomplished
by calling the @code{pl_fmove_r} function to position the Plotter's
graphics cursor, and then calling @code{draw_c_curve}.  This subroutine
repeatedly calls @code{pl_fcontrel_r}.  The @code{pl_fcontrel_r}
function continues a path by adding a line segment @w{to it}.  The
endpoint of each line segment is specified in relative floating point
coordinates, i.e., as a floating point offset from the previous cursor
position.  After the @w{``C'' curve} is drawn, the Plotter is closed by
calling @code{pl_closepl_r}, which automatically invokes
@code{pl_endpath_r} to end the path.  @w{A Postscript} file is written
to standard output when @code{pl_deletepl_r} is called to delete the
Plotter.

Specifying "png", "pnm", "gif", "svg", "ai", "cgm", "fig", "pcl",
"hpgl", "regis", "tek", or "meta" as the first argument in the call to
@code{pl_newpl_r}, instead of "ps", would yield a Plotter that would
write graphics to standard output in the specified format, instead of
Postscript.  The @code{PAGESIZE} parameter is relevant to the "svg",
"ai", "cgm", "fig", "pcl", and "hpgl" output formats, but is ignored for
the others.  Specifying "meta" as the Plotter type may be useful if you
wish to avoid recompilation for different output devices.  Graphics
metafile output may be piped to the @code{plot} utility and converted to
any other supported output format, or displayed in an @w{X window}.
@xref{plot}.

@w{If "X"} were specified as the first argument of @code{pl_newpl_r},
the curve would be drawn in a popped-up @w{X window}, and the output
stream argument would be ignored.  Which @w{X Window} System display the
window would @w{pop up} on would be determined by the @code{DISPLAY}
parameter, or if that parameter were not set, by the @code{DISPLAY}
environment variable.  The size of the @w{X window} would be determined
by the @code{BITMAPSIZE} parameter, or if that parameter were not set,
by the @code{BITMAPSIZE} environment variable.  The default value is
"570x570".  For the "png", "pnm", and "gif" Plotter types, the
interpretation of @code{BITMAPSIZE} is similar.

You could also specify "Xdrawable" as the Plotter type.  For you to make
this work, you would need to know a bit about @w{X Window} System
programming.  You would need to create @w{at least} one @w{X drawable}
(i.e., window or a pixmap), and by invoking @code{pl_setplparam} before
@code{pl_newpl_r} is called, set it as the value of the parameter
@code{XDRAWABLE_DRAWABLE1} or @code{XDRAWABLE_DRAWABLE2}.  For the
parameters that affect @w{X Drawable} Plotters, see @ref{Plotter
Parameters}.

The following is another sample application, written in C, that invokes
@code{libplot} operations to draw vector graphics.  @w{It draws} a
spiral consisting of elliptically boxed text strings, each of which
reads "GNU libplot!".  This figure will be sent to standard output in
Postscript format.

@example
@group
#include <stdio.h>
#include <plot.h>
#include <math.h>
#define SIZE 100.0   /* nominal size of user coordinate frame */
#define EXPAND 2.2   /* expansion factor for elliptical box */
@end group

@group
void draw_boxed_string (plPlotter *plotter, 
                        char *s, double size, double angle)
@{
  double true_size, width;

  pl_ftextangle_r (plotter, angle);      /* set text angle (degrees) */
  true_size = pl_ffontsize_r (plotter, size);  /* set font size */
  width = pl_flabelwidth_r (plotter, s); /* compute width of string */
  pl_fellipserel_r (plotter, 0.0, 0.0, 
                    EXPAND * 0.5 * width, EXPAND * 0.5 * true_size,
                    angle);              /* draw surrounding ellipse */
  pl_alabel_r (plotter, 'c', 'c', s);    /* draw centered text string */
@}
@end group

@group
int main()
@{
  plPlotter *plotter;
  plPlotterParams *plotter_params;
  int i;
@end group

@group
  /* set a Plotter parameter */
  plotter_params = pl_newplparams ();
  pl_setplparam (plotter_params, "PAGESIZE", "letter");  
@end group

@group
  /* create a Postscript Plotter that writes to standard output */
  if ((plotter = pl_newpl_r ("ps", stdin, stdout, stderr,
                             plotter_params)) == NULL)
    @{
      fprintf (stderr, "Couldn't create Plotter\n");
      return 1;
    @}
@end group

@group
  if (pl_openpl_r (plotter) < 0)      /* open Plotter */
    @{
      fprintf (stderr, "Couldn't open Plotter\n");
      return 1;
    @}
@end group
@group
  /* specify user coor system */
  pl_fspace_r (plotter, -(SIZE), -(SIZE), SIZE, SIZE);
  pl_pencolorname_r (plotter, "blue");     /* use blue pen */
  pl_fillcolorname_r (plotter, "white");   /* set white fill color */
  pl_filltype_r (plotter, 1);   /* fill ellipses with fill color */
  /* choose a Postscript font */
  pl_fontname_r (plotter, "NewCenturySchlbk-Roman");
@end group
  
@group
  for (i = 80; i > 1; i--)      /* loop through angles */
    @{
      double theta, radius;
@end group
      
@group
      theta = 0.5 * (double)i;  /* theta is in radians */
      radius = SIZE / pow (theta, 0.35);  /* this yields a spiral */
      pl_fmove_r (plotter, radius * cos (theta), radius * sin (theta));
      draw_boxed_string (plotter, "GNU libplot!", 0.04 * radius,
                         (180.0 * theta / M_PI) - 90.0);
    @}
@end group

@group
  if (pl_closepl_r (plotter) < 0)        /* close Plotter */
    @{
      fprintf (stderr, "Couldn't close Plotter\n");
      return 1;
    @}
@end group
@group
  if (pl_deletepl_r (plotter) < 0)       /* delete Plotter */
    @{
      fprintf (stderr, "Couldn't delete Plotter\n");
      return 1;
    @}
  return 0;
@}
@end group
@end example

This example shows what is involved in plotting a text string or text
strings.  First, the desired font must be retrieved.  @w{A font} is
fully specified by calling @code{pl_fontname_r}, @code{pl_fontsize_r},
and @code{pl_textangle_r}, or their floating point counterparts
@code{pl_ffontname_r}, @code{pl_ffontsize_r}, and
@code{pl_ftextangle_r}.  Since these three functions may be called in
any order, each of them returns the size of the font that it selects, as
a convenience to the programmer.  This may differ slightly from the size
specified in the most recent call to @code{pl_fontsize_r} or
@code{pl_ffontsize_r}, since many Plotters have only a limited repertory
of fonts.  The above example plots each text string in the
"NewCenturySchlbk-Roman" font, which is available on Postscript
Plotters.  @xref{Text Fonts}.

If you replace "ps" by "X" in the call to @code{pl_newpl_r}, an @w{X
Plotter} rather than a Postscript Plotter will be used, and the spiral
will be drawn in a popped-up @w{X window}.  If your @w{X display} does
not support the "NewCenturySchlbk-Roman" font, you may substitute any
other scalable font, such as the widely available
"utopia-medium-r-normal".  For the format of font names, see @ref{Text
Fonts in X}@.  @w{If the} @w{X Plotter} is unable to retrieve the font
you specify, it will first attempt to use a default scalable font
("Helvetica"), and if that fails, use a default Hershey vector font
("HersheySerif") instead.  Hershey fonts are constructed from line
segments, so each built-in Hershey font is available on all types of
Plotter.

If you are using an older (pre-X11R6) @w{X Window} System display, you
will find that retrieving a scalable font is a time-consuming operation.
The above example may run slowly on some older @w{X displays}, since a
new font must be retrieved before each text string is drawn.  That is
because each text string has a different angle of inclination.  @w{It
is} possible to retrieve individual characters from an X11R6 display,
rather than retrieving an entire rasterized font.  @w{If this} feature
is available, the @w{X Plotter} will automatically take advantage @w{of
it} to save time.

@node Paths and Subpaths, Drawing on a Page, Sample C Drawings, C Programming
@subsection Simple paths and compound paths

The most sophisticated sort of graphical object that @code{libplot} can
draw is a @emph{path}.  In this section we explain the fine details of
constructing paths.  The other three sorts of graphical object (text
strings, marker symbols, and points [i.e., pixels]) are discussed
elsewhere.

As in Postscript, paths may be simple or compound.  @w{A simple} path is
a contiguous sequence of line segments, circular arcs, elliptic arcs,
quadratic Bezier curves, and/or cubic Bezier curves.  @w{A simple} path
may also be a circle, an ellipse, or a rectangle.  @w{A compound} path
consists of one or more simple paths, which must be @emph{nested}: they
should not intersect each other.  @emph{This is more restrictive than in
Postscript.}

@code{libplot}'s drawing model is significantly different from
Postscript's, and is more user-friendly.  Before drawing a path by
invoking @code{libplot} operations, you do not need to call any special
function.  You would specify the attributes of the path before drawing,
however.  Attributes include pen color, line type, line width, cap type,
join type, and miter limit.  @w{If the} path is to be filled, the fill
color and fill rule would be specified too.  All these attributes are
`modal': their values are preserved from path to path.

In principle, you would end any path you construct, and request that it
be drawn on the graphics display, by invoking the @code{endpath}
operation.  But @code{endpath} is called automatically when any
path-related attribute is changed, when @code{move} is called to change
the graphics cursor position, and before any other object is constructed
and drawn.  @w{It is} also called at the end of each page of graphics,
i.e., when @code{closepl} is invoked.  So invoking @code{endpath}
explicitly is usually unnecessary.  This is quite different from
Postscript, where an explicit command to stroke or fill a path is
required.

@code{libplot} also differs from Postscript in the way it constructs and
draws compound paths.  In @code{libplot}, you would end each of the
constituent simple paths of a compound path by invoking the
@code{endsubpath} operation.  After all simple paths are drawn, the
compound path as a whole would be drawn by invoking @code{endpath}.
After each of the calls to @code{endsubpath}, you are allowed to call
@code{move} to reposition the graphics cursor, prior to beginning the
next simple path.  Immediately after an invocation of @code{endsubpath},
a call to @code{move} will not automatically invoke @code{endpath}.

The following sample program uses a Postscript Plotter to produce
Postscript output.  It draws a typical compound path, which consists of
@w{17 simple} paths.  The first simple path is a large box.  This box
contains @w{7 circles}, nested within each other, and a separate set of
@w{7 circles} that are also nested within each other.  Within each of
the two sets of nested circles is a pair of contiguous line segments,
which make up an additional simple path.  The compound path is drawn in
green, and it is filled.  The fill color is light blue.

@example
@group
#include <stdio.h>
#include <plot.h>
@end group

@group
int main ()
@{
  int i, j;
  plPlotter *plotter;
  plPlotterParams *plotter_params;
@end group

@group
  /* set a Plotter parameter */
  plotter_params = pl_newplparams ();
  pl_setplparam (plotter_params, "PAGESIZE", "letter");
@end group
@group  
  /* create a Postscript Plotter that writes to standard output */
  plotter = pl_newpl_r ("ps", stdin, stdout, stderr, plotter_params);
@end group
@group
  /* open Plotter, i.e. begin a page of graphics */
  pl_openpl_r (plotter);
@end group

@group
  pl_fspace_r (plotter, 0.0, 0.0, 1000.0, 1000.0); /* set coor system */
  pl_flinewidth_r (plotter, 5.0);  /* set line thickness */
  pl_pencolorname_r (plotter, "green");
  pl_fillcolorname_r (plotter, "light blue");
  pl_filltype_r (plotter, 1);      /* do filling, full strength */
  pl_erase_r (plotter);            /* erase graphics display */
@end group

@group
  /* draw a compound path consisting of 17 simple paths */

  /* draw the first simple path: a large box */
  pl_orientation_r (plotter, 1);
  pl_fbox_r (plotter, 50.0, 50.0, 950.0, 950.0);
  pl_endsubpath_r (plotter);
@end group
@group
  for (i = 0; i < 2; i++)
    /* draw 8 simple paths that are nested inside the box */
    @{
@end group
@group
      /* first, draw 7 simple paths: nested circles */
      for (j = 9; j >= 3; j--)
        @{
          pl_orientation_r (plotter, j % 2 ? -1 : 1);
          pl_fcircle_r (plotter, 250.0 + 500 * i, 500.0, j * 20.0);
          pl_endsubpath_r (plotter);
        @}
@end group
@group
      /* draw an open simple path comprising two line segments */
      pl_fmove_r (plotter, 225.0 + 500 * i, 475.0);
      pl_fcont_r (plotter, 250.0 + 500 * i, 525.0);
      pl_fcont_r (plotter, 275.0 + 500 * i, 475.0);
      pl_endsubpath_r (plotter);  
    @}
@end group
@group
  /* formally end the compound path (not actually necessary) */
  pl_endpath_r (plotter);
@end group

@group
  /* close Plotter, i.e. end page of graphics */
  pl_closepl_r (plotter);
@end group
@group
  /* delete Plotter */
  if (pl_deletepl_r (plotter) < 0)
    @{
      fprintf (stderr, "Couldn't delete Plotter\n");
      return 1;
    @}
  return 0;
@}
@end group
@end example

As you will see if you run this program, the filling of the compound
path takes place in a visually pleasing way: alternating annular regions
are filled.  That is because @code{libplot}'s default fill rule is
"even-odd".  Since a compound path's constituent simple paths must
always be nested, it is easy for @code{libplot} to determine which
regions between them are `even' and which are `odd'.  @w{It is} the
latter that are filled.

The above program includes many invocations of @code{orientation}.  The
value of the modal `orientation' attribute (@w{1, meaning}
counterclockwise, @w{or @minus{}1}, meaning clockwise) applies to
subsequently drawn boxes, circles, and ellipses.  If "even-odd" filling
is used, they have no effect.  @w{But if} the fill rule for the compound
path is set to "nonzero-winding" by an initial call to @code{fillmod},
these calls to @code{orientation} will arrange matters so that
alternating annular regions are filled, just as if "even-odd" filling
were used.

If the preceding paragraph is mysterious, it would be wise to consult a
good book on Postscript programming, or any other reference on the
subject of `winding numbers'.

@node Drawing on a Page, Animated GIFs, Paths and Subpaths, C Programming
@subsection Drawing on a physical page

GNU @code{libplot} can draw graphics over an entire page of paper, not
merely within the graphics display or `viewport' that it normally uses.

The default viewport used by an Illustrator, Postscript, Fig, or PCL
Plotter is a square region centered on the page.  The size of the
default viewport depends on the @code{PAGESIZE} parameter, which may be
"letter", "a4", etc.  See @ref{Page and Viewport Sizes}.  For example,
the default viewport on a letter-sized page, which has width 8.5@dmn{}in
and height 11@dmn{}in, is a square of side 8@dmn{}in.

However, you may specify different dimensions for the viewport, and a
different position @w{as well}.  In particular, you may specify a
viewport that covers the entire page.  This would be accomplished by
setting @code{PAGESIZE} to, for example,
"letter,xsize=8.5in,ysize=11in,xorigin=0in,yorigin=0in".  "xorigin" and
"yorigin" specify the location of the lower left corner of the viewport,
relative to the lower left corner of the page.

With this choice for the viewport, the entire page is @w{in principle}
imageable.  For full-page drawing, it is convenient to define a user
coordinate system in terms of which the lower left corner of the page is
(0,0), and in which the units are physical inches or centimeters.  @w{To
do} so, you would use appropriate arguments when invoking the
@code{space} operation on the Plotter.  The following program shows how
the @code{space} operation would be invoked.

@example
@group
#include <stdio.h> 
#include <plot.h>
@end group
     
@group
int main()
@{
  plPlotter *plotter;
  plPlotterParams *plotter_params;
@end group
     
@group
  /* set page size parameter, including viewport size and location */
  plotter_params = pl_newplparams ();
  pl_setplparam (plotter_params, "PAGESIZE", 
                 "letter,xsize=8.5in,ysize=11in,xorigin=0in,yorigin=0in");
@end group
     
@group
  /* create a Postscript Plotter with the specified parameter */
  plotter = pl_newpl_r ("ps", stdin, stdout, stderr, plotter_params);
@end group
     
@group
  pl_openpl_r (plotter);                /* begin page of graphics */
  pl_fspace_r (plotter,
               0.0, 0.0, 8.5, 11.0);   /* set user coor system */
@end group
     
@group
  pl_fontname_r (plotter, "Times-Bold");
  pl_ffontsize_r (plotter, 0.5);        /* font size = 0.5in = 36pt */
@end group

@group
  pl_fmove_r (plotter, 1.0, 10.0);
  pl_alabel_r (plotter, 'l', 'x', "One inch below the top");
  pl_fline_r (plotter, 1.0, 10.0, 7.5, 10.0);
@end group

@group
  pl_fmove_r (plotter, 7.5, 1.0);
  pl_alabel_r (plotter, 'r', 'x', "One inch above the bottom");
  pl_fline_r (plotter, 1.0, 1.0, 7.5, 1.0);
@end group

@group
  pl_closepl_r (plotter);               /* end page of graphics */
  pl_deletepl_r (plotter);              /* delete Plotter */
  return 0;
@}
@end group
@end example

@noindent
The program will print two strings and draw the baseline for each.  The
first string will be left-justified at position (1.0,11.0), which is one
inch below the top of the page.  The second string will be
right-justified at position (7.5,1.0), which is one inch above the
bottom of the page.  For both strings, the @t{'x'} argument of
@code{pl_alabel_r} specifies the vertical positioning: @w{it requests}
that the baseline of the string, rather than (say) its top or bottom, be
positioned at the current vertical position.

The preceding discussion and sample program dealt with the portrait
orientation of the printed page, which is the default.  Drawing in
landscape orientation is only slightly more complicated.  For this, the
viewport would be rotated on the page by setting the Plotter parameter
@code{ROTATION}@.  Its default value @w{is "0"} (@w{or "no"}), and other
allowed values are "90" (@w{or "yes"}), "180", and "270".  @w{On a}
letter-sized page in landscape orientation, a rotated viewport has lower
left corner (0.0,0.0) and upper right corner (11.0,8.5), provided that
inches are used.  The following program is a modified version of the
preceding, showing how a landscape orientation would be produced.

@example
@group
#include <stdio.h> 
#include <plot.h>
@end group
     
@group
int main()
@{
  plPlotter *plotter;
  plPlotterParams *plotter_params;
@end group
     
@group
  /* set Plotter parameters */
  plotter_params = pl_newplparams ();
  pl_setplparam (plotter_params, "PAGESIZE", 
                 "letter,xsize=8.5in,ysize=11in,xorigin=0in,yorigin=0in");
  pl_setplparam (plotter_params, "ROTATION", "90");
@end group
     
@group
  /* create a Postscript Plotter with the specified parameters */
  plotter = pl_newpl_r ("ps", stdin, stdout, stderr, plotter_params);
@end group
     
@group
  pl_openpl_r (plotter);                /* begin page of graphics */
  pl_fspace_r (plotter,
               0.0, 0.0, 11.0, 8.5);   /* set user coor system */
@end group
     
@group
  pl_fontname_r (plotter, "Times-Bold");
  pl_ffontsize_r (plotter, 0.5);        /* font size = 0.5in = 36pt */
@end group

@group
  pl_fmove_r (plotter, 1.0, 7.5);
  pl_alabel_r (plotter, 'l', 'x', "One inch below the top");
  pl_fline_r (plotter, 1.0, 7.5, 10.0, 7.5);
@end group

@group
  pl_fmove_r (plotter, 10.0, 1.0);
  pl_alabel_r (plotter, 'r', 'x', "One inch above the bottom");
  pl_fline_r (plotter, 1.0, 1.0, 10.0, 1.0);
@end group

@group
  pl_closepl_r (plotter);               /* end page of graphics */
  pl_deletepl_r (plotter);              /* delete Plotter */
  return 0;
@}
@end group
@end example

It is worth nothing that rotating a viewport, by specifying a nonzero
value for @code{ROTATION}, does not change the position of its four
corners.  Rather, any graphics that are drawn are rotated @w{within it}.
@w{If the} viewport is rectangular rather than square, this `rotation'
necessarily includes a rescaling.

@node Animated GIFs, X Animations, Drawing on a Page, C Programming
@subsection Animated GIFs in C

Using GNU @code{libplot} to create pseudo-GIF files, including animated
pseudo-GIFs, is straightforward.  @w{A GIF} Plotter is a Plotter like
any other, and it supports the same drawing operations.  However, it has
two special properties.  @w{(1) It} can draw only a single page of
graphics, i.e., only the graphics contained in the first
@code{openpl}@dots{}@code{closepl} pair appear in the output file.
@w{In this}, it resembles other Plotters that do not plot in real time.
@w{(2) Within} this page, each invocation of @code{erase} is normally
treated as the beginning of a new image in the output file.  There is an
exception to this: the first invocation of @code{erase} begins a new
image only if something has already been drawn.

The reason for the exception is that many programmers who use
@code{libplot} are in the habit of invoking @code{erase} immediately
after a Plotter is opened.  That is not a bad habit, since a few types
of Plotter (e.g., @w{X Drawable} and Tektronix Plotters) are
`persistent' in the sense that previously drawn graphics remain visible.

The following program creates a simple animated pseudo-GIF, 150 pixels
wide and 100 pixels high.

@example
@group
#include <stdio.h>
#include <plot.h>
@end group

@group
int main()
@{
  plPlotter *plotter;
  plPlotterParams *plotter_params;
  int i;
@end group

  /* set Plotter parameters */
  plotter_params = pl_newplparams ();
  pl_setplparam (plotter_params, "BITMAPSIZE", "150x100");
  pl_setplparam (plotter_params, "BG_COLOR", "orange");
  pl_setplparam (plotter_params, "TRANSPARENT_COLOR", "orange");
  pl_setplparam (plotter_params, "GIF_ITERATIONS", "100");
  pl_setplparam (plotter_params, "GIF_DELAY", "5");

  /* create a GIF Plotter with the specified parameters */
  plotter = pl_newpl_r ("gif", stdin, stdout, stderr, plotter_params);
     
  pl_openpl_r (plotter);                 /* begin page of graphics */
  pl_fspace_r (plotter, 
               -0.5, -0.5, 149.5, 99.5); /* set user coor system */
  
  pl_pencolorname_r (plotter, "red");    /* use red pen */
  pl_linewidth_r (plotter, 5);           /* set line thickness */
  pl_filltype_r (plotter, 1);            /* objects will be filled */
  pl_fillcolorname_r (plotter, "black"); /* set the fill color */

@group
  for (i = 0; i < 180 ; i += 15)
    @{
      pl_erase_r (plotter);              /* begin new GIF image */
      pl_ellipse_r (plotter, 75, 50, 40, 20, i); /* draw an ellipse */
    @}
@end group

@group
  pl_closepl_r (plotter);                /* end page of graphics */
  pl_deletepl_r (plotter);               /* delete Plotter */
  return 0;
@}
@end group
@end example

The animated pseudo-GIF will be written to standard output.  @w{It will}
consist of twelve images, showing the counterclockwise rotation of a
black-filled red ellipse through 180 degrees.  The pseudo-GIF will be
`looped' (see below), so the ellipse will rotate repeatedly.

The parameters of the ellipse are expressed in terms of user
coordinates, not pixel coordinates.  But the call to @code{pl_fspace_r}
defines user coordinates that are effectively the same as pixel
coordinates.  In the user coordinate system, the lower left corner of
the rectangle mapped into the 150x100 pseudo-GIF image is given
coordinates (@minus{}0.5,@minus{}0.5), and the upper right corner is
given coordinates (149.5,99.5).  So individual pixels may be addressed
in terms of integer user coordinates.  @w{For example}, invoking
@code{pl_point_r(plotter,0,0)} and @code{pl_point_r(plotter,149,99)}
would set the pixels in the lower left and upper right corners of the
image to the current pen color.

Besides @code{BITMAPSIZE} and @code{BG_COLOR}, there are several
important GIF Plotter parameters that may be set with the
@code{pl_setplparam} function.  The @code{TRANSPARENT_COLOR} parameter
may be set to the name of a color.  Pixels in a pseudo-GIF that have
that color will be treated as transparent by most software.  This is
usually used to create a transparent background.  @w{In the} example
above, the background color is specified as orange, but the transparent
color is also specified as orange.  @w{So the} background will not
actually be displayed.

The @code{GIF_ITERATIONS} parameter, @w{if set}, specifies the number of
times that a multi-frame pseudo-GIF should be looped.  The
@code{GIF_DELAY} parameter specifies the number of hundredths of a
seconds that should elapse between successive images.

The @code{INTERLACE} parameter is sometimes useful.  If it is set to
"yes", the pseudo-GIF will be interlaced.  This is of greatest value for
single-frame GIFs.  For full details on Plotter parameters, see
@ref{Plotter Parameters}.

@node X Animations, X Programming, Animated GIFs, C Programming
@subsection X Window System animations in C

You may use GNU @code{libplot} to produce vector graphics animations on
any Plotter that does real-time plotting (i.e., @w{an X}, @w{X
Drawable}, ReGIS, Tektronix, or Metafile Plotter).  By definition, the
`frames' in any page of graphics are separated by invocations of
@code{erase}.  @w{So the} graphics display will be cleared after each
frame.  If successive frames differ only slightly, @w{a smooth}
animation will result.

The following is a sample application, written @w{in C}, that produces
an animation for the @w{X Window} System.  @w{It displays} a `drifting
eye'.  @w{As the} eye drifts across a popped-up window from left to
right, it slowly rotates.  After the eye has drifted across twice, the
window will vanish.

@example
@group
#include <stdio.h>
#include <plot.h>
@end group

@group
int main ()
@{
  plPlotter *plotter;
  plPlotterParams *plotter_params;
  int i = 0, j;

  /* set Plotter parameters */        
  plotter_params = pl_newplparams ();
  pl_setplparam (plotter_params, "BITMAPSIZE", "300x150");
  pl_setplparam (plotter_params, "VANISH_ON_DELETE", "yes");
  pl_setplparam (plotter_params, "USE_DOUBLE_BUFFERING", "yes");
@end group

@group
  /* create an X Plotter with the specified parameters */
  if ((plotter = pl_newpl_r ("X", stdin, stdout, stderr,
                             plotter_params)) == NULL)
    @{
      fprintf (stderr, "Couldn't create Plotter\n");
      return 1;
    @}
@end group

@group
  if (pl_openpl_r (plotter) < 0)         /* open Plotter */
    @{
      fprintf (stderr, "Couldn't open Plotter\n");
      return 1;
    @}
@end group
@group
  pl_fspace_r (plotter, 
               -0.5, -0.5, 299.5, 149.5);  /* set user coor system */
  pl_linewidth_r (plotter, 8);           /* set line thickness */
  pl_filltype_r (plotter, 1);            /* objects will be filled */
  pl_bgcolorname_r (plotter, "saddle brown"); /* set background color */
@end group
@group
  for (j = 0; j < 300; j++)
    @{
      pl_erase_r (plotter);                 /* erase window */
      pl_pencolorname_r (plotter, "red");   /* use red pen */
      pl_fillcolorname_r (plotter, "cyan"); /* use cyan filling */
      pl_ellipse_r (plotter, i, 75, 35, 50, i);  /* draw an ellipse */
      pl_colorname_r (plotter, "black"); /* use black pen and filling */
      pl_circle_r (plotter, i, 75, 12);  /* draw a circle [the pupil] */
      i = (i + 2) % 300;                 /* shift rightwards */
    @}
@end group
@group
  if (pl_closepl_r (plotter) < 0)        /* close Plotter */
    @{
      fprintf (stderr, "Couldn't close Plotter\n");
      return 1;
    @}
@end group

@group
  if (pl_deletepl_r (plotter) < 0)       /* delete Plotter */
    @{
      fprintf (stderr, "Couldn't delete Plotter\n");
      return 1;
    @}
  return 0;
@}
@end group
@end example

As you can see, this application begins by calling @code{pl_setplparam}
several times to set Plotter parameters, and then calls
@code{pl_newpl_r} to create an @w{X Plotter}.  The @w{X Plotter} window
will have size 300x150 pixels.  This window will vanish when the Plotter
is deleted.  @w{If the} @code{VANISH_ON_DELETE} parameter were not set
to "yes", the window would remain on the screen until removed by the
user (@w{by typing} @samp{q} @w{in it}, or by clicking with a mouse).

Setting the parameter @code{USE_DOUBLE_BUFFERING} to "yes" requests that
double buffering be used.  This is very important if you wish to produce
a smooth animation, with no jerkiness.  Normally, an @w{X Plotter} draws
graphics into a window in real time, and erases the window when
@code{pl_erase_r} is called.  But if double buffering is used, each
frame of graphics is written into an off-screen buffer, and is copied
into the window, pixel by pixel, when @code{pl_erase_r} is called or the
Plotter is closed.  This is a bit counterintuitive, but is exactly what
is needed for smooth animation.

After the Plotter is created, it is selected for use and opened.  When
@code{pl_openpl_r} is called, the window @w{pops up}, and the animation
begins.  In the body of the @t{for} loop there is a call to
@code{pl_erase_r}, and also a sequence of @code{libplot} operations that
draws the eye.  The pen color and fill color are changed twice with each
passage through the loop.  You may wish to experiment with the animation
parameters to produce the best effects on your video hardware.

The positions of the objects that are plotted in the animation are
expressed in terms of user coordinates, not pixel coordinates.  But the
call to @code{pl_fspace_r} defines user and pixel coordinates to be
effectively the same.  User coordinates are chosen so that the lower
left corner of the rectangle mapped to the @w{X window} is
(@minus{}0.5,@minus{}0.5) and the upper right corner is (299.5,149.5).
Since this agrees with the window size, individual pixels may be
addressed in terms of integer user coordinates.  @w{For example},
@code{pl_point_r(plotter,299,149)} would set the pixel in the upper
right corner of the window to the current pen color.

The following is another sample animation, this time of a rotating
@w{letter `A'}.

@example
@group
#include <stdio.h>
#include <plot.h>
@end group

@group
int main()
@{
  plPlotter *plotter;
  plPlotterParams *plotter_params;
  int angle = 0;

  /* set Plotter parameters */        
  plotter_params = pl_newplparams ();
  pl_setplparam (plotter_params, "BITMAPSIZE", "300x300"); 
  pl_setplparam (plotter_params, "USE_DOUBLE_BUFFERING", "yes");
  pl_setplparam (plotter_params, "BG_COLOR", "blue");
@end group

@group
  /* create an X Plotter with the specified parameters */
  plotter = pl_newpl_r ("X", stdin, stdout, stderr, plotter_params);

  /* open X Plotter, initialize coordinates, pen, and font */
  pl_openpl_r (plotter);
  pl_fspace_r (plotter, 0.0, 0.0, 1.0, 1.0);  /* use normalized coors */
  pl_pencolorname_r (plotter, "white");
  pl_ffontsize_r (plotter, 1.0);
  pl_fontname_r (plotter, "NewCenturySchlbk-Roman");
@end group

@group
  pl_fmove_r (plotter, 0.5, 0.5);        /* move to center */
  while (1)                              /* loop endlessly */
    @{
      pl_erase_r (plotter);
      pl_textangle_r (plotter, angle++); /* set new rotation angle */
      pl_alabel_r (plotter, 'c', 'c', "A"); /* draw a centered `A' */
    @}
  pl_closepl_r (plotter);                /* close Plotter */
@end group

@group
  pl_deletepl_r (plotter);               /* delete Plotter */
  return 0;
@}
@end group
@end example

This animation serves as a good test of the capabilities of an @w{X
Window} System display.  @w{On a} modern X11R6 display, animation will
be smooth and fast.  That is because X11R6 displays can rasterize
individual characters from a font without rasterizing the entire font.
@w{If your} @w{X display} does not support the "NewCenturySchlbk-Roman"
font, you may substitute any other scalable font, such as the widely
available "utopia-medium-r-normal".  For the format of font names, see
@ref{Text Fonts in X}@.  @w{If the} @w{X Plotter} is unable to retrieve
the font you specify, it will first attempt to use a default scalable
font ("Helvetica").  @w{If that} too fails, it will use a default
Hershey vector font ("HersheySerif") instead.

Animations that use Hershey fonts are normally faster than ones that use
Postscript fonts or other @w{X Window} System fonts, since the Hershey
fonts are constructed from line segments.  Rasterizing line segments can
be done rapidly.  But if you use a scalable font such as
"NewCenturySchlbk-Roman" or "utopia-medium-r-normal", you will notice
that the rotation @w{speeds up} after the letter `A' has rotated through
360 degrees.  That is because the `A' at angles past 360 degrees has
already been rasterized.

If you are writing an application that performs a lengthy sequence of
drawing operations on an @w{X Plotter}, you may find it useful to set
the Plotter parameter @code{X_AUTO_FLUSH} to "no".  By default, an @w{X
Plotter} flushes all graphics to its @w{X Window} System display after
each drawing operation.  This flushing ensures that graphics are visible
to the user immediately after they are drawn.  However, it sometimes
considerably slows down the rendering process.  For additional details
on Plotter parameters, see @ref{Plotter Parameters}.

@node X Programming, , X Animations, C Programming
@subsection Advanced X Window System programming

Applications that run under the X Window System are often built using
Xt, the @w{X Toolkit}.  @w{In Xt}, an application is constructed from
`widgets' such as text entry fields, buttons, sliders, drawing areas,
etc.  When the application @w{starts up}, each widget is configured to
respond appropriately to `events', which include key presses and mouse
clicks.  After the widgets are configured, control is transferred to the
@w{Xt event} loop.

GNU @code{libplot} can be used within the Xt event loop to draw vector
graphics.  For this, it would use one or more @w{X Drawable} Plotters.
An @w{X Drawable} Plotter is a Plotter that can plot into an off-screen
pixmap or an on-screen window, such as a window associated with a
widget.

The following sample application shows how an @w{X Drawable} Plotter
would be used.  The application draws a @w{`C' curve}, as defined in a
previous section, in a popped-up window.  The usual Xt command-line
options may be used: the window background color is specified with the
@samp{-bg} option, the window geometry with @samp{-geometry}, etc.  The
curve is initially drawn in red, but clicking once with the mouse will
redraw it in green.  @w{A second} mouse click will redraw it in red, and
@w{so forth}.  The application will terminate when @samp{q} is typed.

@example
@group
#include <stdio.h>
#include <plot.h>
@end group
@group
#include <X11/Xlib.h>
#include <X11/Intrinsic.h>
#include <X11/Shell.h>
#include <X11/StringDefs.h>
#include <X11/Core.h>
@end group

plPlotter *plotter;
int green = 0;                  /* draw in green, not red? */

@group
#define MAXORDER 12
void draw_c_curve (double dx, double dy, int order)
@{
  if (order >= MAXORDER)
    /* continue path along (dx, dy) */
    pl_fcontrel_r (plotter, dx, dy); 
@end group
@group
  else
    @{
      draw_c_curve (0.5 * (dx - dy), 0.5 * (dx + dy), order + 1);
      draw_c_curve (0.5 * (dx + dy), 0.5 * (dy - dx), order + 1);
    @}
@}
@end group

void Redraw (Widget w, XEvent *ev, String *params, Cardinal *n_params)
@{
  /* draw C curve */
  pl_erase_r (plotter);
  pl_pencolorname_r (plotter, green ? "green" : "red");
  pl_fmove_r (plotter, 600.0, 300.0);  
  draw_c_curve (0.0, 400.0, 0);
  pl_endpath_r (plotter);
@}

@group
void Toggle (Widget w, XEvent *ev, String *params, Cardinal *n_params)
@{
  green = (green ? 0 : 1);
  Redraw (w, ev, params, n_params);
@}
@end group

@group
void Quit (Widget w, XEvent *ev, String *params, Cardinal *n_params)
@{
  exit (0);
@}
@end group

@group
/* mapping of events to actions */
static const String translations =
"<Expose>:      redraw()\n\
<Btn1Down>:     toggle()\n\
<Key>q:         quit()";
@end group

@group
/* mapping of actions to subroutines */
static XtActionsRec actions[] = 
@{
  @{"redraw",            Redraw@},
  @{"toggle",            Toggle@},
  @{"quit",              Quit@},
@};
@end group

@group
/* default parameters for widgets */
static String default_resources[] = 
@{
  "Example*geometry:      250x250",
  (String)NULL
@};
@end group

@group
int main (int argc, char *argv[])
@{
  plPlotterParams *plotter_params;
  Arg wargs[10];                /* storage of widget args */
  Display *display;             /* X display */
  Widget shell, canvas;         /* toplevel widget; child */
@end group
@group
  Window window;                /* child widget's window */
  XtAppContext app_con;         /* application context */
  int i;
  char *bg_colorname = "white";
@end group
  
@group
  /* take background color from command line */
  for (i = 0; i < argc - 1; i++)
    if (strcmp (argv[i], "-bg") == 0)
      bg_colorname = argv[i + 1];
@end group
@group
  /* create toplevel shell widget */
  shell = XtAppInitialize (&app_con, 
                           (String)"Example", /* app class */
                           NULL,              /* options */
                           (Cardinal)0,       /* num of options */
                           &argc,             /* command line */
                           argv,              /* command line */
                           default_resources,
                           NULL,              /* ArgList */
                           (Cardinal)0        /* num of Args */
                           );
@end group
@group
  /* set default widget parameters (including window size) */
  XtAppSetFallbackResources (app_con, default_resources);
@end group
@group
  /* map actions to subroutines */
  XtAppAddActions (app_con, actions, XtNumber (actions));
@end group
@group
  /* create canvas widget as child of shell widget; realize both */
  XtSetArg(wargs[0], XtNargc, argc);
  XtSetArg(wargs[1], XtNargv, argv);
  canvas = XtCreateManagedWidget ((String)"", coreWidgetClass,
                                  shell, wargs, (Cardinal)2);
  XtRealizeWidget (shell);
@end group
@group
  /* for the canvas widget, map events to actions */
  XtSetArg (wargs[0], XtNtranslations, 
            XtParseTranslationTable (translations));
  XtSetValues (canvas, wargs, (Cardinal)1);
@end group

@group
  /* initialize GNU libplot */
  plotter_params = pl_newplparams ();
  display = XtDisplay (canvas);
  window = XtWindow (canvas);
@end group
@group
  pl_setplparam (plotter_params, "XDRAWABLE_DISPLAY", display);
  pl_setplparam (plotter_params, "XDRAWABLE_DRAWABLE1", &window); 
  pl_setplparam (plotter_params, "BG_COLOR", bg_colorname);
@end group
@group
  plotter = pl_newpl_r ("Xdrawable", NULL, NULL, stderr, 
                        plotter_params);
  pl_openpl_r (plotter);
  pl_fspace_r (plotter, 0.0, 0.0, 1000.0, 1000.0);
  pl_flinewidth_r (plotter, 0.25);     
@end group

@group
  /* transfer control to X Toolkit event loop (doesn't return) */
  XtAppMainLoop (app_con);
@end group

  return 1;
@}
@end example

Even if you are not familiar with @w{X Window} System programming, the
structure of this application should be clear.  @w{It defines} three
callbacks: @code{Redraw}, @code{Toggle}, and @code{Quit}.  They are
invoked respectively in response to @w{(1) a} window expose event or
mouse click, @w{(2) a} mouse click, and @w{(3) a} @w{typed @samp{q}}.
The first drawing of the @w{`C' curve} (@w{in red}) takes place because
the window receives an initial expose event.

This example could be extended to take window resizing into account.
Actually, @w{X Drawable} Plotters are usually used to draw vector
graphics in off-screen pixmaps rather than on-screen windows.  Pixmaps,
unlike windows, are never resized.

@node C++ Programming, Functions, C Programming, libplot
@section C++ Programming with @code{libplotter}

@menu
* The Plotter Class::           The Plotter class
* C++ Compiling and Linking::   C++ compiling and linking
* Sample C++ Drawings::         Sample drawings in C++
@end menu

@node The Plotter Class, C++ Compiling and Linking, C++ Programming, C++ Programming
@subsection The @code{Plotter} class

The C++ binding for @code{libplot} is provided by a class library named
@code{libplotter}.  This library implements a @code{Plotter} class @w{of
which} all Plotters are instances.  Actually, a Plotter would normally
be an instance of an appropriate derived class, determined by the
Plotter's output format.  Derived classes include @code{XPlotter},
@code{XDrawablePlotter}, @code{PNGPlotter}, @code{PNMPlotter},
@code{GIFPlotter}, @code{AIPlotter}, @code{PSPlotter},
@code{CGMPlotter}, @code{FigPlotter}, @code{PCLPlotter},
@code{HPGLPlotter}, @code{ReGISPlotter}, @code{TekPlotter}, and
@code{MetaPlotter}.  The names should be self-explanatory.  The
operations that may be applied to any Plotter (e.g., the @code{openpl}
operation, which begins a page of graphics) are implemented as public
function members of the @code{Plotter} class.

At the time a Plotter is created, its input, output, and error streams
must be specified, along with a PlotterParams object that optionally
contains other Plotter parameters.  (The input stream is ignored, since
@w{at present}, all Plotters are write-only.)  The streams may be
specified either as iostreams or as @code{FILE} pointers.  That is, the
two constructors

@example
  Plotter(istream& instream, ostream& outstream, ostream& errstream,
          PlotterParams &params);
  Plotter(FILE *infile, FILE *outfile, FILE *errfile,
          PlotterParams &params);
@end example

@noindent
are provided for the base Plotter class, and similarly for each of its
derived classes.  So, for example, both

@example
PSPlotter plotter(cin, cout, cerr, params);
@end example

@noindent
and

@example
PSPlotter plotter(stdin, stdout, stderr, params);
@end example

@noindent
are possible declarations of a Postscript Plotter that writes to
standard output.  In the iostream case, an ostream with a null stream
buffer may be specified as the output stream and/or the error stream, to
request that no output take place.  @w{In the} @code{FILE} pointer case,
specifying a null @code{FILE} pointer would accomplish the same thing.
Instances of the @code{XPlotter} and @code{XDrawablePlotter} classes
always ignore the output stream argument, since they write graphics to
an @w{X Display} rather than to a stream.

The @code{PlotterParams} class supports copying and assignment, but has
only a single public function member, @code{setplparam}.  The following
is a formal description.

@table @asis
@item int @t{PlotterParams::setplparam} (const char *@var{parameter}, void *@var{value});
Set the value of the Plotter parameter @var{parameter} to @var{value}.
For most parameters, @var{value} should be a @code{char *}, i.e., a
string.  Unrecognized parameters are ignored.  For a list of the
recognized parameters and their meaning, see @ref{Plotter Parameters}.
@end table

Like the @code{plPlotterParams} datatype and the function
@code{pl_setplparam} of the C binding, the @code{PlotterParams} class
and the @code{PlotterParams::setplparam} function of the C++ binding
give the programmer fine control over the parameters of subsequently
created Plotters.  The parameter values used by any Plotter are constant
over the lifetime of the Plotter, and are those that were specified when
the Plotter was created.  @w{If at} Plotter creation time a parameter
has @emph{not} been set in the specified @code{PlotterParams} object,
its default value will be used, unless the parameter is string-valued
and there is an environment variable of the same name, in which case the
value of that environment variable will be used.

Once set in a PlotterParams object, @w{a parameter} may be unset by the
programmer by invoking @code{PlotterParams::setplparam} with a value
argument of NULL@.  This further increases flexibility.

There is an alternative (older) way of constructing a Plotter, which is
deprecated but still supported.  By using either of

@example
  Plotter(istream& instream, ostream& outstream, ostream& errstream);
  Plotter(FILE *infile, FILE *outfile, FILE *errfile);
@end example

@noindent
one may construct a Plotter without specifying a PlotterParams object.
@w{In this} case the parameter values for the Plotter are copied from
static storage.  @w{A parameter} may be set in static storage by
invoking a static member function of the Plotter class,
@code{Plotter::parampl}, which has declaration

@table @asis
int @t{PlotterParams::parampl} (const char *@var{parameter}, void *@var{value});
@end table

@noindent
This alternative way of creating a Plotter is not thread-safe, which is
why it is deprecated.

@node C++ Compiling and Linking, Sample C++ Drawings, The Plotter Class, C++ Programming
@subsection C++ compiling and linking

The source code for a graphics application written in C++, if it is to
use @code{libplotter}, must contain the line

@example
#include <plotter.h>
@end example

@noindent
The header file @code{plotter.h} is distributed with @code{libplotter},
and should have been installed on your system where your @w{C++
compiler} will find it.  @w{It declares} the @code{Plotter} class and
its derived classes, and also contains some miscellaneous definitions.
@w{It includes} the header files @code{<iostream.h>} and
@code{<stdio.h>}, so you do not need to include them separately.

To link your application with @code{libplotter}, you would use the
appropriate @samp{-l} option(s) on the command line when compiling it.
You would use

@example
-lplotter -lXaw -lXmu -lXt -lXext -lX11 -lpng -lz -lm
@end example

@noindent
or, in recent releases of the @w{X Window} System,

@example
-lplotter -lXaw -lXmu -lXt -lSM -lICE -lXext -lX11 -lpng -lz -lm
@end example

@noindent
These linking options assume that your version of @code{libplotter} has
been compiled with PNG support; @w{if not}, you would omit the
@samp{-lpng -lz} options.

As an alternative to the preceding, you may need to use @samp{-lplotter
-lXm -lXt -lXext -lX11 -lpng -lz -lm}, @samp{-lplotter -lXm -lXt -lXext
-lX11 -lpng -lz -lm -lc -lgen}, or @samp{-lplotter -lXm -lXt -lXext
-lX11 -lpng -lz -lm -lc -lPW}, on systems that provide Motif widgets
instead of Athena widgets.  In recent releases of the @w{X Window}
System, you would insert @samp{-lSM -lICE}@.  Recent releases of Motif
require @samp{-lXp} and possibly @samp{-lXpm} @w{as well}.)

On some platforms, the directories in which @code{libplotter} or the
other libraries are stored must be specified on the command line.
@w{For example}, the options @samp{-lXaw -lXmu -lXt -lSM -lICE -lXext
-lX11}, which specify @w{X Window} System libraries, may need to be
preceded by an option like @samp{-L/usr/X11/lib}.

On most systems @code{libplotter} is installed as a shared library.
This means that the linking with your application will take place at run
time rather than compile time.  The environment variable
@code{LD_LIBRARY_PATH} lists the directories which will be searched for
shared libraries at run time.  For your application to be executable,
this environment variable should include the directory in which
@code{libplotter} is stored.

@node Sample C++ Drawings, , C++ Compiling and Linking, C++ Programming
@subsection Sample drawings in C++

In a previous section, there are several sample @w{C programs} that show
how to draw vector graphics using @code{libplot}'s @w{C binding}.
@xref{Sample C Drawings}.  @w{In this} section, we give a modified
version of one of the C programs, showing how @code{libplot}'s C++
binding, i.e., @code{libplotter}, can be used similarly.

The following C++ program draws an intricate and beautiful path (Bill
Gosper's @w{``C'' curve}).

@example
@group
#include <plotter.h>
const int maxorder = 12;
@end group
     
@group
void draw_c_curve (Plotter& plotter, double dx, double dy, int order)
@{
  if (order >= maxorder)
    plotter.fcontrel (dx, dy);	// continue path along (dx, dy)
@end group
@group
  else
    @{
      draw_c_curve (plotter, 
                    0.5 * (dx - dy), 0.5 * (dx + dy), order + 1);
      draw_c_curve (plotter,
                    0.5 * (dx + dy), 0.5 * (dy - dx), order + 1);
    @}
@}
@end group
     
@group
int main ()
@{
  // set a Plotter parameter
  PlotterParams params;
  params.setplparam ("PAGESIZE", (char *)"letter");
@end group
     
@group
  PSPlotter plotter(cin, cout, cerr, params); // declare Plotter
  if (plotter.openpl () < 0)                  // open Plotter
    @{
      cerr << "Couldn't open Plotter\n";
      return 1;
    @}
@end group

  plotter.fspace (0.0, 0.0, 1000.0, 1000.0); // specify user coor system
  plotter.flinewidth (0.25);       // line thickness in user coordinates
  plotter.pencolorname ("red");    // path will be drawn in red
  plotter.erase ();                // erase Plotter's graphics display
  plotter.fmove (600.0, 300.0);    // position the graphics cursor
  draw_c_curve (plotter, 0.0, 400.0, 0);
@group
  if (plotter.closepl () < 0)      // close Plotter
    @{
      cerr << "Couldn't close Plotter\n";
      return 1;
    @}
  return 0;
@}
@end group
@end example

The above is a straightforward translation of the corresponding @w{C
program}.  Here, @code{plotter} is declared as an instance of the
@code{PSPlotter} class, which will write Postscript graphics to the
output stream @code{cout}.  The graphics are drawn by invoking member
functions.

@node Functions, Plotter Parameters, C++ Programming, libplot
@section The functions in @code{libplot}: A detailed listing

In the current release of GNU @code{libplot}, any Plotter supports 97
distinct operations.  @w{A language} binding for @code{libplot}
necessarily includes 97 functions that correspond to these operations.
@w{In the} C binding, these 97 functions belong to the @w{C API}
(application programming interface).  The name of each function begins
with the prefix "pl_" and ends with the @w{suffix "_r"}.  @w{In the} C++
binding, the 97 functions are implemented as public members of the
@code{Plotter} class.  @w{No prefix} or suffix is used.

@w{A language} binding may also include functions for creating,
selecting, and deleting Plotters.  For example, the @w{C binding}
includes the additional functions @code{pl_newpl_r} and
@code{pl_deletepl_r}.  @xref{The C API}@.

The 97 functions that operate on a specified Plotter are divided into
the four sets tabulated below.

@iftex
@enumerate
@item
Control functions: functions that open, initialize, or close the Plotter.
@item
Functions that cause the Plotter to draw objects.
@item
Functions that set or affect the Plotter's drawing attributes.
@item
Functions that alter the affine map used by the Plotter to transform
user coordinates to device coordinates.
@end enumerate
@end iftex

Many functions come in two versions: integer and double precision
floating point.  Internally, @code{libplot} uses double precision
floating point.  The integer versions are provided for backward
compatibility.  @w{If there} are two versions of a function, the name of
the floating point version begins with the @w{letter @samp{f}}.

Many functions come in both absolute and relative versions, also.  The
latter use relative coordinates (i.e., coordinates relative to the
current position of the graphics cursor), and their names end in
@samp{rel}.

Currently, only a few of the 97 functions have meaningful return values.

@menu
* Control Functions::   Functions that open, initialize or close a Plotter
* Drawing Functions::   Functions that draw objects
* Attribute Functions:: Functions that affect drawing attributes
* Mapping Functions::   Functions affecting the user -> device coordinate map
@end menu

@node Control Functions, Drawing Functions, Functions, Functions
@subsection Control functions

The following are the ``control functions'' in @code{libplot}.  They are
the basic functions that open, initialize, or close an already-created
Plotter.  They are listed in the approximate order in which they would
be called.

In the current @w{C binding}, each of these functions takes a pointer to
a @code{plPlotter} as its first argument.  Also in the current @w{C
binding}, the name of each function begins with "pl_" and ends @w{with
"_r"}.  (@w{"_r" stands} for `revised' or `reentrant'.)  For information
on older @w{C bindings}, see @ref{Older C APIs}.  @w{In the} C++
binding, these are member functions of the @code{Plotter} class and its
subclasses, and the prefix and suffix are not used.

@table @asis
@item int @t{openpl} ();
@t{openpl} opens a Plotter, i.e., begins a page of graphics.  This
resets the Plotter's drawing attributes to their default values.  @w{A
negative} return value indicates the Plotter could not be opened.

Currently, an X Plotter @w{pops up} a new window on an @w{X Window}
System display for each page of graphics, i.e., with each invocation of
@code{openpl}.  Future releases may support window re-use.

@item int @t{bgcolor} (int @var{red}, int @var{green}, int @var{blue});   
@t{bgcolor} sets the background color for the Plotter's graphics
display, using a 48-bit RGB color model.  The arguments @var{red},
@var{green} and @var{blue} specify the red, green and blue intensities
of the background color.  Each is an integer in the range
@t{0x0000}@dots{}@t{0xffff}, i.e., 0@dots{}65535.  The choice @w{(0, 0,
0)} signifies black, and the choice (65535, 65535, 65535) signifies
white.

@t{bgcolor} affects only Plotters that have a notion of background
color, i.e., @w{X Plotters}, X Drawable Plotters, PNG Plotters, PNM
Plotters, and GIF Plotters (all of which produce bitmaps), CGM Plotters,
ReGIS Plotters and Metafile Plotters.  Its effect is simple: the next
time the @t{erase} operation is invoked on such a Plotter, its display
will be filled with the specified color.

@item int @t{bgcolorname} (const char *@var{name});
@t{bgcolorname} sets the background color for the the graphics display
to be @var{name}.  Unrecognized colors are interpreted as "white".  For
information on what color names are recognized, see @ref{Color Names}.
@w{A 24-bit} RGB color may also be specified as a six-digit hexadecimal
string, e.g., "#c0c0c0".

@t{bgcolorname} affects only Plotters that have a notion of background
color, i.e., @w{X Plotters}, @w{X Drawable} Plotters, PNG Plotters, PNM
Plotters, and GIF Plotters (all of which produce bitmaps), CGM Plotters,
ReGIS Plotters, and Metafile Plotters.  Its effect is simple: the next
time the @t{erase} operation is invoked on such a Plotter, its display
will be filled with the specified color.

SVG Plotters and CGM Plotters support "none" as a value for the
background color.  It will @w{turn off} the background: the drawn
objects will not be backed by anything.  This is useful when the
generated SVG or WebCGM file is to be placed on a Web page.

@item int @t{erase} ();
@t{erase} begins the next frame of a multiframe page, by clearing all
previously plotted objects from the graphics display, and filling it
with the background color @w{(if any)}.

It is frequently useful to invoke @t{erase} at the beginning of each
page, i.e., immediately after invoking @t{openpl}.  That is because some
Plotters are persistent, in the sense that objects drawn within an
@code{openpl}@dots{}@code{closepl} pair remain on the graphics display
even after a new page is begun by a subsequent invocation of
@code{openpl}.  Currently, only @w{X Drawable} Plotters and Tektronix
Plotters are persistent.  Future releases may support optional
persistence for @w{X Plotters} also.

On X Plotters and X Drawable Plotters the effects of invoking @t{erase}
will be altogether different if the Plotter parameter
@code{USE_DOUBLE_BUFFERING} is set to "yes".  @w{In this} case, objects
will be written to an off-screen buffer rather than to the graphics
display, and invoking @t{erase} will @w{(1) copy} the contents of this
buffer to the display, and @w{(2) erase} the buffer by filling it with
the background color.  This `double buffering' feature facilitates
smooth animation.  @xref{Plotter Parameters}.

@item int @t{space} (int @var{x0}, int @var{y0}, int @var{x1}, int @var{y1});
@itemx int @t{fspace} (double @var{x0}, double @var{y0}, double @var{x1}, double @var{y1});
@t{space} and @t{fspace} take two pairs of arguments, specifying the
positions of the lower left and upper right corners of a rectangular
window in the user coordinate system that will be mapped to the
`viewport': the rectangular portion of the output device that graphics
will be @w{drawn in}.  The default window is a square, with opposite
corners (0,0) @w{and (1,1)}.

In mathematical terms, calling @t{space} or @t{fspace} sets the affine
transformation from user coordinates to device coordinates.  That is, it
sets the transformation matrix attribute for each object subsequently
drawn on the display.  Either @t{space} or @t{fspace} would usually be
invoked at the beginning of each page of graphics, i.e., immediately
after the call to @t{openpl}.  Additional calls to @t{space} or
@t{fspace} are allowed, and there are several ``mapping functions'' that
also affect the transformation matrix attribute.  See @ref{Mapping
Functions}.

Note that the size and location of the viewport depend on the type of
Plotter, and on the Plotter parameters that are specified at Plotter
creation time.  For example, the default viewport used by any
Illustrator, Postscript, Fig, PCL, and HP-GL Plotter is a square whose
size depends on the Plotter's page type.  See @ref{Page and Viewport
Sizes}.

@item int @t{space2} (int @var{x0}, int @var{y0}, int @var{x1}, int @var{y1}, int @var{x2}, int @var{y2});
@itemx int @t{fspace2} (double @var{x0}, double @var{y0}, double @var{x1}, double @var{y1}, double @var{x2}, double @var{y2});
@t{space2} and @t{fspace2} are extended versions of @t{space} and
@t{fspace}.  Their arguments are the three defining vertices of an
parallelogram-shaped window in the user coordinate system.  The
specified vertices are the lower left, the lower right, and the upper
left.  This window will be mapped affinely onto the viewport: the
rectangular portion of the output device that graphics will be @w{drawn
in}.

@item int @t{havecap} (const char *@var{s});
@t{havecap} is not really a control function: it is a query function.
@w{It tests} whether or not a Plotter, which need not be open, has a
specified capability.  The return value is @w{0, 1}, @w{or 2},
signifying no/yes/maybe.  For unrecognized capabilities the return value
is zero.  Recognized capabilities include "WIDE_LINES" (i.e., the
ability to draw lines with a non-default thickness), "DASH_ARRAY" (the
ability to draw in arbitrary dashing styles, as requested by the
@t{linedash} function), "SETTABLE_BACKGROUND" (the ability to set the
color of the background), and "SOLID_FILL".  The "HERSHEY_FONTS",
"PS_FONTS", "PCL_FONTS", and "STICK_FONTS" capabilities indicate whether
or not fonts of a particular class are supported.  @xref{Text Fonts}.

All Plotters except Tektronix Plotters have the "SOLID_FILL" capability,
meaning they can fill paths with solid color.  Each such Plotter has at
least one of the "EVEN_ODD_FILL" and "NONZERO_WINDING_NUMBER_FILL"
capabilities.  These indicate the supported rules for determining the
`inside' of a path.

The `maybe' value is returned for most capabilities by Metafile
Plotters, which do no drawing themselves.  The output of a Metafile
Plotter must be translated to another format, or displayed, by invoking
@code{plot}.

@item int @t{flushpl} ();
@t{flushpl} flushes (i.e., pushes onward) all previously plotted objects
to the graphics display.  This is useful only if the affected Plotter is
one that does real-time plotting (@w{X Plotters}, @w{X Drawable}
Plotters, ReGIS Plotters, Tektronix Plotters, and Metafile Plotters).
@w{It ensures} that all previously plotted objects are visible to the
user.  @w{On Plotters} that do not do real-time plotting, this operation
has no effect.

@item int @t{closepl} ();
@t{closepl} closes a Plotter, i.e., ends a page of graphics.  If a path
is in progress, it is first ended and plotted, as if @t{endpath} had
been called.  @w{A negative} return value indicates the Plotter could
not be closed.

In the present release of @code{libplot}, some Plotters output each page
of graphics immediately after it is plotted, i.e., when @t{closepl} is
invoked to end the page.  That is the case with PCL and HP-GL Plotters,
in particular.  Plotters that can output only a single page of graphics
(PNG, PNM, GIF, SVG, Illustrator, and Fig Plotters) do so immediately
after the first page is plotted, i.e., when @t{closepl} is invoked for
the first time.  Postscript and CGM Plotters store all pages of graphics
internally, and do not produce output until they are deleted.
@end table

@node Drawing Functions, Attribute Functions, Control Functions, Functions
@subsection Object-drawing functions

The following are the ``drawing functions'' in @code{libplot}.  When
invoked on a Plotter, these functions cause it to draw objects (paths,
text strings, marker symbols, and points [i.e., pixels]) on the
associated graphics display.

Paths may be simple or compound.  @w{A simple} path is a sequence of
contiguous line segments, arc segments (either circular or elliptic),
and/or Bezier curve segments (either quadratic or cubic).  Such simple
paths are drawn incrementally, one segment at a time.  @w{A simple} path
may also be a circle, rectangle, or ellipse.  @w{A compound} path
consists of multiple simple paths, which must be nested.

You do not need to begin a path by calling any special function.  You
should, @w{at least} in theory, end a path under construction, and
request that it be drawn on the graphics display, by calling
@code{endpath}.  But the @code{endpath} function is automatically called
when any other object is drawn, and at the end of each page of graphics.
@w{It is} also called automatically when any path-related attribute is
changed: for example, when @code{move} is called to change the graphics
cursor position.  So @code{endpath} seldom needs to be invoked
explicitly.

When drawing a compound path, you would end each of its constituent
simple paths by calling @code{endsubpath}, and the compound path as a
whole by calling @code{endpath}.  After each call to @code{endsubpath},
you are allowed to call @code{move} to reposition the graphics cursor,
prior to beginning the next simple path.  Such a call to @code{move}
will not automatically invoke @code{endpath}.  This is an exception to
the above rule.

In the current @w{C binding}, each of these functions takes a pointer to
a @code{plPlotter} as its first argument.  Also in the current @w{C
binding}, the name of each function begins with "pl_" and ends @w{with
"_r"}.  (@w{"_r" stands} for `revised' or `reentrant'.)  For information
on older @w{C bindings}, see @ref{Older C APIs}.  @w{In the} C++
binding, these are member functions of the @code{Plotter} class and its
subclasses, and the prefix and suffix are not used.

@table @asis
@item int @t{alabel} (int @var{horiz_justify}, int @var{vert_justify}, const char *@var{s});
@t{alabel} takes three arguments @var{horiz_justify},
@var{vert_justify}, and @var{s}, which specify an `adjusted label,'
i.e., a justified text string.  The path under construction (@w{if any})
is ended and drawn, as if @t{endpath} had been called, and the string
@var{s} is drawn according to the specified justifications.  If
@var{horiz_justify} is equal to @samp{l}, @samp{c}, or @samp{r}, then
the string will be drawn with left, center or right justification,
relative to the current graphics cursor position.  If @var{vert_justify}
is equal to @samp{b}, @samp{x}, @samp{c}, @samp{C}, or @samp{t}, then
the bottom, baseline, center, cap line, or top of the string will be
placed even with the current graphics cursor position.  The graphics
cursor is moved to the right end of the string if left justification is
specified, and to the left end if right justification is specified.

The string may contain escape sequences of various sorts (see @ref{Text
String Format}), though it should not contain line feeds or carriage
returns.  @w{In fact} it should include only printable characters, from
the byte ranges @t{0x20}@dots{}@t{0x7e} and @t{0xa0}@dots{}@t{0xff}.
The string may be plotted at a nonzero angle, if @code{textangle} has
been called.

@item int @t{arc} (int @var{xc}, int @var{yc}, int @var{x0}, int @var{y0}, int @var{x1}, int @var{y1});
@itemx int @t{farc} (double @var{xc}, double @var{yc}, double @var{x0}, double @var{y0}, double @var{x1}, double @var{y1});
@itemx int @t{arcrel} (int @var{xc}, int @var{yc}, int @var{x0}, int @var{y0}, int @var{x1}, int @var{y1});
@itemx int @t{farcrel} (double @var{xc}, double @var{yc}, double @var{x0}, double @var{y0}, double @var{x1}, double @var{y1});
@t{arc} and @t{farc} take six arguments specifying the beginning
(@var{x0}, @var{y0}), end (@var{x1}, @var{y1}), and center (@var{xc},
@var{yc}) of a circular arc.  @w{If the} graphics cursor is at
(@var{x0}, @var{y0}) and a path is under construction, then the arc is
added to the path.  Otherwise the current path (@w{if any}) is ended and
drawn, as if @t{endpath} had been called, and the arc begins a new
path.  In all cases the graphics cursor is moved to (@var{x1},
@var{y1}).

The direction of the arc (clockwise or counterclockwise) is determined
by the convention that the arc, centered at (@var{xc}, @var{yc}), sweep
through an angle of at most 180 degrees.  @w{If the} three points appear
to be collinear, the direction is taken to be counterclockwise.  If
(@var{xc}, @var{yc}) is not equidistant from (@var{x0}, @var{y0}) and
(@var{x1}, @var{y1}) as it @w{should be}, @w{it is} corrected by being
moved to the closest point on the perpendicular bisector of the line
segment joining (@var{x0}, @var{y0}) and (@var{x1}, @var{y1}).
@t{arcrel} and @t{farcrel} are similar to @code{arc} and @code{farc},
but use cursor-relative coordinates.

@item int @t{bezier2} (int @var{x0}, int @var{y0}, int @var{x1}, int @var{y1}, int @var{x2}, int @var{y2});
@itemx int @t{fbezier2} (double @var{x0}, double @var{y0}, double @var{x1}, double @var{y1}, double @var{x2}, double @var{y2});
@itemx int @t{bezier2rel} (int @var{x0}, int @var{y0}, int @var{x1}, int @var{y1}, int @var{x2}, int @var{y2});
@itemx int @t{fbezier2rel} (double @var{x0}, double @var{y0}, double @var{x1}, double @var{y1}, double @var{x2}, double @var{y2});
@t{bezier2} and @t{fbezier2} take six arguments specifying the beginning
@code{p0}=(@var{x0}, @var{y0}) and end @code{p2}=(@var{x2}, @var{y2}) of
a quadratic Bezier curve, and its intermediate control point
@code{p1}=(@var{x1}, @var{y1}).  @w{If the} graphics cursor is @w{at
@code{p0}} and a path is under construction, then the curve is added to
the path.  Otherwise the current path (@w{if any}) is ended and drawn,
as if @t{endpath} had been called, and the curve begins a new path.
@w{In all} cases the graphics cursor is moved @w{to @code{p2}}.
@t{bezier2rel} and @t{fbezier2rel} are similar to @code{bezier2} and
@code{fbezier2}, but use cursor-relative coordinates.

The quadratic Bezier curve is tangent at @code{p0} to the line segment
joining @code{p0} @w{to @code{p1}}, and is tangent @w{at @code{p2}} to
the line segment joining @code{p1} @w{to @code{p2}}.  @w{So it} fits
snugly into a triangle with vertices @code{p0}, @code{p1}, @w{and
@code{p2}}.

When using a PCL Plotter to draw Bezier curves on a LaserJet III, you
should set the parameter @code{PCL_BEZIERS} to "no".  That is because
the LaserJet III, which was Hewlett--Packard's first @w{PCL 5} printer,
does not recognize the Bezier instructions supported by later @w{PCL 5}
printers.  See @ref{Plotter Parameters}.

@item int @t{bezier3} (int @var{x0}, int @var{y0}, int @var{x1}, int @var{y1}, int @var{x2}, int @var{y2}, int @var{x3}, int @var{y3});
@itemx int @t{fbezier3} (double @var{x0}, double @var{y0}, double @var{x1}, double @var{y1}, double @var{x2}, double @var{y2}, double @var{x3}, double @var{y3});
@itemx int @t{bezier3rel} (int @var{x0}, int @var{y0}, int @var{x1}, int @var{y1}, int @var{x2}, int @var{y2}, int @var{x3}, int @var{y3});
@itemx int @t{fbezier3rel} (double @var{x0}, double @var{y0}, double @var{x1}, double @var{y1}, double @var{x2}, double @var{y2}, double @var{x3}, double @var{y3});
@t{bezier3} and @t{fbezier3} take eight arguments specifying the
beginning @code{p0}=(@var{x0}, @var{y0}) and end @code{p3}=(@var{x3},
@var{y3}) of a cubic Bezier curve, and its intermediate control points
@code{p1}=(@var{x1}, @var{y1}) and @code{p2}=(@var{x2}, @var{y2}).
@w{If the} graphics cursor is @w{at @code{p0}} and a path is under
construction, then the curve is added to the path.  Otherwise the
current path (@w{if any}) is ended and drawn, as if @t{endpath} had been
called, and the curve begins a new path.  @w{In all} cases the graphics
cursor is moved @w{to @code{p3}}.  @t{bezier3rel} and @t{fbezier3rel}
are similar to @code{bezier3} and @code{fbezier3}, but use
cursor-relative coordinates.

The cubic Bezier curve is tangent at @code{p0} to the line segment
joining @code{p0} @w{to @code{p1}}, and is tangent @w{at @code{p3}} to
the line segment joining @code{p2} @w{to @code{p3}}.  @w{So it} fits
snugly into a quadrangle with vertices @code{p0}, @code{p1}, @code{p2},
@w{and @code{p3}}.

When using a PCL Plotter to draw Bezier curves on a LaserJet III, you
should set the parameter @code{PCL_BEZIERS} to "no".  That is because
the LaserJet III, which was Hewlett--Packard's first @w{PCL 5} printer,
does not recognize the Bezier instructions supported by later @w{PCL 5}
printers.  See @ref{Plotter Parameters}.

@item int @t{box} (int @var{x1}, int y@var{1}, int @var{x2}, int @var{y2});
@itemx int @t{fbox} (double @var{x1}, double @var{y1}, double @var{x2}, double @var{y2});
@itemx int @t{boxrel} (int @var{x1}, int y@var{1}, int @var{x2}, int @var{y2});
@itemx int @t{fboxrel} (double @var{x1}, double y@var{1}, double @var{x2}, double @var{y2});
@t{box} and @t{fbox} take four arguments specifying the starting corner
(@var{x1}, @var{y1}) and opposite corner (@var{x2}, @var{y2}) of a
`box', or rectangle.  The path under construction (@w{if any}) is ended,
and the box is drawn as a new path.  This path is also ended, and the
graphics cursor is moved to the midpoint of the box.  @t{boxrel} and
@t{fboxrel} are similar to @t{box} and @t{fbox}, but use cursor-relative
coordinates.

@item int @t{circle} (int @var{xc}, int @var{yc}, int @var{r});
@itemx int @t{fcircle} (double @var{xc}, double @var{yc}, double @var{r});
@itemx int @t{circlerel} (int @var{xc}, int @var{yc}, int @var{r});
@itemx int @t{fcirclerel} (double @var{xc}, double @var{yc}, double @var{r});
@t{circle} and @t{fcircle} take three arguments specifying the center
(@var{xc}, @var{yc}) and radius (@var{r}) of a circle.  The path under
construction (@w{if any}) is ended, and the circle is drawn as a new
path.  This path is also ended, and the graphics cursor is moved to
(@var{xc}, @var{yc}).  @t{circlerel} and @t{fcirclerel} are similar to
@t{circle} and @t{fcircle}, but use cursor-relative coordinates for
@var{xc} and @var{yc}.

@item int @t{cont} (int @var{x}, int @var{y});
@itemx int @t{fcont} (double @var{x}, double @var{y});
@itemx int @t{contrel} (int @var{x}, int @var{y});
@itemx int @t{fcontrel} (double @var{x}, double @var{y});
@t{cont} and @t{fcont} take two arguments specifying the coordinates
(@var{x}, @var{y}) of a point.  If a path is under construction, the
line segment from the current graphics cursor position to the point
(@var{x}, @var{y}) is added to it.  Otherwise the line segment begins a
new path.  In all cases the graphics cursor is moved to (@var{x},
@var{y}).  @t{contrel} and @t{fcontrel} are similar to @t{cont} and
@t{fcont}, but use cursor-relative coordinates.

@item int @t{ellarc} (int @var{xc}, int @var{yc}, int @var{x0}, int @var{y0}, int @var{x1}, int @var{y1});
@itemx int @t{fellarc} (double @var{xc}, double @var{yc}, double @var{x0}, double @var{y0}, double @var{x1}, double @var{y1});
@itemx int @t{ellarcrel} (int @var{xc}, int @var{yc}, int @var{x0}, int @var{y0}, int @var{x1}, int @var{y1});
@itemx int @t{fellarcrel} (double @var{xc}, double @var{yc}, double @var{x0}, double @var{y0}, double @var{x1}, double @var{y1});
@t{ellarc} and @t{fellarc} take six arguments specifying the three
points @code{pc}=(@var{xc},@var{yc}), @code{p0}=(@var{x0},@var{y0}), and
@code{p1}=(@var{x1},@var{y1}) that define a so-called quarter ellipse.
This is an elliptic arc from @code{p0} to @code{p1} with @w{center
@code{pc}}.  @w{If the} graphics cursor is at point @code{p0} and a path
is under construction, the quarter-ellipse is added to it.  Otherwise
the path under construction (@w{if any}) is ended and drawn, as if
@t{endpath} had been called, and the quarter-ellipse begins a new path.
@w{In all} cases the graphics cursor is moved to @code{p1}.

The quarter-ellipse is an affinely transformed version of a quarter
circle.  @w{It is} drawn so as to have control points @code{p0},
@code{p1}, and @math{@code{p0}+@code{p1}-@code{pc}}.  This means that it
is tangent at @code{p0} to the line segment joining @code{p0} to
@math{@code{p0}+@code{p1}-@code{pc}}, and is tangent at @code{p1} to the
line segment joining @code{p1} to @math{@code{p0}+@code{p1}-@code{pc}}.
@w{So it} fits snugly into a triangle with these three control points as
vertices.  Notice that the third control point is the reflection of
@code{pc} through the line joining @code{p0} @w{and @code{p1}}.
@t{ellarcrel} and @t{fellarcrel} are similar to @t{ellarc} and
@t{fellarc}, but use cursor-relative coordinates.

@item int @t{ellipse} (int @var{xc}, int @var{yc}, int @var{rx}, int @var{ry}, int @var{angle});
@itemx int @t{fellipse} (double @var{xc}, double @var{yc}, double @var{rx}, double @var{ry}, double @var{angle});
@itemx int @t{ellipserel} (int @var{xc}, int @var{yc}, int @var{rx}, int @var{ry}, int @var{angle});
@itemx int @t{fellipserel} (double @var{xc}, double @var{yc}, double @var{rx}, double @var{ry}, double @var{angle});
@t{ellipse} and @t{fellipse} take five arguments specifying the center
(@var{xc}, @var{yc}) of an ellipse, the lengths of its semiaxes
(@var{rx} and @var{ry}), and the inclination of the first semiaxis in
the counterclockwise direction from the @w{@math{x} axis} in the user
coordinate system.  The path under construction (@w{if any}) is ended,
and the ellipse is drawn as a new path.  This path is also ended, and
the graphics cursor is moved to (@var{xc}, @var{yc}).  @t{ellipserel}
and @t{fellipserel} are similar to @t{ellipse} and @t{fellipse}, but use
cursor-relative coordinates.

@item int @t{endpath} ();
@t{endpath} terminates the path under construction, @w{if any}, and
@w{draws it}.  @w{It also} removes the path from the current graphics
context, so that a new path may be constructed.

The path under construction may be a simple path, or a compound path
constructed with the aid of @t{endsubpath} (see below).  @w{A simple}
path is constructed by one or more successive calls to @t{cont},
@t{line}, @t{arc}, @t{ellarc}, @t{bezier2}, @t{bezier3}, and/or their
floating point counterparts.  @w{A simple} path may also be constructed
by a single call to @t{circle}, @t{ellipse}, or @t{box}.

It is often not necessary to call @t{endpath} explicitly, since it is
frequently called automatically.  It will be called if any non-path
object is drawn, if any path-related drawing attribute is set, or if
@t{move} or @t{fmove} is invoked to set the cursor position.  @w{It
will} also be called if @t{restorestate} is called to pop a graphics
context off the stack, and if @t{closepl} is called to end a page of
graphics.  So it is seldom necessary to call @t{endpath} explicitly.
However, if a Plotter plots objects in real time, calling @t{endpath}
will ensure that a completed path is drawn on the graphics display
without delay.

@item int @t{endsubpath} ();
@t{endsubpath} terminates the simple path under construction, @w{if
any}, and signals that the construction of the next simple path in a
compound path is to begin.  Immediately after @t{endsubpath} is called,
it is permissible to call @t{move} or @t{fmove} to reposition the
graphics cursor.  (At other times in the drawing of a compound path,
calling @t{move} or @t{fmove} would force a premature end to the path,
by automatically invoking @t{endpath}.)

@item int @t{label} (const char *@var{s});
@t{label} takes a single string argument @var{s} and draws the text
contained in @var{s} at the current graphics cursor position.  The text
is left justified, and the graphics cursor is moved to the right end of
the string.  This function is provided for backward compatibility; the
function call @t{label}(@var{s}) is equivalent to @t{alabel}(`l',`x',@var{s}).

@item int @t{labelwidth} (const char *@var{s});
@itemx double @t{flabelwidth} (const char *@var{s});
@t{labelwidth} and @t{flabelwidth} are not really object-drawing
functions: they are query functions.  They compute and return the width
of a string in the current font, in the user coordinate system.  The
string is not drawn.

@item int @t{line} (int @var{x1}, int @var{y1}, int @var{x2}, int @var{y2});
@itemx int @t{fline} (double @var{x1}, double y@var{1}, double @var{x2}, double @var{y2});
@itemx int @t{linerel} (int @var{x1}, int y@var{1}, int @var{x2}, int @var{y2});
@itemx int @t{flinerel} (double @var{x1}, double y@var{1}, double @var{x2}, double @var{y2});
@t{line} and @t{fline} take four arguments specifying the start point
(@var{x1}, @var{y1}) and end point (@var{x2}, @var{y2}) of a line
segment.  @w{If the} graphics cursor is at (@var{x1}, @var{y1}) and a
path is under construction, the line segment is added to it.  Otherwise
the path under construction (@w{if any}) is ended and drawn, as if
@t{endpath} had been called, and the line segment begins a new path.
@w{In all} cases the graphics cursor is moved to (@var{x2}, @var{y2}).
@t{linerel} and @t{flinerel} are similar to @t{line} and @t{fline}, but
use cursor-relative coordinates.

@item  int @t{marker} (int @var{x}, int @var{y}, int @var{type}, int @var{size});
@itemx int @t{fmarker} (double @var{x}, double @var{y}, int @var{type}, double @var{size});
@itemx int @t{markerrel} (int @var{x}, int @var{y}, int @var{type}, int @var{size});
@itemx int @t{fmarkerrel} (double @var{x}, double @var{y}, int @var{type}, double @var{size});
@t{marker} and @t{fmarker} take four arguments specifying the position
(@var{x},@var{y}) of a marker symbol, its type, and its font size in
user coordinates.  The path under construction (@w{if any}) is ended and
drawn, as if @t{endpath} had been called, and the marker symbol is
plotted.  The graphics cursor is moved to (@var{x},@var{y}).
@t{markerrel} and @t{fmarkerrel} are similar to @t{marker} and
@t{fmarker}, but use cursor-relative coordinates for the position
(@var{x},@var{y}).

A marker symbol is a visual representation of a point, which is visible
on all types of Plotter.  @w{In this} it differs from the points
produced by the @t{point} function (see below).  Marker symbol types
0@dots{}31 are taken from a standard set, and marker symbol types 32 and
above are interpreted as the index of a character in the current text
font.  @xref{Marker Symbols}.

@item int @t{point} (int @var{x}, int @var{y});
@itemx int @t{fpoint} (double @var{x}, double @var{y});
@itemx int @t{pointrel} (int @var{x}, int @var{y});
@itemx int @t{fpointrel} (double @var{x}, double @var{y});
@t{point} and @t{fpoint} take two arguments specifying the coordinates
(@var{x}, @var{y}) of a point.  The path under construction @w{(if any)}
is ended and drawn, as if @t{endpath} had been called, and the point is
plotted.  The graphics cursor is moved to (@var{x}, @var{y}).
@t{pointrel} and @t{fpointrel} are similar to @t{point} and @t{fpoint},
but use cursor-relative coordinates.

`Point' is a misnomer.  Any Plotter that produces a bitmap, i.e., an
@w{X Plotter}, an @w{X Drawable} Plotter, @w{a PNG} Plotter, @w{a PNM}
Plotter, or @w{a GIF} Plotter, draws a point as a single pixel.  Most
other Plotters draw a point as a small solid circle, usually @w{so
small} @w{as to} be invisible.  @w{So @t{point}} should really be called
@t{pixel}.
@end table

@node Attribute Functions, Mapping Functions, Drawing Functions, Functions
@subsection Attribute-setting functions

The following are the ``attribute functions'' in @code{libplot}.  When
invoked on a Plotter, these functions set its drawing attributes, or
save them or restore them.  Path-related attributes include graphics
cursor position, pen color, fill color, fill rule, line thickness, line
style, cap style, join style, miter limit, and transformation matrix.
Text-related attributes include pen color, font name, font size, text
angle, and transformation matrix.

Setting any path-related drawing attribute automatically terminates and
draws the path under construction (@w{if any}), @w{as if} the
@code{endpath} operation had been invoked.  The `orientation' attribute
(clockwise/counterclockwise), which affects circles, ellipses, and
boxes, is an exception to this.  The exception allows a compound path to
include circles, ellipses, and boxes with different orientations.

In the current @w{C binding}, each of these functions takes a pointer to
a @code{plPlotter} as its first argument.  Also in the current @w{C
binding}, the name of each function begins with "pl_" and ends @w{with
"_r"}.  (@w{"_r" stands} for `revised' or `reentrant'.)  For information
on older @w{C bindings}, see @ref{Older C APIs}.  @w{In the} C++
binding, these are member functions of the @code{Plotter} class and its
subclasses, and the prefix and suffix are not used.

@table @asis
@item int @t{capmod} (const char *@var{s});
@t{capmod} terminates and draws the path under construction (@w{if
any}), as if @t{endpath} had been called, and sets the cap mode (i.e.,
cap style) for all paths subsequently drawn on the graphics display.
Recognized styles are "butt" (the default), "round", and "projecting".
The three styles are visibly distinct only if the line thickness is
fairly large.  Butt caps @w{do not} extend beyond the end of the path.
The other two kinds do, however.  Round caps are filled semicircles, and
projecting caps are filled rectangular regions that extend a distance
equal to half the line width beyond the end of the path.

PNG, PNM, GIF, PCL, and HP-GL Plotters support a fourth cap mode,
"triangular".  (For all but PCL and HP-GL Plotters, the support is
currently only partial.)  Plotters other than these treat "triangular"
as equivalent to "round".

This function has no effect on ReGIS or Tektronix Plotters.  Also, it
has no effect on HP-GL Plotters if the parameter @code{HPGL_VERSION} is
set to a value less @w{than "2"} (the default), or on CGM Plotters if
the parameter @code{CGM_MAX_VERSION} is set to a value less @w{than
"3"}.  @xref{Plotter Parameters}.

@item int @t{color} (int @var{red}, int @var{green}, int @var{blue});   
@t{color} is a convenience function.  Calling @t{color} is equivalent to
calling both @t{pencolor} and @t{fillcolor}, to set both the the pen
color and fill color of all objects subsequently drawn on the graphics
display.  Note that the physical fill color depends also on the fill
level, which is specified by calling @t{filltype}.

@item int @t{colorname} (const char *@var{name});
@t{colorname} is a convenience function.  Calling @t{colorname} is
equivalent to calling both @t{pencolorname} and @t{fillcolorname}, to
set both the the pen color and fill color of all objects subsequently
drawn on the graphics display.  Note that the physical fill color
depends also on the fill level, which is specified by calling
@t{filltype}.

@item int @t{fillcolor} (int @var{red}, int @var{green}, int @var{blue});   
@t{fillcolor} terminates and draws the path under construction (@w{if
any}), as if @t{endpath} had been called, and sets the fill color for
all paths subsequently drawn on the graphics display, using a 48-bit RGB
color model.  The arguments @var{red}, @var{green} and @var{blue}
specify the red, green and blue intensities of the fill color.  Each is
an integer in the range @t{0x0000}@dots{}@t{0xffff}, i.e.,
0@dots{}65535.  The choice @w{(0, 0, 0)} signifies black, and the choice
(65535, 65535, 65535) signifies white.  Note that the physical fill
color depends also on the fill level, which is specified by calling
@t{filltype}.

@item int @t{fillcolorname} (const char *@var{name});
@t{fillcolorname} sets the fill color of all paths subsequently drawn on
the graphics display to be @var{name}.  Unrecognized colors are
interpreted as "black".  For information on what color names are
recognized, see @ref{Color Names}.  @w{A 24-bit} RGB color may also be
specified as a six-digit hexadecimal string, e.g., "#c0c0c0".

Note that the physical fill color depends also on the fill level, which
is specified by calling @t{filltype}.

@item int @t{fillmod} (const char *@var{s});
@t{fillmod} terminates and draws the path under construction (@w{if
any}), as if @t{endpath} had been called, and sets the fill mode, i.e.,
fill rule, for all paths subsequently drawn on the graphics display.
The fill rule affects only compound paths and self-intersecting simple
paths: it determines which points are `inside'.  Two rules are
supported: "even-odd" (the default for all Plotters), and
"nonzero-winding".  For the distinction, see the @cite{Postscript
Language Reference Manual}.  "alternate" is an alias for "even-odd" and
"winding" is an alias for "nonzero-winding".

CGM, Fig, and ReGIS Plotters do not support the "nonzero-winding" rule,
because the CGM, Fig, and ReGIS vector graphics formats do not
@w{support it}.  Also, HP-GL Plotters do not support "nonzero-winding"
if @code{HPGL_VERSION} is set to a value less than "2" (the default).
@xref{Plotter Parameters}.

The LaserJet III, which was Hewlett--Packard's first @w{PCL 5} printer,
did not support the nonzero-winding fill rule.  However, all later
@w{PCL 5} printers from Hewlett--Packard @w{support it}.

@item int @t{filltype} (int @var{level});
@t{filltype} terminates and draws the path under construction (@w{if
any}), as if @t{endpath} had been called, and sets the fill level for
all subsequently drawn paths.  @w{A value} @w{of 0} for @var{level}
specifies no filling.  This is the default.  @w{A value} @w{of 1}
specifies 100% filling: the fill color will be the color previously
specified by calling @t{fillcolor} or @t{fillcolorname}.

As a convenience to the user, @var{level} may be set to any value in the
range @t{0x0000}@dots{}@t{0xffff}, i.e., 0@dots{}65535.  Any nonzero
value will produce filling.  If @var{level}=@t{0xffff}, the fill color
will be white.  Values in the range @t{0x0001}@dots{}@t{0xffff} are
interpreted as specifying a desaturation, or gray level.  @w{For
example}, @t{0x8000} specifies 50% filling (the fill color will be
half-way between the color specified by calling @t{fillcolor} or
@t{fillcolorname}, and white).

To draw the region bounded by a path in an edgeless way, you would call
@t{filltype} to @w{turn on} the filling of the interior, and @t{pentype}
to @w{turn off} the drawing of the boundary.

Tektronix Plotters do not support filling, and HP-GL Plotters support
filling of arbitrary paths only if the parameter @code{HPGL_VERSION} is
equal to "1.5" @w{or "2"} (the default).  (If the version @w{is "1"}
then only circles and rectangles aligned with the coordinate axes may be
filled.)  @emph{Opaque} filling, including white filling, is supported
only if the parameter @code{HPGL_VERSION} @w{is "2"} and the parameter
@code{HPGL_OPAQUE_MODE} is "yes" (the default).  @xref{Plotter
Parameters}.

@item int @t{fmiterlimit} (double @var{limit});
@t{fmiterlimit} terminates and draws the path under construction (@w{if
any}), as if @t{endpath} had been called, and sets the miter limit for
all paths subsequently drawn on the graphics display.  The miter limit
controls the treatment of corners, if the join mode is set to "miter"
(the default).  @w{At a} join point of a path, the `miter length' is
defined to be the distance between the inner corner and the outer
corner.  The miter limit is the maximum value that will be tolerated for
the miter length divided by the line thickness.  If this value is
exceeded, the miter will be @w{cut off}: the "bevel" join mode will be
used instead.

Examples of typical values for @var{limit} are 10.43 (the default, which
cuts off miters if the join angle is less than 11 degrees), 2.0 (the
same, for 60 degrees), and 1.414 (the same, for 90 degrees).  @w{In
general}, the miter limit is the cosecant of one-half the minimum angle
for mitered joins.  The minimum meaningful value for @var{limit} @w{is
1.0}, which converts all mitered joins to beveled joins, irrespective of
join angle.  Specifying a value less than 1.0 resets the limit to the
default.

This function has no effect on @w{X Drawable} Plotters or @w{X
Plotters}, since the @w{X Window} System miter limit, which is also
10.43, cannot be altered.  It also has no effect on Tektronix, ReGIS, or
Fig Plotters, or on HP-GL Plotters if the parameter @code{HPGL_VERSION}
is set to a value less @w{than "2"} (the default).  @xref{Plotter
Parameters}.  The miter limit used by HP-GL or PCL Plotters is always
rounded to the closest integer, downward.

@item int @t{fontname} (const char *@var{font_name});
@itemx double @t{ffontname} (const char *@var{font_name});
@t{fontname} and @t{ffontname} take a single case-insensitive string
argument, @var{font_name}, specifying the name of the font to be used
for all text strings subsequently drawn on the graphics display.  (The
font for plotting strings is fully specified by calling @t{fontname},
@t{fontsize}, and @t{textangle}.)  The size of the font in user
coordinates is returned.

The default font name depends on the type of Plotter.  @w{It is}
"Helvetica" for all Plotters except for PCL Plotters, for which it is
"Univers", and PNG, PNM, GIF, HP-GL, ReGIS, Tektronix and Metafile
Plotters, for which it is "HersheySerif".  @w{If the} argument
@var{font_name} is NULL or the empty string, or the font is not
available, the default font name will be used.  Which fonts are
available also depends on the type of Plotter; for a list of all
available fonts, see @ref{Text Fonts}.

@item int @t{fontsize} (int @var{size});
@itemx double @t{ffontsize} (double @var{size});
@t{fontsize} and @t{ffontsize} take a single argument, interpreted as
the size, in the user coordinate system, of the font to be used for all
text strings subsequently drawn on the graphics display.  (The font for
plotting strings is fully specified by calling @t{fontname},
@t{fontsize}, and @t{textangle}.)  The size of the font in user
coordinates is returned.  

@w{A negative} value for @var{size} sets the size to the default, which
depends on the type of Plotter.  Typically, the default font size is
1/50 times the size (i.e., minimum dimension) of the display.  The
interpretation of zero font size is also Plotter-dependent (most
Plotters do not draw text strings if the font size is zero).

@item int @t{joinmod} (const char *@var{s});
@t{joinmod} terminates and draws the path under construction (@w{if
any}), as if @t{endpath} had been called, and sets the join mode (i.e.,
join style) for all paths subsequently drawn on the graphics display.
Recognized styles are "miter" (the default), "round", and "bevel".  The
three styles are visibly distinct only if the line thickness is fairly
large.  Mitered joins are sharp, rounded joins are round, and beveled
joins are @w{squared off}.  However, unusually sharp joins are never
mitered: instead, they are beveled.  The angle at which beveling
replaces mitering may be specified by calling @t{fmiterlimit}.

PNG, PNM, GIF, PCL, and HP-GL Plotters support a fourth join mode,
"triangular".  Other Plotters treat "triangular" as equivalent to
"round".

This function has no effect on ReGIS or Tektronix Plotters.  Also, it
has no effect on HP-GL Plotters if the parameter @code{HPGL_VERSION} is
set to a value less @w{than "2"} (the default), or on CGM Plotters if
the parameter @code{CGM_MAX_VERSION} is set to a value less @w{than
"3"}.  @xref{Plotter Parameters}.

@item int @t{linedash} (int @var{n}, const int *@var{dashes}, int @var{offset});
@itemx int @t{flinedash} (int @var{n}, const double *@var{dashes}, double @var{offset});
@t{linedash} and @t{flinedash} terminate and draw the path under
construction (@w{if any}), as if @t{endpath} had been called, and set
the line style for all paths subsequently drawn on the graphics display.
They provide much finer control of dash patterns than the @t{linemod}
function (see below) provides.  @var{dashes} should be an array of
@w{length @var{n}}.  Its elements, which should be positive, are
interpreted as distances in the user coordinate system.  Along any path,
circle, or ellipse, the elements
@var{dashes}[0]@dots{}@var{dashes}[@var{n}-1] alternately specify the
length of a dash and the length of a gap between dashes.  When the end
of the array is reached, the reading of the array wraps around to the
beginning.  If the array is empty, i.e., @var{n} equals zero, there is
no dashing: the drawn line is solid.

The @var{offset} argument specifies the `phase' of the dash pattern
relative to the start of the path.  It is interpreted as the distance
into the dash pattern at which the dashing should begin.  For example,
if @var{offset} equals zero then the path will begin with a dash, of
length @var{dashes}[0] in user space.  @w{If @var{offset}} equals
@var{dashes}[0] then the path will begin with a gap of length
@var{dashes}[1], and @w{so forth}.  @var{offset} is allowed to be
negative.

Not all Plotters fully support @t{linedash} and @t{flinedash}.  PCL and
HP-GL Plotters cannot dash with a nonzero offset, and in the dash
patterns used by @w{X and} @w{X Drawable} Plotters, each dash or gap has
a maximum length of 255 pixels.  @t{linedash} and @t{flinedash} have no
effect @w{at all} on Tektronix, ReGIS, and Fig Plotters.  Also, they
have no effect on HP-GL Plotters for which the parameter
@code{HPGL_VERSION} is less @w{than "2"} (the default), or on CGM
Plotters for which the parameter @code{CGM_MAX_VERSION} is less @w{than
"3"}.  For information on Plotter parameters, see @ref{Plotter
Parameters}.

@strong{Warning}: If the transformation from the user coordinate system
to the device coordinate system is anisotropic, each dash pattern should
ideally be drawn on the graphics display with a length that depends on
its direction.  But currently, only SVG and Postscript Plotters @w{do
this}.  Other Plotters always draw any specified dash pattern with the
same length, irrespective of its direction.  The length that is used is
the minimum length, in the device coordinate system, that can correspond
to the specified dash pattern length in the user coordinate system.

@item int @t{linemod} (const char *@var{s});
@t{linemod} terminates and draws the path under construction (@w{if
any}), as if @t{endpath} had been called, and sets the line style for
all paths subsequently drawn on the graphics display.  The supported
line styles are "solid", "dotted", "dotdashed", "shortdashed",
"longdashed", "dotdotdashed", "dotdotdotdashed", and "disconnected".
The first seven correspond to the following dash patterns:

@example
@group
"solid"             --------------------------------
"dotted"            -   -   -   -   -   -   -   -   
"dotdashed"         ----   -   ----   -   ----   -
"shortdashed"       ----    ----    ----    ----    
"longdashed"        -------    -------    -------    
"dotdotdashed"      ----   -   -   ----   -   -
"dotdotdotdashed"   ----   -   -   -   ----   -   -   -
@end group
@end example

@noindent
@w{In the} preceding patterns, each hyphen stands for one line
thickness.  This is the case for sufficiently thick lines, @w{at least}.
@w{So for} sufficiently thick lines, the distance over which a dash
pattern repeats is scaled proportionately to the line thickness.

The "disconnected" line style is special.  A "disconnected" path is
rendered as a set of filled circles, each of which has diameter equal to
the nominal line thickness.  One of these circles is centered on each of
the juncture points of the path (i.e., the endpoints of the line
segments or arcs from which it is constructed).  Circles and ellipses
with "disconnected" line style are invisible.  Disconnected paths are
not filled; this includes circles and ellipses.

All line styles are supported by all Plotters, with the following
exceptions.  HP-GL Plotters do not support the "dotdotdotdashed" style
unless the parameter @code{HPGL_VERSION} is set to "2" (the default).
Tektronix Plotters do not support the "dotdotdotdashed" style, and do
not support the "dotdotdashed" style unless the parameter @code{TERM} is
set to "kermit".  @xref{Plotter Parameters}.

@item int @t{linewidth} (int @var{size});
@itemx int @t{flinewidth} (double @var{size});
@t{linewidth} and @t{flinewidth} terminate and draws the path under
construction (@w{if any}), as if @t{endpath} had been called, and set
the thickness, in the user coordinate system, of all paths subsequently
drawn on the graphics display.  @w{A negative} value resets the
thickness to the default.  The default thickness depends on the type of
Plotter.  For most Plotters, it is 1/850 times the size of the viewport,
i.e., the drawn-on portion of the display.  (Here `size' means minimum
dimension.)  But for Plotters that produce bitmaps, i.e., @w{X
Plotters}, @w{X Drawable} Plotters, PNG Plotters, PNM Plotters, and GIF
Plotters, @w{it is} zero.

By convention, a zero-thickness line is the thinnest line that can be
drawn.  However, the drawing editors @code{idraw} and @code{xfig} treat
zero-thickness lines as invisible.  @w{So when} producing editable
graphics with a Postscript or Fig Plotter, using a zero line thickness
may not be desirable.

Tektronix and ReGIS Plotters do not support drawing with other than a
default thickness, and HP-GL Plotters do not support doing so if the
parameter @code{HPGL_VERSION} is set to a value less @w{than "2"} (the
default; see @ref{Plotter Parameters}).

@strong{Warning}: If the transformation from the user coordinate system
to the device coordinate system is anisotropic, each line segment in a
polygonal path should ideally be drawn on the graphics display with a
thickness that depends on its direction.  But currently, only SVG and
Postscript Plotters @w{do this}.  Other Plotters draw all line segments
in a path with the same thickness.  The thickness that is used is the
minimum thickness, in the device coordinate system, that can correspond
to the specified line thickness in the user coordinate system.

@item int @t{move} (int @var{x}, int @var{y});
@itemx int @t{fmove} (double @var{x}, double @var{y});
@itemx int @t{moverel} (int @var{x}, int @var{y});
@itemx int @t{fmoverel} (double @var{x}, double @var{y});
@t{move} and @t{fmove} take two arguments specifying the coordinates
(@var{x}, @var{y}) of a point to which the graphics cursor should be
moved.  The path under construction @w{(if any)} is ended and drawn, as
if @t{endpath} had been called, and the graphics cursor is moved to
(@var{x}, @var{y}).  This is equivalent to lifting the pen on a plotter
and moving it to a new position, without drawing any line.  @t{moverel}
and @t{fmoverel} are similar to @t{move} and @t{fmove}, but use
cursor-relative coordinates.

When a new page of graphics is begun by invoking @t{openpl}, the cursor
is initially at the point (0,0) in user space.  Most of the drawing
functions reposition the cursor.  @xref{Drawing Functions}.

@item int @t{orientation} (int @var{direction});
@t{orientation} sets the orientation for all circles, ellipses, and
boxes subsequently drawn on the graphics display.  @var{direction} must
@w{be 1}, meaning counterclockwise, @w{or @minus{}1}, meaning clockwise.
The default @w{is 1}.

@t{orientation} will have a visible effect on a circle, ellipse, or box
only if it is dashed, or if it is one of the simple paths in a filled
compound path.  Its effects on filling, when the "nonzero-winding" fill
rule is used, are dramatic, since it is the orientation of each simple
path in a compound path that determines which points are `inside' and
which are `outside'.

@item int @t{pencolor} (int @var{red}, int @var{green}, int @var{blue});
@t{pencolor} terminates and draws the path under construction (@w{if
any}), as if @t{endpath} had been called, and sets the pen color for all
objects subsequently drawn on the graphics display, using a 48-bit RGB
color model.  The arguments @var{red}, @var{green} and @var{blue}
specify the red, green and blue intensities of the pen color.  Each is
an integer in the range @t{0x0000}@dots{}@t{0xffff}, i.e.,
0@dots{}65535.  The choice @w{(0, 0, 0)} signifies black, and the choice
(65535, 65535, 65535) signifies white.

HP-GL Plotters support drawing with a white pen only if the value of the
parameter @code{HPGL_VERSION} @w{is "2"} (the default), and the value of
the parameter @code{HPGL_OPAQUE_MODE} is "yes" (the default).
@xref{Plotter Parameters}.

@item int @t{pencolorname} (const char *@var{name});
@t{pencolorname} sets the pen color of all objects subsequently drawn on
the graphics display to be @var{name}.  Unrecognized colors are
interpreted as "black".  For information on what color names are
recognized, see @ref{Color Names}.  @w{A 24-bit} RGB color may also be
specified as a six-digit hexadecimal string, e.g., "#c0c0c0".

HP-GL Plotters support drawing with a white pen only if the value of the
parameter @code{HPGL_VERSION} @w{is "2"} (the default) and the value of
the parameter @code{HPGL_OPAQUE_MODE} is "yes" (the default).
@xref{Plotter Parameters}.

@item int @t{pentype} (int @var{level});
@t{pentype} terminates and draws the path under construction (@w{if
any}), as if @t{endpath} had been called, and sets the pen level for all
subsequently drawn paths.  @w{A value} @w{of 1} for @var{level}
specifies that an outline of each of these objects should be drawn, in
the color previously specified by calling @t{pencolor} or
@t{pencolorname}.  This is the default.  @w{A value} @w{of 0} specifies
that outlines should not be drawn.

To draw the region bounded by a path in an edgeless way, you would call
@t{pentype} to @w{turn off} the drawing of the boundary, and
@t{filltype} to @w{turn on} the filling of the interior.

@t{pentype} also affects the drawing of marker symbols and points, i.e.,
pixels.  @w{A value} @w{of 0} specifies that they should not be drawn.

@strong{Note}: In future releases, @t{pentype} may also affect the
drawing of text strings (@w{a value} @w{of 0} will specify that they
should not be drawn).  @w{It already} affects text strings that are
rendered using Hershey fonts, since they are drawn using polygonal
paths.

@item int @t{restorestate} ();
@t{restorestate} pops the current graphics context off the stack of
drawing states.  The graphics context consists largely of
@code{libplot}'s drawing attributes, which are set by the attribute
functions documented in this section.  So @w{popping off} the graphics
context restores the drawing attributes to values they previously had.
@w{A path} under construction is regarded as part of the graphics
context.  For this reason, calling @t{restorestate} automatically calls
@t{endpath} to terminate and draw the path under construction, @w{if
any}.  All graphics contexts on the stack are @w{popped off} when
@code{closepl} is called, @w{as if} @code{restorestate} had been called
repeatedly.

@item int @t{savestate} ();
@t{savestate} pushes the current graphics context onto the stack of
drawing states.  The graphics context consists largely of
@code{libplot}'s drawing attributes, which are set by the attribute
functions documented in this section.  @w{A path} under construction,
@w{if any}, is regarded as part of the graphics context.  That is
because paths may be drawn incrementally, one line segment or arc at a
time.  The new graphics context created by @t{savestate} will contain no
path.  When the previous graphics context is @w{returned to} by calling
@t{restorestate}, the path previously under construction may be
continued.

@item int @t{textangle} (int @var{angle});  
@itemx double @t{ftextangle} (double @var{angle});  
@t{textangle} and @t{ftextangle} take one argument, which specifies the
angle in degrees counterclockwise from the @math{x} (horizontal) axis in
the user coordinate system, for text strings subsequently drawn on the
graphics display.  The default angle is zero.  (The font for plotting
strings is fully specified by calling @t{fontname}, @t{fontsize}, and
@t{textangle}.)  The size of the font for plotting strings, in user
coordinates, is returned.
@end table

@node Mapping Functions, , Attribute Functions, Functions
@subsection Mapping functions

The following are the ``mapping functions'' in @code{libplot}.  When
invoked on a Plotter, they affect the affine transformation it employs
to map the user coordinate system to the device coordinate system.
@w{That is}, they affect the transformation matrix attribute of objects
subsequently drawn on the graphics display.

The names of these functions resemble those of the corresponding
functions in the Postscript language.  For information on how to use
them to draw graphics efficiently, consult any good book on Postscript
programming, or the @cite{Postscript Language Reference Manual}.

Each of these functions, if called, terminates and draws the path under
construction (@w{if any}), as if @t{endpath} had been called.

In the current @w{C binding}, each of these functions takes a pointer to
a @code{plPlotter} as its first argument.  Also in the current @w{C
binding}, the name of each function begins with "pl_" and ends @w{with
"_r"}.  (@w{"_r" stands} for `revised' or `reentrant'.)  For information
on older @w{C bindings}, see @ref{Older C APIs}.  @w{In the} C++
binding, these are member functions of the @code{Plotter} class and its
subclasses, and the prefix and suffix are not used.

@table @asis
@item int @t{fsetmatrix} (double @var{m0}, double @var{m1}, double @var{m2}, double @var{m3}, double @var{tx}, double @var{ty});
Use the Postscript-style transformation matrix [@var{m0} @var{m1}
@var{m2} @var{m3} @var{tx} @var{ty}] as the transformation matrix from
user space to NDC (normalized device coordinate) space.  This matrix
determines the transformation matrix from user space to unnormalized
device space, i.e., sets the transformation matrix attribute that will
be used when subsequently drawing objects on the graphics display.

In NDC space, the graphics display (i.e., viewport) has corners
@code{(0,0)}, @code{(1,0)}, @code{(1,1)}, and @code{(0,1)}.  For
information on the size of the graphics display in physical units, see
@ref{Page and Viewport Sizes}.

The default transformation matrix from user space to NDC space is 
@w{[1 0 0 1 0 0]}, which means that by default, user coordinates are the 
same as NDC coordinates.  This transformation matrix is also altered by
@t{space}, @t{fspace}, @t{space2}, and @t{fspace2}, and by the following
functions.

@item int @t{fconcat} (double @var{m0}, double @var{m1}, double @var{m2}, double @var{m3}, double @var{tx}, double @var{ty});
Modify the transformation matrix from user space to NDC space by
pre-multiplying it by the matrix [@var{m0} @var{m1} @var{m2} @var{m3}
@var{tx} @var{ty}].  Equivalently, apply the linear transformation
defined by the two-by-two matrix [@var{m0} @var{m1} @var{m2} @var{m3}]
to the user coordinate system, and then translate by @var{tx} units in
the @w{@math{x} direction} and @w{@var{ty} units} in the @w{@math{y}
direction}.

@t{fconcat} is a wrapper around the more fundamental @t{fsetmatrix}
function.  The following three functions (@t{frotate}, @t{fscale},
@t{ftranslate}) are convenience functions that are special cases of
@t{fconcat}.

@item int @t{frotate} (double @var{theta});
Modify the transformation matrix from user space to NDC space by
pre-multiplying it by the matrix [cos(@var{theta}) sin(@var{theta})
@minus{}sin(@var{theta}) cos(@var{theta}) 0 0].  Equivalently, rotate
the user coordinate system axes about their origin by @var{theta}
degrees counterclockwise, with respect to their former orientation.  The
position of the user coordinate origin and the size of the @math{x}
@w{and @math{y}} units remain unchanged.

@item int @t{fscale} (double @var{sx}, double @var{sy});
Modify the transformation matrix from user space to NDC space by
pre-multiplying it by the matrix [@var{sx} 0 0 @var{sy} 0 0].
Equivalently, make the @math{x} and @math{y} units in the user
coordinate system be the size of @var{sx} and @var{sy} units in the
former user coordinate system.  The position of the user coordinate
origin and the orientation of the coordinate axes are unchanged.

@item int @t{ftranslate} (double @var{tx}, double @var{ty});
Modify the transformation matrix from user space to NDC space by
pre-multiplying it by the matrix [0 0 0 0 @var{tx} @var{ty}].
Equivalently, move the origin of the user coordinate system by @var{tx}
units in the @w{@math{x} direction} and @w{@var{ty} units} in the
@w{@math{y} direction}, relative to the former user coordinate system.
The size of the @math{x} and @w{@math{y} units} and the orientation of
the coordinate axes are unchanged.
@end table

@node Plotter Parameters, , Functions, libplot
@section Plotter parameters

In designing the @code{libplot} library, every effort was made to make
the Plotter interface independent of the type of Plotter.  @w{To the}
extent that Plotters display individual (i.e., instance-specific)
behavior, that behavior is captured by a manageable number of
@emph{Plotter parameters}.  Each parameter has a value that is allowed
to be a generic pointer (@w{a @code{void *}}).  For most parameters, the
value is a string (@w{a @code{char *}}).

The parameter values of any Plotter are constant over the lifetime of
the Plotter, and are specified when the Plotter is created.  In the @w{C
binding}, @w{a value} for any parameter is specified by calling the
@code{pl_setplparam} function.  The @code{pl_setplparam} function acts
on a @code{plPlotterParams} object, which encapsulates Plotter
parameters.  When a Plotter is created by calling @code{pl_newpl_r},
@w{a pointer} to a @code{plPlotterParams} object is passed as the final
argument.

If at Plotter creation time a parameter is @emph{not} specified, its
default value will be used, unless the parameter is string-valued and
there is an environment variable of the same name, in which case the
value of that environment variable will be used.  This rule increases
run-time flexibility: @w{an application} programmer may allow
non-critical Plotter parameters to be specified by the user via
environment variables.

In the C++ binding, the @code{PlotterParams} class and
@code{PlotterParams::setplparam}, @w{a member} function, are the
analogues of the @code{plPlotterParams} datatype and the function
@code{pl_setplparam}.

The following are the currently recognized parameters (unrecognized ones
are ignored).  The most important ones are @code{DISPLAY}, which affects
@w{X Plotters}, @code{BITMAPSIZE}, which affects @w{X Plotters}, PNG
Plotters, PNM Plotters, and GIF Plotters, @code{PAGESIZE}, which affects
Illustrator, Postscript, CGM, Fig, and HP-GL Plotters, and
@code{ROTATION}, which affects all Plotters except Metafile Plotters.
These four parameters are listed first and the others alphabetically.
Most of the remaining parameters, such as the several whose names begin
with "HPGL", affect only a single type of Plotter.

@table @code
@item @t{DISPLAY}
(Default NULL@.)  The @w{X Window} System display on which the graphics
display will be @w{popped up}, as an @w{X window}.  This is relevant
only to @w{X Plotters}.

@item BITMAPSIZE
(Default "570x570".)  The size of the graphics display (i.e., the
viewport) in terms of pixels.  This is relevant only to @w{X Plotters},
PNG Plotters, PNM Plotters, and GIF Plotters.  For @w{X Plotters}, the
value of this parameter will automatically, if it is not set, be taken
from the @w{X resource} @code{Xplot.geometry}.  That is for backward
compatibility.

X Plotters support precise positioning of the graphics display.  For
example, if @code{BITMAPSIZE} is "570x570+0+0" then it will be
positioned in the upper left corner of the @w{X Window} System display.

@item PAGESIZE
(Default "letter".)  The page type, which determines the size of the
graphics display (i.e., the viewport) used by the Plotter.  This is
relevant only to SVG, Illustrator, Postscript, CGM, Fig, PCL, and HP-GL
Plotters.  "letter" means an 8.5@dmn{in} by 11@dmn{in} page.  Any ISO
page size in the range "a0"@dots{}"a4" or ANSI page size in the range
"a"@dots{}"e" may be specified ("letter" is an alias @w{for "a"} and
"tabloid" is an alias @w{for "b"}).  "legal", "ledger", @w{and "b5"} are
recognized page sizes also.

For Illustrator, Postscript, PCL and Fig Plotters, the graphics display
will be, by default, a square region centered on the specified page.
(For example, it will be a centered 8@dmn{in} square if @code{PAGESIZE}
is "letter".)  For HP-GL Plotters, it will be a square region of the
same size, but will not @w{by default} be centered.  SVG format and
WebCGM format have no notion of the Web page on which the graphics
display will ultimately be positioned.  They do have a notion of default
display size, though this will normally be overridden when the SVG or
WebCGM file is placed on a Web page.  For the default display size, SVG
and CGM Plotters will use the graphics display size that is used by
other Plotters.  

For the default size and location of the graphics display for each page
type, see @ref{Page and Viewport Sizes}.  You do not need to use the
default graphics display, since either or both of its dimensions can be
specified explicitly.  For example, @code{PAGESIZE} could be specified
as "letter,xsize=4in", or "a4,xsize=10cm,ysize=15cm".  The dimensions
are allowed to be negative (@w{a negative} dimension results in a
reflection).

For Plotters other than SVG and CGM Plotters, the position of the
graphics display on the page, relative to its default position, can be
adjusted by specifying an offset vector.  For example, @code{PAGESIZE}
could be specified as "letter,yoffset=1.2in", or
"a4,xoffset=@minus{}5mm,yoffset=2.0cm".  Inches, centimeters, and
millimeters are the supported units.  

@w{It is} also possible to position the graphics display precisely, by
specifying the location of its lower left corner relative to the lower
left corner of the page.  For example, @code{PAGESIZE} could be
specified as "letter,xorigin=2in,yorigin=3in", or
"a4,xorigin=0.5cm,yorigin=0.5cm".  The preceding options may be
intermingled.  SVG and WebCGM Plotters ignore the "xoffset", "yoffset",
"xorigin", and "yorigin" options, since SVG format and WebCGM format
have no notion of the Web page on which the graphics display will
ultimately be positioned.

@item ROTATION
(Default "0".)  Relevant to all Plotters other than Metafile Plotters,
which have no output device.  The angle, in degrees, by which the
graphics display (i.e., the viewport) should be rotated, relative to its
default orientation.  Recognized values are "0", "90", "180", and "270";
@w{"no" and} "yes" are equivalent to @w{"0" and "90"} respectively.  The
rotation is counterclockwise.  

A rotated viewport does not change the position of its four corners.
Rather, the graphics are rotated @w{within it}.  @w{If the} viewport is
rectangular rather than square, this `rotation' necessarily includes a
rescaling.

This parameter is useful for switching between portrait and landscape
orientations.  Internally, it determines the affine transformation from
NDC (normalized device coordinate) space to device space.

@item BG_COLOR
(Default "white".)  The initial background color of the graphics
display, when drawing each page of graphics.  This is relevant to @w{X
Plotters}, PNG Plotters, PNM Plotters, GIF Plotters, CGM Plotters, ReGIS
Plotters, and Metafile Plotters; also to @w{X Drawable Plotters} (for
the last, the background color @w{shows up} only if @code{erase} is
invoked).  For information on what color names are recognized, see
@ref{Color Names}.  The background color may be changed at any later
time by invoking the @t{bgcolor} (or @t{bgcolorname}) and @t{erase}
operations.

SVG Plotters and CGM Plotters support "none" as a value for the
background color.  It will @w{turn off} the background: the drawn
objects will not be backed by anything.  This is useful when the
generated SVG or WebCGM file is to be placed on a Web page.

@item CGM_ENCODING
(Default "binary".)  Relevant only to CGM Plotters.  "binary" means that
the CGM output should use the binary encoding.  "clear_text" means that
the CGM output should use a human-readable encoding.  The WebCGM profile
requires that the binary encoding be used, but many CGM viewers and
interpreters can also parse the clear text encoding.  The third standard
CGM encoding, "character", is not currently supported.

@item CGM_MAX_VERSION
(Default "4".)  Relevant only to CGM Plotters.  An upper bound on the
version number of CGM format that is produced.  Many older CGM
interpreters and viewers, such as the ones built into Microsoft Office
and other commercial software, only support @w{version 1} CGM files.
For fully adequate handling of fonts and line styles, @w{version 3} is
necessary.  By default, the present release of @code{libplot} produces
@w{version 3} CGM files, i.e., it does not use @w{version 4} features.

@item EMULATE_COLOR
(Default "no".)  Relevant to all Plotters.  "yes" means that each color
in the output should be replaced by an appropriate shade of gray.  The
well known formula for CIE luminance, namely @math{0.212671R + 0.715160G
+ 0.072169B}, is used.

This parameter is seldom useful, except when using a PCL Plotter to
prepare output for a monochrome @w{PCL 5} device.  Many monochrome
@w{PCL 5} devices, such as monochrome LaserJets, do a poor job of
emulating color on their own.  They usually map HP-GL/2's seven standard
pen colors, including even yellow, to black.

@item GIF_ANIMATION
(Default "yes".)  Relevant only to GIF Plotters.  "yes" means that the
@code{erase} operation will have special semantics: with the exception
of its first invocation, it will act as a separator between successive
images in the written-out pseudo-GIF file.  @w{"no" means} that
@code{erase} should act as it does on other Plotters that do not write
graphics in real time, i.e., @w{it should} erase the image under
construction by filling it with the background color.  @w{If "no"} is
specified, the pseudo-GIF file will contain only a single image.

@item GIF_DELAY
(Default "0".)  Relevant only to GIF Plotters.  The delay, in hundredths
of a second, after each image in a written-out animated pseudo-GIF file.
The value should be an integer in the range "0"@dots{}"65535".

@item GIF_ITERATIONS
(Default "0".)  Relevant only to GIF Plotters.  The number of times that
an animated pseudo-GIF file should be `looped'.  The value should be an
integer in the range "0"@dots{}"65535".

@item HPGL_ASSIGN_COLORS
(Default "no".)  Relevant only to HP-GL Plotters, and only if the value
of @code{HPGL_VERSION} @w{is "2"}.  @w{"no" means} to draw with a fixed
set of pens, specified by setting the @code{HPGL_PENS} parameter.  "yes"
means that pen colors will not restricted to the palette specified in
@code{HPGL_PENS}: colors will be assigned to ``logical pens'' in the
range #1@dots{}#31, @w{as needed}.  Other than color LaserJet printers
and DesignJet plotters, not many HP-GL/2 devices allow the assignment of
colors to logical pens.  In particular, HP-GL/2 pen plotters do not.
@w{So this} parameter should be used with caution.

@item HPGL_OPAQUE_MODE
(Default "yes".)  Relevant only to HP-GL Plotters, and only if the value
of @code{HPGL_VERSION} @w{is "2"}.  "yes" means that the HP-GL/2 output
device should be switched into opaque mode, rather than transparent
mode.  This allows objects to be filled with opaque white and other
opaque colors.  @w{It also} allows the drawing of visible white lines,
which by convention are drawn with @w{pen #0}.  Not all HP-GL/2 devices
support opaque mode or the use of @w{pen #0} to draw visible white
lines.  In particular, HP-GL/2 pen plotters @w{do not}.  Some older
HP-GL/2 devices reportedly malfunction if asked to switch into opaque
mode.  @w{If the} output of an HP-GL Plotter is to be sent to such a
device, @w{a "no"} value is recommended.

@item HPGL_PENS
(Default "1=black:2=red:3=green:4=yellow:5=blue:6=magenta:7=cyan" if the
value of @code{HPGL_VERSION} is "1.5" @w{or "2"} and "1=black" if the
value of @code{HPGL_VERSION} @w{is "1"}.  Relevant only to HP-GL
Plotters.  The set of available pens; the format should be
self-explanatory.  The color for any pen in the range #1@dots{}#31 may
be specified.  For information on what color names are recognized, see
@ref{Color Names}.  @w{Pen #1} must always be present, though it need
not be black.  Any other pen in the range #1@dots{}#31 may be omitted.

@item HPGL_ROTATE
(Default "0".)  Relevant only to HP-GL Plotters.  The angle, in degrees,
by which the graphics display (i.e., the viewport) should be rotated on
the page relative to the default orientation.  Recognized values are
"0", "90", "180", and "270"; @w{"no" and} "yes" are equivalent to @w{"0"
and "90"} respectively.  "180" and "270" are supported only if
@code{HPGL_VERSION} @w{is "2"}.

The rotation requested by @code{HPGL_ROTATE} is different from the sort
requested by the @code{ROTATION} parameter.  @code{ROTATION} rotates the
graphics display @w{in place}, but @code{HPGL_ROTATE} both rotates the
graphics display and moves its lower left corner toward another corner
of the page.  Altering the plotting area in such a way is supported by
the HP-GL language.

The @code{HPGL_ROTATE} parameter facilitates switching between portrait
and landscape orientations.  For HP-GL devices that is frequently a
concern, since some HP-GL devices (``plotters'') draw with a default
landscape orientation, while others (``printers'') draw with a default
portrait orientation.  There is no programmatic way of determining which
is which.

@item HPGL_VERSION
(Default "2".)  Relevant only to HP-GL Plotters.  @w{"1" means} that the
output should be generic HP-GL, @w{"1.5" means} that the output should
be suitable for the HP7550A graphics plotter and the HP758x, HP7595A and
HP7596A drafting plotters (HP-GL with some HP-GL/2 extensions), and
@w{"2" means} that the output should be modern HP-GL/2.  @w{If the}
version is less than "2" then the only available fonts will be vector
fonts, and all paths will be drawn with a default thickness, so that
invoking @t{linewidth}, @t{capmod}, @t{joinmod}, and @t{fmiterlimit}
will have no effect.  Also, the `nonzero winding number rule' will not
be supported when filling paths, so invoking @t{fillmod} will have no
effect.  Additionally, if the version @w{is "1"} then the filling of
arbitrary paths will not be supported (circles and rectangles aligned
with the coordinate axes may be filled, however).

@item INTERLACE
(Default "no".)  Relevant only to PNG and GIF Plotters.  If the value is
"yes", the output file will be interlaced.  That means it will be
displayed in an interlaced (nonlinear) way by many applications.

@item MAX_LINE_LENGTH
(Default "500".)  The maximum number of defining points that a path may
have, before it is flushed to the output device.  If this flushing
occurs, the path will be split into two or more sub-paths, though the
splitting should not be noticeable.  Splitting will not be performed if
the path is to be filled.

This parameter is relevant to all Plotters except Tektronix and Metafile
Plotters.  The reason for splitting long paths is that some display
devices (e.g., old Postscript printers and HP-GL pen plotters) have
limited buffer sizes.  @w{It is} not relevant to Tektronix or Metafile
Plotters, since they draw paths in real time and have no buffer
limitations.

@item META_PORTABLE
(Default "no".)  Relevant only to Metafile Plotters.  "yes" means that
the output metafile should use a portable (human-readable) encoding of
graphics, rather than the default (binary) encoding.  @xref{Metafiles}.

@item PCL_ASSIGN_COLORS
(Default "no".)  Relevant only to PCL Plotters.  @w{"no" means} to draw
with a fixed set of pens.  "yes" means that pen colors will not
restricted to this palette: colors will be assigned to ``logical pens'',
@w{as needed}.  Other than color LaserJet printers, not many @w{PCL 5}
devices allow the assignment of colors to logical pens.  @w{So this}
parameter should be used with caution.

@item PCL_BEZIERS
(Default "yes".)  Relevant only to PCL Plotters.  @w{"yes" means} that
when drawing Bezier curves, the special `Bezier instructions' will be
used.  @w{"no" means} that these instructions will not be used.
Instead, each Bezier curve will be approximated and drawn as a polygonal
line.  Other than the LaserJet III, which was Hewlett--Packard's first
@w{PCL 5} printer, all Hewlett--Packard's @w{PCL 5} printers support the
Bezier instructions.

@item PNM_PORTABLE
(Default "no".)  Relevant only to PNM Plotters.  "yes" means that the
output should be in a portable (human-readable) version of PBM/PGM/PPM
format, rather than the default (binary) version.  `Portable' is
something of a misnomer, since binary PBM/PGM/PPM files are also
portable, in the sense that they are machine-independent.

@item TERM
(Default NULL@.)  Relevant only to Tektronix Plotters.  If the value is
a string beginning with "xterm", "nxterm", or "kterm", @w{it is} taken
as a sign that the current application is running in an @w{X Window}
System VT100 terminal emulator: @w{an @code{xterm}}, @code{nxterm}, or
@code{kterm}.  Before drawing graphics, a Tektronix Plotter will emit an
escape sequence that causes the terminal emulator's auxiliary Tektronix
window, which is normally hidden, to @w{pop up}.  After the graphics are
drawn, an escape sequence that returns control to the original VT100
window will be emitted.  The Tektronix window will remain on the screen.

If the value is a string beginning with "kermit", "ansi.sys", or
"nansi.sys", @w{it is} taken as a sign that the current application is
running in the VT100 terminal emulator provided by the MS-DOS version of
@code{kermit}.  Before drawing graphics, a Tektronix Plotter will emit
an escape sequence that switches the terminal emulator to Tektronix
mode.  Also, some of the Tektronix control codes emitted by the Plotter
will be @code{kermit}-specific.  There will be a limited amount of color
support, which is not normally the case (the 16 @code{ansi.sys} colors
will be supported).  The "dotdotdashed" line style will be supported,
which is also not normally the case.  After drawing graphics, the
Plotter will emit an escape sequence that returns the emulator to VT100
mode.  The key sequence `@w{ALT minus}' may be employed manually within
@code{kermit} to switch between the two modes.

@item TRANSPARENT_COLOR
(Default "none".)  Relevant only to PNG and GIF Plotters.  If the value
is a recognized color name, that color, if it appears in the output
file, will be treated as transparent by most applications.  For
information on what names are recognized, see @ref{Color Names}.

If @code{TRANSPARENT_COLOR} is set and an animated pseudo-GIF file is
produced, the `restore to background' disposal method will be used for
each image in the file.  Otherwise, the `unspecified' disposal method
will be used.

@item USE_DOUBLE_BUFFERING
(Default "no".)  Relevant only to X Plotters and X Drawable Plotters.
@w{If the} value is "yes", a double buffering scheme will be used when
drawing graphics.  Each frame of graphics, within a
@t{openpl}@dots{}@t{closepl} pair, will be written to an off-screen
buffer rather than to the Plotter's display.  When @t{erase} is invoked
to end a frame, or when @t{closepl} is invoked, the contents of the
off-screen buffer will be copied to the Plotter's display, pixel by
pixel.  If successive frames differ only slightly, this will create the
illusion of smooth animation.

Some X displays provide special hardware support for double buffering.
@w{If this} support is available, the @w{X Plotter} will detect its
presence, and will draw graphics using the appropriate extension to the
X11 protocol (either DBE or MBX).  In this case the animation will be
significantly faster; on high-end graphics hardware, @w{at least}.

@item VANISH_ON_DELETE
(Default "no".)  Relevant only to X Plotters.  If the value is "yes",
when a Plotter is deleted, the window or windows that it has @w{popped
up} will vanish.  Otherwise, each such window will remain on the screen
until it is removed by the user (by typing @samp{q} @w{in it}, or by
clicking with a mouse).

@item XDRAWABLE_COLORMAP
(Default NULL@.)  Relevant only to @w{X Drawable Plotters}.  If the
value is non-NULL, it should be a @code{Colormap *}, @w{a pointer} to a
colormap from which colors should be allocated.  NULL indicates that the
colormap to be used should be the default colormap of the default screen
of the @w{X display}.

@item XDRAWABLE_DISPLAY
(Default NULL@.)  Relevant only to X Drawable Plotters.  The value
should be a @code{Display *}, @w{a pointer} to the @w{X display} with
which the drawable(s) to be @w{drawn in} are associated.

@item XDRAWABLE_DRAWABLE1
@itemx XDRAWABLE_DRAWABLE2
(Default NULL@.)  Relevant only to X Drawable Plotters.  If set, the
value of each of these parameters should be a @code{Drawable *}, a
pointer to a drawable to be @w{drawn in}.  @w{A `drawable'} is either a
window or a pixmap.  At the time an @w{X Drawable} Plotter is created,
@w{at least} one of the two parameters must be set.

@w{X Drawable} Plotters support simultaneous drawing in two drawables
because it is often useful to be able to draw graphics simultaneously in
both an @w{X window} and its background pixmap.  If two drawables are
specified, they must have the same dimensions and depth, and be
associated with the same screen of the @w{X display}.

@item XDRAWABLE_VISUAL
(Default NULL@.)  Relevant only to @w{X Drawable Plotters}.  If set, the
value should be a @code{Visual *}, @w{a pointer} to the `visual' with
which the colormap (see above) is associated.  Setting this parameter is
not required, but it is recommended that it be set if
@code{XDRAWABLE_COLORMAP} is set.  Under some circumstances, that will
@w{speed up} color cell allocation.

@item X_AUTO_FLUSH
(Default "yes".)  Relevant only to X Plotters.  If the value is "yes",
an @code{XFlush} operation is performed after each drawing operation.
That ensures that graphics are flushed to the @w{X Window} System
display, and are visible to the user, immediately after they are drawn.
However, it slows down rendering considerably.  @w{If the} value is
"no", drawing is faster, since it does not take place in real time.
@end table

@node Appendices, , libplot, Top
@ifnottex
The following appendices contain supplementary information on the GNU
plotting utilities and the GNU @code{libplot} library.
@end ifnottex

@menu
* Text and Markers::         Text fonts, text strings, and marker symbols
* Color Names::              Specifying colors by name
* Page and Viewport Sizes::  Specifying the size of an output page 
* Metafiles::                The device-independent GNU metafile format
* Auxiliary Software::       How to obtain auxiliary software
* History and Acknowledgements::    The contributors
* Reporting Bugs::           How to report bugs
@end menu

@node Text and Markers, Color Names, Appendices, Appendices
@appendix Fonts, Strings, and Symbols 

The GNU @code{libplot} graphics library and applications built @w{on
it}, such as @code{graph}, @code{plot}, @code{pic2plot},
@code{tek2plot}, and @code{plotfont}, can draw text strings in a wide
variety of fonts.  Text strings may include characters from more than
one font in a typeface, and may include superscripts, subscripts, and
square roots.  @w{A wide} variety of marker symbols can also be drawn.
The following sections explain how to use these features.

@menu
* Text Fonts::          Available text fonts
* Cyrillic and Japanese::  The Cyrillic and Japanese fonts
* Text Fonts in X::     Available text fonts in the X Window System
* Text String Format::  Text string formatting (with escape sequences)
* Marker Symbols::      Available marker symbols
@end menu

@node Text Fonts, Cyrillic and Japanese, Text and Markers, Text and Markers
@appendixsection Available text fonts

The GNU @code{libplot} library and applications built @w{on it}, such as
@code{graph}, @code{plot}, @code{pic2plot}, @code{tek2plot}, and
@code{plotfont}, can use many fonts.  These include 22 Hershey vector
fonts, 35 Postscript fonts, 45 @w{PCL 5} fonts, and 18 Hewlett--Packard
vector fonts.  @w{We call} these 120 supported fonts the `built-in'
fonts.  The Hershey fonts are constructed from stroked characters
digitized @w{c.@: 1967} by Dr.@: @w{Allen V.} Hershey at the U.S. Naval
Surface Weapons Center in @w{Dahlgren, VA}@.  The 35 Postscript fonts
are the outline fonts resident in all modern Postscript printers, and
the 45 @w{PCL 5} fonts are the outline fonts resident in modern
Hewlett--Packard LaserJet printers and plotters.  (Of the @w{PCL 5}
fonts, the old LaserJet III, which was Hewlett--Packard's first @w{PCL
5} printer, supported only eight: the Univers and CGTimes fonts.)  The
18 Hewlett--Packard vector fonts are fonts that are resident in
Hewlett--Packard printers and plotters (mostly the latter).

The Hershey fonts can be used by all types of Plotter supported by
@code{libplot}, and the Postscript fonts can be used by X, SVG,
Illustrator, Postscript, and Fig Plotters.  So, for example, all
variants of @code{graph} can use the Hershey fonts, and @code{graph
@w{-T X}}, @code{graph -T svg}, @code{graph -T ai}, @code{graph -T ps},
@code{graph -T cgm} and @code{graph -T fig} can use the Postscript
fonts.  The @w{PCL 5} fonts can be used by by SVG, Illustrator, PCL, and
HP-GL Plotters, and by @code{graph -T svg}, @code{graph -T ai},
@code{graph -T pcl}, and @code{graph -T hpgl}.  The Hewlett--Packard
vector fonts can be used by PCL and HP-GL Plotters, and by @code{graph
-T pcl} and @code{graph -T hpgl}.  @w{X Plotters} and @code{graph @w{-T
X}} are not restricted to the built-in Hershey and Postscript fonts.
They can use any @w{X Window} System font.

The @code{plotfont} utility, which accepts the @samp{-T} option, will
print a character map of any font that is available in the specified
output format.  @xref{plotfont}.

For the purpose of plotting text strings (see @ref{Text String Format}),
the 120 built-in fonts are divided into typefaces.  As you can see from
the following tables, our convention is that in any typeface with more
than a single font, font #1 is the normal font, font #2 is italic or
oblique, font #3 is bold, and font #4 is bold italic or bold oblique.
Additional variants @w{(if any)} are numbered #5 and higher.

The 22 Hershey fonts are divided into typefaces as follows.

@itemize @bullet
@item HersheySerif

@enumerate
@item HersheySerif
@item HersheySerif-Italic
@item HersheySerif-Bold
@item HersheySerif-BoldItalic
@item HersheyCyrillic
@item HersheyCyrillic-Oblique
@item HersheyEUC
@end enumerate

@item HersheySans

@enumerate
@item HersheySans
@item HersheySans-Oblique
@item HersheySans-Bold
@item HersheySans-BoldOblique
@end enumerate

@item HersheyScript

@enumerate
@item HersheyScript
@item HersheyScript
@item HersheyScript-Bold
@item HersheyScript-Bold
@end enumerate

@item HersheyGothicEnglish
@item HersheyGothicGerman
@item HersheyGothicItalian

@item HersheySerifSymbol
@enumerate
@item HersheySerifSymbol
@item HersheySerifSymbol-Oblique
@item HersheySerifSymbol-Bold
@item HersheySerifSymbol-BoldOblique
@end enumerate

@item HersheySansSymbol
@enumerate
@item HersheySansSymbol
@item HersheySansSymbol-Oblique
@end enumerate
@end itemize

@noindent
Nearly all Hershey fonts except the Symbol fonts use the ISO-Latin-1
encoding, which is a superset of ASCII@.  The Symbol fonts consist of
Greek characters and mathematical symbols, and use the symbol font
encoding documented in the @cite{Postscript Language Reference Manual}.
By convention, each Hershey typeface contains a symbol font
(HersheySerifSymbol or HersheySansSymbol, as appropriate) as @w{font
#0}.

HersheyCyrillic, HersheyCyrillic-Oblique, and HersheyEUC (which is a
Japanese font) are the only non-Symbol Hershey fonts that do not use the
ISO-Latin-1 encoding.  For their encodings, see @ref{Cyrillic and
Japanese}.

The 35 Postscript fonts are divided into typefaces as follows.

@itemize @bullet
@item Helvetica

@enumerate
@item   Helvetica
@item   Helvetica-Oblique
@item   Helvetica-Bold
@item   Helvetica-BoldOblique
@end enumerate

@item   Helvetica-Narrow

@enumerate
@item   Helvetica-Narrow
@item   Helvetica-Narrow-Oblique
@item   Helvetica-Narrow-Bold
@item   Helvetica-Narrow-BoldOblique
@end enumerate

@item   Times

@enumerate
@item   Times-Roman
@item   Times-Italic
@item   Times-Bold
@item   Times-BoldItalic
@end enumerate

@item AvantGarde

@enumerate
@item   AvantGarde-Book
@item   AvantGarde-BookOblique
@item   AvantGarde-Demi
@item   AvantGarde-DemiOblique
@end enumerate

@item Bookman

@enumerate
@item   Bookman-Light
@item   Bookman-LightItalic
@item   Bookman-Demi
@item   Bookman-DemiItalic
@end enumerate

@item Courier

@enumerate
@item   Courier
@item   Courier-Oblique
@item   Courier-Bold
@item   Courier-BoldOblique
@end enumerate

@item NewCenturySchlbk

@enumerate
@item   NewCenturySchlbk-Roman
@item   NewCenturySchlbk-Italic
@item   NewCenturySchlbk-Bold
@item   NewCenturySchlbk-BoldItalic
@end enumerate

@item Palatino

@enumerate
@item   Palatino-Roman
@item   Palatino-Italic
@item   Palatino-Bold
@item   Palatino-BoldItalic
@end enumerate

@item   ZapfChancery-MediumItalic
@item   ZapfDingbats
@item   Symbol
@end itemize

@noindent
All Postscript fonts except the ZapfDingbats and Symbol fonts use the
ISO-Latin-1 encoding.  The encodings used by the ZapfDingbats and Symbol
fonts are documented in the @cite{Postscript Language Reference Manual}.
By convention, each Postscript typeface contains the Symbol font as
@w{font #0}.

The 45 @w{PCL 5} fonts are divided into typefaces as follows.

@itemize @bullet
@item Univers

@enumerate
@item   Univers
@item   Univers-Oblique
@item   Univers-Bold
@item   Univers-BoldOblique
@end enumerate

@item UniversCondensed

@enumerate
@item   UniversCondensed
@item   UniversCondensed-Oblique
@item   UniversCondensed-Bold
@item   UniversCondensed-BoldOblique
@end enumerate

@item   CGTimes

@enumerate
@item   CGTimes-Roman
@item   CGTimes-Italic
@item   CGTimes-Bold
@item   CGTimes-BoldItalic
@end enumerate

@item Albertus

@enumerate
@item   AlbertusMedium
@item   AlbertusMedium
@item   AlbertusExtraBold
@item   AlbertusExtraBold
@end enumerate

@item AntiqueOlive

@enumerate
@item AntiqueOlive
@item AntiqueOlive-Italic
@item AntiqueOlive-Bold
@end enumerate

@item   Arial

@enumerate
@item   Arial-Roman
@item   Arial-Italic
@item   Arial-Bold
@item   Arial-BoldItalic
@end enumerate

@item   ClarendonCondensed
@item   Coronet
@item Courier

@enumerate
@item   Courier
@item   Courier-Italic
@item   Courier-Bold
@item   Courier-BoldItalic
@end enumerate

@item Garamond

@enumerate
@item   Garamond
@item   Garamond-Italic
@item   Garamond-Bold
@item   Garamond-BoldItalic
@end enumerate

@item LetterGothic

@enumerate
@item   LetterGothic-Roman
@item   LetterGothic-Italic
@item   LetterGothic-Bold
@item   LetterGothic-BoldItalic
@end enumerate

@item   Marigold
@item CGOmega

@enumerate
@item   CGOmega-Roman
@item   CGOmega-Italic
@item   CGOmega-Bold
@item   CGOmega-BoldItalic
@end enumerate

@item TimesNewRoman

@enumerate
@item   TimesNewRoman
@item   TimesNewRoman-Italic
@item   TimesNewRoman-Bold
@item   TimesNewRoman-BoldItalic
@end enumerate

@item   Wingdings
@item   Symbol
@end itemize

@noindent
All PCL 5 fonts except the Wingdings and Symbol fonts use the
ISO-Latin-1 encoding.  The encoding used by the Symbol font is the
symbol font encoding documented in the @cite{Postscript Language
Reference Manual}.  By convention, each PCL typeface contains the Symbol
font as @w{font #0}.

The 18 Hewlett--Packard vector fonts are divided into typefaces as
follows.

@itemize @bullet
@item Arc

@enumerate
@item   Arc
@item   Arc-Oblique
@item   Arc-Bold
@item   Arc-BoldOblique
@end enumerate

@item Stick

@enumerate
@item   Stick
@item   Stick-Oblique
@item   Stick-Bold
@item   Stick-BoldOblique
@end enumerate

@item ArcANK

@enumerate
@item   ArcANK*
@item   ArcANK-Oblique*
@item   ArcANK-Bold*
@item   ArcANK-BoldOblique*
@end enumerate

@item StickANK

@enumerate
@item   StickANK*
@item   StickANK-Oblique*
@item   StickANK-Bold*
@item   StickANK-BoldOblique*
@end enumerate

@item ArcSymbol*

@item StickSymbol*

@end itemize

@noindent 
The Hewlett--Packard vector fonts with an asterisk (the ANK and Symbol
fonts) are only available when producing HP-GL/2 graphics, or HP-GL
graphics for the HP7550A graphics plotter and the HP758x, HP7595A and
HP7596A drafting plotters.  That is, they are available only if
@code{HPGL_VERSION} @w{is "2"} (the default) @w{or "1.5"}.  The ANK
fonts are Japanese fonts (@pxref{Cyrillic and Japanese}), and the Symbol
fonts contain a few miscellaneous mathematical symbols.

All Hewlett--Packard vector fonts except the ANK and Symbol fonts use
the ISO-Latin-1 encoding.  The Arc fonts are proportional
(variable-width) fonts, and the Stick fonts are fixed-width fonts.  If
HP-GL/2 or HP-GL output is selected, the Arc fonts are assumed to be
kerned via device-resident kerning tables.  But when producing @w{PCL 5}
output, it is assumed that the display device will do no kerning.
Apparently Hewlett--Packard dropped support for device-resident kerning
tables when emulating HP-GL/2 from within @w{PCL 5}.  For information
about Hewlett--Packard vector fonts and the way in which they are kerned
(@w{in HP-GL} pen plotters, @w{at least}), see the article by
@w{L@. W@.}  Hennessee @w{et al@.} in the Nov.@: 1981 issue of the
@cite{Hewlett--Packard Journal}.

To what extent do the fonts supported by @code{libplot} contain
ligatures?  The Postscript fonts, the @w{PCL 5} fonts, and the
Hewlett--Packard vector fonts, @w{at least} as implemented in
@code{libplot}, @w{do not} contain ligatures.  However, six of the 22
Hershey fonts contain ligatures.  The character combinations "fi", "ff",
"fl", "ffi", and "ffl" are automatically drawn as ligatures in
HersheySerif and HersheySerif-Italic.  (Also in the two HersheyCyrillic
fonts and HersheyEUC, since insofar as printable ASCII characters are
concerned, they are identical [or almost identical] to HersheySerif.)
@w{In addition}, "tz" and "ch" are ligatures in HersheyGothicGerman.
The German double-s @w{character `@ss{}'}, which is called an `eszet',
is not treated as a ligature in any font.  @w{To obtain} an eszet, you
must either request one with the escape @w{sequence "\ss"} (@pxref{Text
String Format}), or, if you have an 8-bit keyboard, type an eszet
explicitly.

@node Cyrillic and Japanese, Text Fonts in X, Text Fonts, Text and Markers
@appendixsection Cyrillic and Japanese fonts

The built-in fonts discussed in the previous section include Cyrillic
and Japanese vector fonts.  This section explains how these fonts are
encoded, i.e., how their character maps are @w{laid out}.  You may use
the @code{plotfont} utility to display the character map for any font,
including the Cyrillic and Japanese vector fonts.  @xref{plotfont}.

The HersheyCyrillic and HersheyCyrillic-Oblique fonts use an encoding
called @w{KOI8-R}, a superset of ASCII that has become the @w{de facto}
standard for Unix and networking applications in the former Soviet
Union.  Insofar as printable ASCII characters go, they resemble the
HersheySerif vector font.  But their upper halves are different.  The
byte range @t{0xc0}@dots{}@t{0xdf} contains lower-case Cyrillic
characters and the byte range @t{0xe0}@dots{}@t{0xff} contains upper
case Cyrillic characters.  Additional Cyrillic characters are located at
@t{0xa3} @w{and @t{0xb3}}.  For more on the encoding scheme, see
@uref{http://www.nagual.pp.ru/~ache/koi8.html, the official KOI8-R Web
page} and Internet RFC 1489, which is available from the
@uref{http://www.isi.edu, Information Sciences Institute}.

The HersheyEUC font is a vector font that is used for displaying
Japanese text.  It uses the 8-bit EUC-JP encoding.  EUC stands for
`extended Unix code', which is a scheme for encoding Japanese, and also
other character sets (e.g., Greek and Cyrillic) as multibyte character
strings.  The format of EUC strings is explained in Ken Lunde's
@cite{Understanding Japanese Information Processing} (O'Reilly, 1993),
which contains much additional information on Japanese text processing.
See also @uref{http://www.ora.com/people/authors/lunde/cjk_inf.html, his
on-line supplement}, and his more recent book @cite{CJKV Information
Processing} (O'Reilly, 1999).

In the HersheyEUC font, characters in the printable ASCII range,
@t{0x20}@dots{}@t{0x7e}, are similar to HersheySerif (their encoding is
`JIS Roman', an ASCII variant standardized by the Japanese Industrial
Standards Committee).  Also, each successive pair of bytes in the
@code{0xa1}@dots{}@code{0xfe} range defines a single character in the
JIS X0208 standard.  The characters in the JIS X0208 standard include
Japanese syllabic characters (Hiragana and Katakana), ideographic
characters (Kanji), Roman, Greek, and Cyrillic alphabets, punctuation
marks, and miscellaneous symbols.  For example, the JIS X0208 standard
indexes the 83 Hiragana as @code{0x2421}@dots{}@code{0x2473}.  @w{To
obtain} the EUC code for any JIS X0208 character, you would add
@code{0x80} to each byte (i.e., `set the high bit' on each byte).  @w{So
the} first of the 83 Hiragana (@code{0x2421}) would be encoded as the
successive pair of bytes @code{0xa4} @w{and @code{0xa1}}.

The implementation of the JIS X0208 standard in the HersheyEUC font is
based on @w{Dr.@: Hershey's} digitizations, and is complete enough to be
useful.  All 83 Hiragana and 86 Katakana are available, though the
little-used `half-width Katakana' are not supported.  Also, 603 Kanji
are available, including 596 of the 2965 JIS @w{Level 1} (i.e.,
frequently used) Kanji.  The Hiragana, the Katakana, and the available
Kanji all have the same width.  The file @file{kanji.doc}, which on most
systems is installed in @file{/usr/share/libplot} or
@file{/usr/local/share/libplot}, lists the 603 available Kanji.  Each
JIS X0208 character that is unavailable will be drawn as an `undefined
character' glyph (@w{a bundle} of horizontal lines).

The eight Hewlett--Packard vector fonts in the ArcANK and StickANK
typefaces are also used for displaying Japanese text.  They are
available when producing HP-GL/2 output, or HP-GL output for the HP7550A
graphics plotter and the HP758x, HP7595A and HP7596A drafting plotters.
That is, they are available only if @code{HPGL_VERSION} @w{is "2"} (the
default) @w{or "1.5"}.

ANK stands for Alphabet, Numerals, and Katakana.  The ANK fonts use a
special mixed encoding.  The lower half of each font uses the JIS Roman
encoding, and the upper half contains half-width Katakana.  Half-width
Katakana are simplified Katakana that may need to be equipped with
diacritical marks.  The diacritical marks are included in the encoding
as separate characters.

@node Text Fonts in X, Text String Format, Cyrillic and Japanese, Text and Markers
@appendixsection Available text fonts for the X Window System

The command-line graphics programs @code{graph @w{-T X}}, @code{plot
@w{-T X}}, @code{pic2plot @w{-T X}}, @code{tek2plot @w{-T X}}, and
@code{plotfont @w{-T X}}, and the @code{libplot} library that they are
@w{built on}, can draw text on an @w{X Window} System display in a wide
variety of fonts.  This includes the 22 built-in Hershey vector fonts.
They can use the 35 built-in Postscript fonts too, if those fonts are
available on the @w{X display}.  Most releases of the plotting utilities
include freely distributable versions of the 35 Postscript fonts, in
@w{Type 1} format, that are easily installed on any @w{X display}.

In fact, the plotting utilities can use most fonts that are available on
the current @w{X display}.  This includes all scalable fonts that have a
so-called XLFD (@w{X Logical} Font Description) name.  For example, the
"CharterBT-Roman" font is available on many @w{X displays}.  It has a
formal XLFD name, namely
"-bitstream-charter-medium-r-normal--0-0-0-0-p-0-iso8859-1".  The
plotting utilities would refer to it as "charter-medium-r-normal".  The
command

@example
echo 0 0 1 1 2 0 | graph -T X -F charter-medium-r-normal
@end example

@noindent
would draw a plot in a popped-up @w{X window}, in which all axis ticks
are labeled in this font.

You may determine which fonts are available on an @w{X display} by using
the @code{xlsfonts} command.  Fonts whose names end in
"-0-0-0-0-p-0-iso8859-1" or "-0-0-0-0-m-0-iso8859-1" are scalable
ISO-Latin-1 fonts that can be used by @code{libplot}'s @w{X Plotters}
and by the plotting utilities that are built on @code{libplot}.  The two
sorts of font are variable-width and fixed-width fonts, respectively.
Fonts whose names end in "iso8859-2", etc., and "adobe-fontspecific",
may also be used, even though they do not employ the standard
ISO-Latin-1 encoding.

The escape sequences that provide access to the non-ASCII `8-bit'
characters in the built-in ISO-Latin-1 fonts may be employed when using
any ISO-Latin-1 @w{X Window} System font.  For more on escape sequences,
see @ref{Text String Format}.  As an example, "\Po" will yield the
British pounds sterling @w{symbol `@pounds{}'}.  The command

@example
echo 0 0 1 1 | graph -T X -F charter-medium-r-normal -L "A \Po1 Plot"
@end example

@noindent
shows how this symbol could be used in a graph label.  In the same way,
the escape sequences that provide access to mathematical symbols and
Greek characters may be employed when using any @w{X Window} System
font, whether or not it is an ISO-Latin-1 font.

The plotting utilities, including @code{graph}, support a
@samp{--bitmap-size} option.  @w{If the} @samp{@w{-T X}} option is used,
@w{it sets} the size of the popped-up @w{X Window}.  You may use it to
obtain some interesting visual effects.  Each of the plotting utilities
assumes that it is drawing in a square region, so if you use the
@samp{--bitmap-size 800x400} option, your plot will be scaled
anisotropically, by a larger factor in the horizontal direction than in
the vertical direction.  The fonts in the plot will be scaled in the
same way.  Actually, this requires a modern (X11R6) display.  @w{If
your} @w{X display} cannot scale a font, @w{a default} scalable font
(@w{such as} "HersheySerif") will be substituted.

@node Text String Format, Marker Symbols, Text Fonts in X, Text and Markers
@appendixsection Text string format and escape sequences

Text strings that are drawn by the GNU @code{libplot} library and by
applications built @w{on it}, such as @code{graph}, @code{plot},
@code{pic2plot}, @code{tek2plot}, and @code{plotfont}, must consist of
printable characters.  @w{No embedded} control characters, such as
newlines or carriage returns, are allowed.  Technically, a character is
`printable' if it comes from either of the two byte ranges
@t{0x20}@dots{}@t{0x7e} and @t{0xa0}@dots{}@t{0xff}.  The former is the
printable ASCII range and the latter is the printable `8-bit' range.

Text strings may, however, include embedded `escape sequences' that
shift the font, append subscripts or superscripts, or include non-ASCII
characters and mathematical symbols.  As a consequence, the axis labels
on a plot prepared with @code{graph} may include such features.  So may
the text strings that @code{pic2plot} uses to label objects.

The format of the escape sequences should look familiar to anyone who is
familiar with the @TeX{}, @code{troff}, or @code{groff} document
formatters.  Each escape sequence consists of three characters: @w{a
backslash} and two additional characters.  The most frequently used
escape sequences are as follows.

@table @asis
@item "\sp"
start superscript mode
@item "\ep"
end superscript mode
@item "\sb"
start subscript mode
@item "\eb"
end subscript mode
@item "\mk"
mark position
@item "\rt"
return to marked position
@end table

@noindent
For example, the string "x\sp2\ep" would be interpreted as `x squared'.
Subscripts on subscripts, etc., are allowed.  Subscripts and
superscripts may be vertically aligned by judicious use of the "\mk" and
"\rt" escape sequences.  For example, "a\mk\sbi\eb\rt\sp2\ep" produces
"a sub i squared", with the exponent `2' placed immediately above the
subscript.

There are also escape sequences that switch from font to font within a
typeface.  For an enumeration of the fonts within each typeface, see
@ref{Text Fonts}.  Suppose @w{for example} that the current font is
Times-Roman, which is font #1 in the `Times' typeface.  The string "A
\f2very\f1 well labeled axis" would be a string in which the word `very'
appears in Times-Italic rather than Times-Roman.  That is because
Times-Italic is the #2 font in the typeface.  Font-switching escape
sequences are of the form "\f@var{n}", where @var{n} is the number of
the font to be @w{switched to}.  For compatibility with @code{troff} and
@code{groff}, "\fR", "\fI", "\fB" are equivalent to "\f1", "\f2", "\f3",
respectively.  "\fP" will switch the font to the previously used font
(only one font is remembered).  There is currently no support for
switching between fonts in different typefaces.

There are also a few escape sequences for horizontal shifts, which are
useful for improving horizontal alignment, such as when shifting between
italic and non-italic fonts.  "\r1", "\r2", "\r4", "\r6", "\r8", and
"\r^" are escape sequences that shift right by 1 em, 1/2 em, 1/4 em, 1/6
em, 1/8 em, and 1/12 em, respectively.  "\l1", "\l2", "\l4", "\l6",
"\l8", and "\l^" are similar, but shift left instead of right.  
"A \fIvery\r^\fP well labeled axis" would look slightly better than 
"A \fIvery\fP well labeled axis".

Square roots are handled with the aid of a special pair of escape
sequences, together with the "\mk" and "\rt" sequences discussed above.
A square root symbol is begun with "\sr", and continued arbitrarily far
to the right with the overbar (`run') escape sequence, "\rn".  For
example, the string "\sr\mk\rn\rn\rtab" would be plotted as `the square
root of ab'.  @w{To adjust} the length of the overbar, you may need to
experiment with the number of times "\rn" appears.

To underline a string, you would use "\ul", the underline escape
sequence, one or more times.  The "\mk"@dots{}"\rt" trick would be
employed in the same way.  So, for example, "\mk\ul\ul\ul\rtabc" would
yield an underlined "abc".  To adjust the length of the underline, you
may need to experiment with the number of times "\ul" appears.  You may
also need to use one or more of the abovementioned horizontal shifts.
@w{For example}, if the "HersheySerif" font were used,
"\mk\ul\ul\l8\ul\rtabc" would yield a better underline than
"\mk\ul\ul\ul\rtabc".

Besides the preceding escape sequences, there are also escape sequences
for the printable non-ASCII characters in each of the built-in
ISO-Latin-1 fonts (which means in every built-in font, except for the
symbol fonts, the HersheyCyrillic fonts, HersheyEUC, and ZapfDingbats).
The useful non-ASCII characters include accented characters among
others.  Such `8-bit' characters, in the @t{0xa0}@dots{}@t{0xff} byte
range, may be included directly in a text string.  But if your terminal
does not permit this, you may use the escape sequences for them instead.

There are escape sequences for the mathematical symbols and Greek
characters in the symbol fonts, @w{as well}.  This is how the symbol
fonts are usually accessed.  Which symbol font the mathematical symbols
and Greek characters are taken from depends on whether your current font
is a Hershey font or a non-Hershey font.  They are taken from the
HersheySerifSymbol font or the HersheySansSymbol font in the former
case, and from the Symbol font in the latter.

The following are the escape sequences that provide access to the
non-ASCII characters of the current font, provided that it is an
ISO-Latin-1 font.  Each escape sequence is followed by the position of
the corresponding character in the ISO-Latin-1 encoding (in decimal),
and the official Postscript name of the character.  Most names should be
self-explanatory.  @w{For example}, `eacute' is a lower-case `e',
equipped with an acute accent.

@table @asis
@item "\r!" 
[161] exclamdown
@item "\ct" 
[162] cent
@item "\Po" 
[163] sterling
@item "\Cs" 
[164] currency
@item "\Ye" 
[165] yen
@item "\bb" 
[166] brokenbar
@item "\sc" 
[167] section
@item "\ad" 
[168] dieresis
@item "\co" 
[169] copyright
@item "\Of" 
[170] ordfeminine
@item "\Fo" 
[171] guillemotleft
@item "\no" 
[172] logicalnot
@item "\hy" 
[173] hyphen
@item "\rg" 
[174] registered
@item "\a-" 
[175] macron
@item "\de" 
[176] degree
@item "\+-" 
[177] plusminus
@item "\S2" 
[178] twosuperior
@item "\S3" 
[179] threesuperior
@item "\aa" 
[180] acute
@item "\*m" 
[181] mu
@item "\ps" 
[182] paragraph
@item "\md" 
[183] periodcentered
@item "\ac" 
[184] cedilla
@item "\S1" 
[185] onesuperior
@item "\Om" 
[186] ordmasculine
@item "\Fc" 
[187] guillemotright
@item "\14" 
[188] onequarter
@item "\12" 
[189] onehalf
@item "\34" 
[190] threequarters
@item "\r?" 
[191] questiondown
@item "\`A" 
[192] Agrave
@item "\'A" 
[193] Aacute
@item "\^A" 
[194] Acircumflex
@item "\~A" 
[195] Atilde
@item "\:A" 
[196] Adieresis
@item "\oA" 
[197] Aring
@item "\AE" 
[198] AE
@item "\,C" 
[199] Ccedilla
@item "\`E" 
[200] Egrave
@item "\'E" 
[201] Eacute
@item "\^E" 
[202] Ecircumflex
@item "\:E" 
[203] Edieresis
@item "\`I" 
[204] Igrave
@item "\'I" 
[205] Iacute
@item "\^I" 
[206] Icircumflex
@item "\:I" 
[207] Idieresis
@item "\-D" 
[208] Eth
@item "\~N" 
[209] Ntilde
@item "\'O" 
[210] Ograve
@item "\'O" 
[211] Oacute
@item "\^O" 
[212] Ocircumflex
@item "\~O" 
[213] Otilde
@item "\:O" 
[214] Odieresis
@item "\mu" 
[215] multiply
@item "\/O" 
[216] Oslash
@item "\`U" 
[217] Ugrave
@item "\'U" 
[218] Uacute
@item "\^U" 
[219] Ucircumflex
@item "\:U" 
[220] Udieresis
@item "\'Y" 
[221] Yacute
@item "\TP" 
[222] Thorn
@item "\ss" 
[223] germandbls
@item "\`a" 
[224] agrave
@item "\'a" 
[225] aacute
@item "\^a" 
[226] acircumflex
@item "\~a" 
[227] atilde
@item "\:a" 
[228] adieresis
@item "\oa" 
[229] aring
@item "\ae" 
[230] ae
@item "\,c" 
[231] ccedilla
@item "\`e" 
[232] egrave
@item "\'e" 
[233] eacute
@item "\^e" 
[234] ecircumflex
@item "\:e" 
[235] edieresis
@item "\`i" 
[236] igrave
@item "\'i" 
[237] iacute
@item "\^i" 
[238] icircumflex
@item "\:i" 
[239] idieresis
@item "\Sd" 
[240] eth
@item "\~n" 
[241] ntilde
@item "\`o" 
[242] ograve
@item "\'o" 
[243] oacute
@item "\^o" 
[244] ocircumflex
@item "\~o" 
[245] otilde
@item "\:o" 
[246] odieresis
@item "\di" 
[247] divide
@item "\/o" 
[248] oslash
@item "\`u" 
[249] ugrave
@item "\'u" 
[250] uacute
@item "\^u" 
[251] ucircumflex
@item "\:u" 
[252] udieresis
@item "\'y" 
[253] yacute
@item "\Tp" 
[254] thorn
@item "\:y" 
[255] ydieresis
@end table

The following are the escape sequences that provide access to
mathematical symbols and Greek characters in the current symbol font,
whether HersheySerifSymbol or HersheySansSymbol (for Hershey fonts) or
Symbol (for Postscript fonts).  Each escape sequence is followed by the
position (in octal) of the corresponding character in the symbol
encoding, and the official Postscript name of the character.  Many
escape sequences and names should be self-explanatory.  "\*a" represents
a lower-case Greek alpha, @w{for example}.  For a table displaying each
of the characters below, see the @cite{Postscript Language Reference
Manual}.

@table @asis
@item "\fa" 
[0042] universal
@item "\te" 
[0044] existential
@item "\st" 
[0047] suchthat
@item "\**" 
[0052] asteriskmath
@item "\=~" 
[0100] congruent
@item "\*A" 
[0101] Alpha
@item "\*B" 
[0102] Beta
@item "\*X" 
[0103] Chi
@item "\*D" 
[0104] Delta
@item "\*E" 
[0105] Epsilon
@item "\*F" 
[0106] Phi
@item "\*G" 
[0107] Gamma
@item "\*Y" 
[0110] Eta
@item "\*I" 
[0111] Iota
@item "\+h" 
[0112] theta1
@item "\*K" 
[0113] Kappa
@item "\*L" 
[0114] Lambda
@item "\*M" 
[0115] Mu
@item "\*N" 
[0116] Nu
@item "\*O" 
[0117] Omicron
@item "\*P" 
[0120] Pi
@item "\*H" 
[0121] Theta
@item "\*R" 
[0122] Rho
@item "\*S" 
[0123] Sigma
@item "\*T" 
[0124] Tau
@item "\*U" 
[0125] Upsilon
@item "\ts" 
[0126] sigma1
@item "\*W" 
[0127] Omega
@item "\*C" 
[0130] Xi
@item "\*Q" 
[0131] Psi
@item "\*Z" 
[0132] Zeta
@item "\tf" 
[0134] therefore
@item "\pp" 
[0136] perpendicular
@item "\ul" 
[0137] underline
@item "\rx" 
[0140] radicalex
@item "\*a" 
[0141] alpha
@item "\*b" 
[0142] beta
@item "\*x" 
[0143] chi
@item "\*d" 
[0144] delta
@item "\*e" 
[0145] epsilon
@item "\*f" 
[0146] phi
@item "\*g" 
[0147] gamma
@item "\*y" 
[0150] eta
@item "\*i" 
[0151] iota
@item "\+f" 
[0152] phi1
@item "\*k" 
[0153] kappa
@item "\*l" 
[0154] lambda
@item "\*m" 
[0155] mu
@item "\*n" 
[0156] nu
@item "\*o" 
[0157] omicron
@item "\*p" 
[0160] pi
@item "\*h" 
[0161] theta
@item "\*r" 
[0162] rho
@item "\*s" 
[0163] sigma
@item "\*t" 
[0164] tau
@item "\*u" 
[0165] upsilon
@item "\+p" 
[0166] omega1
@item "\*w" 
[0167] omega
@item "\*c" 
[0170] xi
@item "\*q" 
[0171] psi
@item "\*z" 
[0172] zeta
@item "\ap" 
[0176] similar
@item "\+U" 
[0241] Upsilon1
@item "\fm" 
[0242] minute
@item "\<=" 
[0243] lessequal
@item "\f/" 
[0244] fraction
@item "\if" 
[0245] infinity
@item "\Fn" 
[0246] florin
@item "\CL" 
[0247] club
@item "\DI" 
[0250] diamond
@item "\HE" 
[0251] heart
@item "\SP" 
[0252] spade
@item "\<>" 
[0253] arrowboth
@item "\<-" 
[0254] arrowleft
@item "\ua" 
[0255] arrowup
@item "\->" 
[0256] arrowright
@item "\da" 
[0257] arrowdown
@item "\de" 
[0260] degree
@item "\+-" 
[0261] plusminus
@item "\sd" 
[0262] second
@item "\>=" 
[0263] greaterequal
@item "\mu" 
[0264] multiply
@item "\pt" 
[0265] proportional
@item "\pd" 
[0266] partialdiff
@item "\bu" 
[0267] bullet
@item "\di" 
[0270] divide
@item "\!=" 
[0271] notequal
@item "\==" 
[0272] equivalence
@item "\~~" 
[0273] approxequal
@item "\.." 
[0274] ellipsis
@item NONE 
[0275] arrowvertex
@item "\an" 
[0276] arrowhorizex
@item "\CR" 
[0277] carriagereturn
@item "\Ah" 
[0300] aleph
@item "\Im" 
[0301] Ifraktur
@item "\Re" 
[0302] Rfraktur
@item "\wp" 
[0303] weierstrass
@item "\c*" 
[0304] circlemultiply
@item "\c+" 
[0305] circleplus
@item "\es" 
[0306] emptyset
@item "\ca" 
[0307] cap
@item "\cu" 
[0310] cup
@item "\SS" 
[0311] superset
@item "\ip" 
[0312] reflexsuperset
@item "\n<" 
[0313] notsubset
@item "\SB" 
[0314] subset
@item "\ib" 
[0315] reflexsubset
@item "\mo" 
[0316] element
@item "\nm" 
[0317] notelement
@item "\/_" 
[0320] angle
@item "\gr" 
[0321] nabla
@item "\rg" 
[0322] registerserif
@item "\co" 
[0323] copyrightserif
@item "\tm" 
[0324] trademarkserif
@item "\PR" 
[0325] product
@item "\sr" 
[0326] radical
@item "\md" 
[0327] dotmath
@item "\no" 
[0330] logicalnot
@item "\AN" 
[0331] logicaland
@item "\OR" 
[0332] logicalor
@item "\hA" 
[0333] arrowdblboth
@item "\lA" 
[0334] arrowdblleft
@item "\uA" 
[0335] arrowdblup
@item "\rA" 
[0336] arrowdblright
@item "\dA" 
[0337] arrowdbldown
@item "\lz" 
[0340] lozenge
@item "\la" 
[0341] angleleft
@item "\RG" 
[0342] registersans
@item "\CO" 
[0343] copyrightsans
@item "\TM" 
[0344] trademarksans
@item "\SU" 
[0345] summation
@item NONE 
[0346] parenlefttp
@item NONE 
[0347] parenleftex
@item NONE 
[0350] parenleftbt
@item "\lc" 
[0351] bracketlefttp
@item NONE 
[0352] bracketleftex
@item "\lf" 
[0353] bracketleftbt
@item "\lt" 
[0354] bracelefttp
@item "\lk" 
[0355] braceleftmid
@item "\lb" 
[0356] braceleftbt
@item "\bv" 
[0357] braceex
@item "\eu"
[0360] euro
@item "\ra" 
[0361] angleright
@item "\is" 
[0362] integral
@item NONE 
[0363] integraltp
@item NONE 
[0364] integralex
@item NONE 
[0365] integralbt
@item NONE 
[0366] parenrighttp
@item NONE 
[0367] parenrightex
@item NONE 
[0370] parenrightbt
@item "\rc" 
[0371] bracketrighttp
@item NONE 
[0372] bracketrightex
@item "\rf" 
[0373] bracketrightbt
@item "\RT" 
[0374] bracerighttp
@item "\rk" 
[0375] bracerightmid
@item "\rb" 
[0376] bracerightbt
@end table

Finally, there are escape sequences that apply only if the current font
is a Hershey font.  Most of these escape sequences provide access to
special symbols that belong to no font, and are accessible by no other
means.  These symbols are of two sorts: miscellaneous, and astronomical
or zodiacal.  The escape sequences for the miscellaneous symbols are as
follows.

@table @asis
@item "\dd"
daggerdbl
@item "\dg"
dagger
@item "\hb"
hbar
@item "\li"
lineintegral
@item "\IB"
interbang
@item "\Lb"
lambdabar
@item "\~-"
modifiedcongruent
@item "\-+"
minusplus
@item "\||"
parallel
@item "\s-"
[variant form of s]
@end table

@noindent
The final escape sequence in the table above, "\s-", yields a letter
rather than a symbol.  @w{It is} provided because in some Hershey fonts,
the shape of the lower-case @w{letter `s'} differs if it is the last
letter in a word.  This is the case for HersheyGothicGerman.  The German
word "besonders", for example, should be written as "besonder\s-" if it
is to be rendered correctly in this font.  The same is true for the two
Hershey symbol fonts, with their Greek alphabets (in Greek text,
lower-case @w{final `s'} is different from lower-case @w{non-final
`s'}).  @w{In Hershey} fonts where there is no distinction between final
and @w{non-final `s'}, @w{"s" and "\s-"} are equivalent.

The escape sequences for the astronomical symbols, including the signs
for the twelve constellations of the zodiac, are listed in the following
table.  We stress that that like the preceding miscellaneous escape
sequences, they apply only if the current font is a Hershey font.

@table @asis
@item "\SO"
sun
@item "\ME"
mercury
@item "\VE"
venus
@item "\EA"
earth
@item "\MA"
mars
@item "\JU"
jupiter
@item "\SA"
saturn
@item "\UR"
uranus
@item "\NE"
neptune
@item "\PL"
pluto
@item "\LU"
moon
@item "\CT"
comet
@item "\ST"
star
@item "\AS"
ascendingnode
@item "\DE"
descendingnode
@item "\AR"
aries
@item "\TA"
taurus
@item "\GE"
gemini
@item "\CA"
cancer
@item "\LE"
leo
@item "\VI"
virgo
@item "\LI"
libra
@item "\SC"
scorpio
@item "\SG"
sagittarius
@item "\CP"
capricornus
@item "\AQ"
aquarius
@item "\PI"
pisces
@end table

The preceding miscellaneous and astronomical symbols are not the only
special non-font symbols that can be used if the current font is a
Hershey font.  The entire library of glyphs digitized by Allen Hershey
is built into GNU @code{libplot}.  @w{So text} strings may include any
Hershey glyph.  Each of the available Hershey glyphs is identified by a
four-digit number.  Standard Hershey @w{glyph #1} would be specified as
"\#H0001".  The standard Hershey glyphs range from "\#H0001" to
"\#H3999", with a number of gaps.  Some additional glyphs designed by
others appear in the "\#H4000"@dots{}"\#H4194" range.  Syllabic Japanese
characters (Kana) are located in the "\#H4195"@dots{}"\#H4399" range.

You may order a table of nearly all the Hershey glyphs in the
"\#H0001"@dots{}"\#H3999" range from the U.S. National Technical
Information Service, at @w{+1 703} 487 4650.  Ask for item number
PB251845; the current price is about US$40.  By way of example, the
string

@example
"\#H0744\#H0745\#H0001\#H0002\#H0003\#H0869\#H0907\#H2330\#H2331"
@end example

@noindent
when drawn will display a shamrock, a fleur-de-lys, cartographic (small)
letters @w{A, B, C}, @w{a bell,} @w{a large} circle, @w{a treble}
clef, and @w{a bass} clef.  Again, this assumes that the current font is
a Hershey font.

You may also use Japanese syllabic characters (Hiragana and Katakana)
and ideographic characters (Kanji) when drawing strings in any Hershey
font.  @w{In all}, 603 Kanji are available; these are the same Kanji
that are available in the HersheyEUC font.  The Japanese characters are
indexed according to the JIS X0208 standard for Japanese typography,
which represents each character by a two-byte sequence.  The file
@file{kanji.doc}, which is distributed along with the GNU plotting
utilities, lists the available Kanji.  @w{On most} systems it is
installed in @file{/usr/share/libplot} or
@file{/usr/local/share/libplot}.

Each JIS X0208 character would be specified by an escape sequence which
expresses this two-byte sequence as four hexadecimal digits, such as
"\#J357e".  Both bytes must be in the @code{0x21}@dots{}@code{0x7e}
range in order to define a JIS X0208 character.  Kanji are located at
"\#J3021" and above.  Characters appearing elsewhere in the JIS X0208
encoding may be accessed similarly.  For example, Hiragana and Katakana
are located in the "\#J2421"@dots{}"\#J257e" range, and Roman characters
in the "\#J2321"@dots{}"\#J237e" range.  The file @file{kana.doc}, which
is installed in the same directory as @file{kanji.doc}, lists the
encodings of the Hiragana and Katakana.  For more on the JIS X0208
standard, see Ken Lunde's @cite{Understanding Japanese Information
Processing} (O'Reilly, 1993), and
@uref{http://www.ora.com/people/authors/lunde/cjk_inf.html, his on-line
supplement}.

The Kanji numbering used in @w{A. N.} Nelson's @cite{Modern Reader's
Japanese-English Character Dictionary}, @w{a longtime} standard, is also
supported.  (This dictionary is published by @w{C. E.} Tuttle and Co.,
with ISBN 0-8048-0408-7.  @w{A revised} edition [ISBN 0-8048-2036-8]
appeared in 1997, but uses a different numbering.)  `Nelson' escape
sequences for Kanji are similar to JIS X0208 escape sequences, but use
four decimal instead of four hexadecimal digits.  The file
@file{kanji.doc} gives the correspondence between the JIS numbering
scheme and the Nelson numbering scheme.  @w{For example}, "\#N0001" is
equivalent to "\#J306c".  @w{It also} gives the positions of the
available Kanji in the Unicode encoding.

All available Kanji have the same width, which is the same as that of
the syllabic Japanese characters (Hiragana and Katakana).  Each Kanji
that is not available will print as an `undefined character' glyph (@w{a
bundle} of horizontal lines).  The same is true for non-Kanji JIS X0208
characters that are not available.

@node Marker Symbols, , Text String Format, Text and Markers
@appendixsection Available marker symbols

The GNU @code{libplot} library supports a standard set of marker
symbols, numbered 0@dots{}31.  @w{A marker} symbol is a visual
representation of a point.  The @code{libplot} marker symbols are the
symbols that the @code{graph} program will plot at each point of a
dataset, if the @samp{-S} option is specified.

Like a text string, a marker symbol has a font size.  @w{In any} output
format, @w{a marker} symbol is guaranteed to be visible if its font size
is sufficiently large.  Marker symbol #0 is an exception to this: by
convention, @w{symbol #0} means no symbol @w{at all}.  Marker symbols in
the range 1@dots{}31 are defined @w{as follows}.

@enumerate
@item dot
@tex
($\thinspace\cdot\thinspace$)
@end tex
@item plus (@math{+})
@item asterisk (@math{*})
@item circle
@tex
($\circ$)
@end tex
@item cross
@tex
($\times$)
@end tex
@item square
@item triangle
@item diamond
@item star
@item inverted triangle
@item starburst
@item fancy plus
@item fancy cross
@item fancy square
@item fancy diamond
@item filled circle
@item filled square
@item filled triangle
@item filled diamond
@item filled inverted triangle
@item filled fancy square
@item filled fancy diamond
@item half filled circle
@item half filled square
@item half filled triangle
@item half filled diamond
@item half filled inverted triangle
@item half filled fancy square
@item half filled fancy diamond
@item octagon
@item filled octagon
@end enumerate

@noindent
The interpretation of marker symbols 1 through 5 is the same as in the
@w{well known} Graphical Kernel System (GKS).

By convention, symbols 32 @w{and up} are interpreted as characters in a
certain text font.  For @code{libplot}, this is simply the current font.
But for the @code{graph} program, @w{it is} the symbol font selected
with the @samp{--symbol-font-name} option.  @w{By default}, the symbol
font is the ZapfDingbats font except in @code{graph -T png}, @code{graph
-T pnm}, @code{graph -T gif}, @code{graph -T pcl}, @code{graph -T hpgl}
and @code{graph -T tek}.  Those variants of @code{graph} normally have
no access to ZapfDingbats and other Postscript fonts, so they use the
HersheySerif font instead.

Many of the characters in the ZapfDingbats font are suitable for use as
marker symbols.  For example, character #74 is the Texas star.  Doing

@example
echo 0 0 1 2 2 1 3 2 4 0 | graph -T ps -m 0 -S 74 0.1 > plot.ps
@end example

@noindent
will produce a Postscript plot consisting of five data points, not
joined by line segments.  Each data point will be marked by a Texas
star, of a large font size (@w{0.1 times} the width of the plotting
box).

If you are using @code{graph -T pcl} or @code{graph -T hpgl} and wish to
use font characters as marker symbols, you should consider using the
Wingdings font, which is available when producing @w{PCL 5} or HP-GL/2
output.  Doing

@example
echo 0 0 1 2 2 1 3 2 4 0 | 
    graph -T pcl -m 0 --symbol-font Wingdings -S 181 0.1 > plot.pcl
@end example

@noindent
will produce a @w{PCL 5} plot that is similar to the preceding
Postscript plot.  The Wingdings font has the Texas star in location
#181.

@node Color Names, Page and Viewport Sizes, Text and Markers, Appendices
@appendix Specifying Colors by Name

The GNU @code{libplot} library allows colors to be specified by the
user.  It includes the @code{bgcolorname}, @code{pencolorname}, and
@code{fillcolorname} functions, each of which takes a color as an
argument.

The command-line graphics programs built on @code{libplot}, namely
@code{graph}, @code{plot}, @code{pic2plot}, @code{tek2plot}, and
@code{plotfont}, allow colors to be specified on the command line.  Each
of them supports a @samp{--bg-color} option, and each of them, other
than @code{graph}, supports a @samp{--pen-color} option.  (@code{graph}
supports a more complicated @samp{--pen-colors} option, and a
@samp{--frame-color} option.)

In any of these contexts, a color may be specified precisely as a
hexadecimal string that gives by its 48-bit RGB representation.  For
example, "#c0c0c0" is a silvery gray, and "#ffffff" is white.  Also,
colors may be specified by name.  665 distinct names are recognized,
including familiar ones like "red", "green", and "blue", and obscure
ones like "dark magenta", "forest green", and "olive drab".  Color names
are case-insensitive, and spaces are ignored.  So, @w{for example},
"RosyBrown" is equivalent to "rosy brown", and "DarkGoldenrod3" to "dark
goldenrod 3".

The file @file{colors.txt}, which is distributed along with the GNU
plotting utilities, lists the 665 recognized color names.  @w{On most}
systems it is installed in @file{/usr/share/libplot} or
@file{/usr/local/share/libplot}.  The names are essentially those
recognized by recent releases of the @w{X Window} System, which on most
machines are listed in the file @file{/usr/lib/X11/rgb.txt}.  However,
for every color name containing the string "gray", @w{a version}
containing "grey" has been included.  @w{For example}, both "dark slate
gray 4" and "dark slate grey 4" are recognized color names.

@node Page and Viewport Sizes, Metafiles, Color Names, Appendices
@appendix Page Sizes and Viewport Sizes

When producing output in such formats as Illustrator, Postscript, @w{PCL
5}, HP-GL, and Fig, it is important to specify the size of the page on
which the output will be printed.  The GNU @code{libplot} library allows
the user to specify a @code{PAGESIZE} parameter, which can be used for
this.  The command-line graphics programs @code{graph}, @code{plot},
@code{pic2plot}, @code{tek2plot}, and @code{plotfont}, which are
@w{built on} @code{libplot}, support a @code{PAGESIZE} environment
variable and a @samp{--page-size} option.

Graphics drawn by @code{libplot} are nominally drawn within a graphics
display, or `viewport'.  When producing such raster formats as PNG, PNM,
and pseudo-GIF, @w{it will} use a square or rectangular bitmap as its
viewport.  But when producing Illustrator, Postscript, @w{PCL 5}, HP-GL,
and Fig format, it will use a square or rectangular region on the page
as its viewport.  Except in the HP-GL case, the viewport will @w{by
default} be centered on the page.  Graphics will not be clipped to the
viewport, so the entire page will @w{in principle} be imageable.

Either or both of the dimensions of the graphics display can be
specified explicitly.  For example, the page size could be specified as
"letter,xsize=4in", or "a4,xsize=10cm,ysize=15cm".  The dimensions of
the graphics display are allowed to be negative (@w{a negative}
dimension results in a reflection).  Inches, centimeters, and
millimeters are the supported units.

@w{It is} also possible to position the graphics display precisely, by
specifying the location of its lower left corner relative to the lower
left corner of the page.  For example, the page size could be specified
not merely as "letter" @w{or "a4"}, but as
"letter,xorigin=2in,yorigin=3in", or "a4,xorigin=0.5cm,yorigin=0.5cm".
In all cases, the viewport position may be adjusted by specifying an
offset vector.  For example, the page size could be specified as
"letter,yoffset=1.2in", or "a4,xoffset=@minus{}5mm,yoffset=2.0cm".  The
viewport may also be rotated, by setting the @code{ROTATION} parameter
or environment variable, or (@w{in the} case of the graphics programs)
by using the @samp{--rotation} option.  A rotated viewport does not
change the position of its four corners.  Rather, the graphics are
rotated @w{within it}.  @w{If the} viewport is rectangular rather than
square, this `rotation' necessarily includes a rescaling.

Any ISO page size in the range "a0"@dots{}"a4" or ANSI page size in the
range "a"@dots{}"e" may be specified.  ("letter" is an alias @w{for
"a"}, which is the default, and "tabloid" is an alias @w{for "b"}).
"legal", "ledger", and the JIS [Japanese Industrial Standard] size "b5"
are recognized also.  The following are the supported page sizes and the
default square viewport size that corresponds to each.

@table @asis
@item "a" (or "letter"; 8.5@dmn{in} by 11.0@dmn{in})
8.0@dmn{in}

@item "b" (or "tabloid"; 11.0@dmn{in} by 17.0@dmn{in})
10.0@dmn{in}

@item "c" (17.0@dmn{in} by 22.0@dmn{in})
16.0@dmn{in}

@item "d" (22.0@dmn{in} by 34.0@dmn{in})
20.0@dmn{in}

@item "e" (34.0@dmn{in} by 44.0@dmn{in})
32.0@dmn{in}

@item "legal" (8.5@dmn{in} by 14.0@dmn{in})
8.0@dmn{in}

@item "ledger" (17.0@dmn{in} by 11.0@dmn{in})
10.0@dmn{in}

@item "a4" (21.0@dmn{cm} by 29.7@dmn{cm})
19.81@dmn{cm}

@item "a3" (29.7@dmn{cm} by 42.0@dmn{cm})
27.18@dmn{cm}

@item "a2" (42.0@dmn{cm} by 59.4@dmn{cm})
39.62@dmn{cm}

@item "a1" (59.4@dmn{cm} by 84.1@dmn{cm})
56.90@dmn{cm}

@item "a0" (84.1@dmn{cm} by 118.9@dmn{cm})
81.79@dmn{cm}

@item "b5" (18.2@dmn{cm} by 25.7@dmn{cm})
16.94@dmn{cm}
@end table

SVG format and WebCGM format have no notion of the Web page on which the
viewport will ultimately be positioned.  They do have a notion of
default viewport size, though this will normally be overridden when the
output file is placed on a Web page.  When producing SVG or WebCGM
output, this default viewport size is set by @code{PAGESIZE}, or (@w{in
the} case of the graphics programs) the @samp{--page-size} option.  The
"xorigin", "yorigin", "xoffset", and "yoffset" specifiers, if included,
are ignored.

For a similar reason, the "xorigin" and "yorigin" specifiers are ignored
when producing HP-GL or HP-GL/2 output.  The lower left corner of the
viewport is positioned at the HP-GL `scaling @w{point' P1}, whose
location is device-dependent.  The "xoffset" and "yoffset" specifiers
are respected, however, and may be used to reposition the viewport.

@node Metafiles, Auxiliary Software, Page and Viewport Sizes, Appendices
@appendix The Graphics Metafile Format

A GNU graphics metafile is produced by any application that uses the
Metafile Plotter support contained in GNU @code{libplot}.  That includes
the raw variants of @code{graph}, @code{plot}, @code{pic2plot},
@code{tek2plot}, and @code{plotfont}.  @w{A metafile} is a sort of audit
trail, which specifies a sequence of Plotter operations.  Each operation
is represented by an @w{`op code'}: @w{a single} ASCII character.  The
arguments of the operation, @w{if any}, immediately follow the @w{op
code}.

A metafile may use either of two encodings: binary (the default) or
portable (human-readable).  Metafiles in the binary encoding begin with
the magic string @w{"#PLOT 1\n"}, and metafiles in the portable encoding
with the magic string @w{"#PLOT 2\n"}.  @w{If you} intend to transfer
metafiles between machines of different types, you should use the
portable rather than the binary encoding.  Portable metafiles are
produced by Metafile Plotters if the @code{META_PORTABLE} parameter is
set to "yes", and by the raw variants of GNU @code{graph} and the other
command-line graphics programs if the @samp{-O} option is specified.
Both binary and portable metafiles can be translated to other formats by
GNU @code{plot}.  @xref{plot}.

In the portable encoding, the arguments of each operation (integers,
floating point numbers, or strings) are printed in a human-readable
form, separated by spaces, and each argument list ends with a newline.
@w{In the} binary encoding, the arguments are represented as integers,
single precision floating point numbers, or newline-terminated ASCII
strings.  Using the newline character as a terminator is acceptable
because each Plotter operation includes a maximum of one string among
its arguments, and such a string may not include a newline.  Also, the
string must come last among the arguments.

There are 97 Plotter operations in all.  The most important are
@code{openpl} and @code{closepl}, which open and close a Plotter, i.e.,
begin and end a page of graphics.  They are represented by the @w{op
codes} @w{@samp{o} and @samp{x}}, respectively.  The @code{erase}
operation, if present, separates frames within a page.  On real-time
display devices, @w{it is} interpreted as a screen erasure.  @w{It is}
represented by the @w{op code @samp{e}}.

Each of the 94 other Plotter operations has a corresponding @w{op code},
with 12 exceptions.  These 12 exceptions are @w{(1) the} control
operation @code{flushpl}, @w{(2) the} operations @code{havecap},
@code{labelwidth}, and @code{flabelwidth}, which merely return
information, @w{(3) the} @code{color}, @code{colorname},
@code{pencolorname}, @code{fillcolorname}, and @code{bgcolorname}
operations, which are internally mapped to @code{pencolor},
@code{fillcolor}, and @code{bgcolor}, @w{(4) the} @code{frotate},
@code{fscale}, and @code{ftranslate} operations, which are internally
mapped to @code{fconcat}, and @w{(5) the} @code{ffontname} operation,
which in a metafile would be indistinguishable from @code{fontname}.
@w{So besides} @w{@samp{o} and @samp{x}}, there are 83 possible @w{op
codes}, for a total @w{of 85}.  The following table lists 10 of the
@w{op codes} other than @w{@samp{o} and @samp{x}}, followed by the
Plotter operation they @w{stand for}.

@table @asis
@item Op Code
Operation
@item @samp{a}
@code{arc}
@item @samp{c}
@code{circle}
@item @samp{e}
@code{erase}
@item @samp{f}
@code{linemod}
@item @samp{l}
@code{line}
@item @samp{m}
@code{move}
@item @samp{n}
@code{cont}
@item @samp{p}
@code{point}
@item @samp{s}
@code{space}
@item @samp{t}
@code{label}
@end table

@noindent
The full set of 85 @w{op codes} is listed in the @code{libplot} header
file @file{plot.h} and the @code{libplotter} header file
@file{plotter.h}, which are distributed along with the plotting
utilities.  @w{On most} systems they are installed in
@file{/usr/include} or @file{/usr/local/include}.

The 10 op codes in the table above are actually the @w{op codes} of the
traditional `plot(5)' format produced by pre-GNU versions of
@code{graph} and @code{libplot}.  The use of these @w{op codes} make GNU
metafile format compatible with plot(5) format.  The absence of a magic
string, and the absence of the @w{@samp{o} and @samp{x}} @w{op codes},
makes it possible to distinguish files in plot(5) format from GNU
metafiles in the binary encoding.  GNU @code{plot} can convert files in
plot(5) format to GNU metafiles in either the binary or the portable
encoding.  @xref{plot}.

@node Auxiliary Software, History and Acknowledgements, Metafiles, Appendices
@appendix Obtaining Auxiliary Software

@menu
* idraw::       Obtaining the idraw drawing editor
* xfig::        Obtaining the xfig drawing editor
@end menu

@node idraw, xfig, Auxiliary Software, Auxiliary Software
@section How to get @code{idraw}

The @code{idraw} utility mentioned several times in this documentation
is a freely distributable interactive drawing editor for the @w{X
Window} System.  @w{It can} display and edit the output of any
application that uses the Postscript Plotter support contained in GNU
@code{libplot}.  That includes @code{graph -T ps}, @code{plot -T ps},
@code{pic2plot -T ps}, @code{tek2plot -T ps}, and @code{plotfont -T ps}.

The current version of @code{idraw} is maintained by Vectaport, Inc.,
and is available at @uref{http://www.vectaport.com, their Web site}.
@w{It is} part of the @code{ivtools} package, which is a framework for
building custom drawing editors.  @code{idraw} was originally part of
the @code{InterViews} package, developed by Stanford University and
Silicon Graphics.  The @code{InterViews} package is available at
@uref{ftp://interviews.stanford.edu, a distribution site}, but is 
@w{no longer} supported.  Retrieving the @code{ivtools} package instead
is recommended.

Also available at @uref{http://www.vectaport.com, Vectaport's Web site}
is an enhanced version of @code{idraw} called @code{drawtool}.
@code{drawtool} can import additional graphics in TIFF and PBM/PGM/PPM
formats, besides the X11 bitmaps that @code{idraw} can import.

@node xfig, , idraw, Auxiliary Software
@section How to get @code{xfig}

The @code{xfig} utility mentioned several times in this documentation is
a freely distributable interactive drawing editor for the @w{X Window}
System.  @w{It can} display and edit the output of any application that
uses the Fig Plotter support contained in GNU @code{libplot}.  That
includes @code{graph -T fig}, @code{plot -T fig}, @code{pic2plot -T
fig}, @code{tek2plot -T fig}, and @code{plotfont -T fig}.

The current version is available at
@uref{ftp://ftp.x.org/contrib/applications/drawing_tools/}.  It can
import additional graphics in GIF, X11 bitmap, and Postscript formats.
Accompanying the editor is a package called @code{transfig}, which
allows @code{xfig} graphics to be exported in many formats.  GIF, X11
bitmap, La@TeX{}, and Postscript formats are supported.

There is @uref{http://duke.usask.ca/~macphed/soft/fig, a Web page on Fig
format}, which discusses application software that can interoperate with
@code{xfig}.

@node History and Acknowledgements, Reporting Bugs, Auxiliary Software, Appendices
@unnumbered History and Acknowledgements

Several of the GNU plotting utilities were inspired by Unix plotting
utilities.  A @code{graph} utility and various plot filters were present
in the first releases of Unix from Bell Laboratories, going @w{at least}
as far back as the @w{Version 4} distribution (1973).  The first
supported display device was a Tektronix 611 storage scope.  Most of the
work on tying the plot filters together and breaking out
device-dependent versions of @code{libplot} was performed by
@email{llc@@research.att.com, Lorinda Cherry}.
@w{By the} time of @w{Version 7} Unix (1979) and the subsequent Berkeley
releases, the package consisting of @code{graph}, @code{plot},
@code{spline}, and several device-dependent versions of @code{libplot}
was a standard Unix feature.  Supported devices by the early 1980's
included Tektronix storage scopes, early graphics terminals,
200@dmn{dpi} electrostatic printer/plotters from Versatec and Varian,
and pen plotters from Hewlett--Packard.

In 1989, @email{rich@@freebsd.org, Rich Murphey} wrote the first GNU
versions of @code{graph}, @code{plot}, and @code{spline}, and the
earliest documentation.  Richard Stallman further directed development
of the programs and provided editorial support for the documentation.
@email{interran@@uluru.stanford.edu, John Interrante}, then of the
InterViews team at Stanford, generously provided the @code{idraw}
Postscript prologue now included in @code{libplot}, and helpful
comments.  The package as it stood in 1991 was distributed under the
name `GNU graphics'.

In 1995 @email{rsm@@math.arizona.edu, Robert S. Maier} took over
development of the package, and designed and wrote the current,
maximally device-independent, standalone version of @code{libplot}.
He also rewrote @code{graph} from scratch, turning it into a real-time
filter that would use the new library.  He fleshed out @code{spline}
too, by adding support for splines in tension, periodicity, and cubic
Bessel interpolation.

@code{libplot} now incorporates the @w{X Window} System code for filling
polygons and drawing wide polygonal lines and arcs.  The code is used
when producing output in bitmap formats (e.g., PNG, PNM, and
pseudo-GIF)@.  @w{It was} written by Brian Kelleher, Joel McCormack,
Todd Newman, Keith Packard, Robert Scheifler and Ken Whaley, who worked
for Digital Equipment Corp., MIT, and/or the @w{X Consortium}, and is
copyright @copyright{} 1985--89 by the @w{X Consortium}.

The pseudo-GIF support now in @code{libplot} uses the `miGIF' run-length
encoding routines developed by 
@email{mouse@@rodents.montreal.qc.ca, der Maus} and 
@email{ivo@@hasc.com, ivo}, which are copyright @copyright{} 1998 
by @uref{http://www.hasc.com, Hutchison Avenue Software Corporation}.
The copyright notice and permission notice for the miGIF routines 
are distributed with the source code distribution of the plotting utilities.

Most development work on @code{ode} was performed by
@email{nbt@@reed.edu, Nick Tufillaro} in 1978--1994, on a sequence of
platforms that extended back to a PDP-11 running @w{Version 4} Unix.  In
1997 Robert Maier modified his 1994 version to agree with GNU
conventions on coding and command-line parsing, extended it to support
the full set of special functions supported by @code{gnuplot}, and
extended the exception handling.

Many other people aided the development of the plotting utilities
package along the way.  The Hershey vector fonts now in @code{libplot}
are @w{of course} based on the characters digitized in the mid to late
1960's by @w{Allen V.} Hershey, who deserves a vote of thanks.
Additional characters and/or marker symbols were taken from the SLAC
Unified Graphics System developed by @w{Robert C.} Beach in the
mid-1970's, and from the fonts designed by
@email{wolff@@inf.fu-berlin.de, Thomas Wolff} for Ghostscript.  The
interpolation algorithms used in @code{spline} are based on the
algorithms of @email{cline@@cs.utexas.edu, @w{Alan K.} Cline}, as
described in his papers in the Apr.@: 1974 issue of @cite{Communications
of the ACM}@.  The table-driven parser used in @code{tek2plot} was
written at Berkeley in the mid-1980's by @email{moy@@parc.xerox.com,
Edward Moy}.  The `sagitta' algorithm used in an extended form in
@code{libplot} for drawing circular and elliptic arcs was developed by
Peter Karow of URW and @email{turk@@apple.com, Ken Turkowski} of Apple.
@email{toy@@rtp.ericsson.se, Raymond Toy}
helped with the tick mark
spacing code in @code{graph} and was the first to incorporate GNU
@code{getopt}.  Arthur Smith, formerly of LASSP at Cornell, provided
code for his @code{xplot} utility.  
@email{beebe@@math.utah.edu, Nelson Beebe}
exhaustively tested the package installation process.

Robert Maier wrote the documentation, which now incorporates Nick
Tufillaro's @code{ode} manual.  Julie Sussmann checked over the
documentation for style and clarity.

@node Reporting Bugs, , History and Acknowledgements, Appendices
@unnumbered Reporting Bugs

Please report all bugs in the GNU plotting utilities to
@email{bug-gnu-utils@@gnu.org}.  @w{Be sure} to say which version of the
plotting utilities package you have.  Each command-line program
announces the package version if you use the @samp{--version} argument.

If you installed the plotting utilities from scratch, be sure to say
what compiler (and compiler version) you used.  @w{If your} problems
are installation-related, be sure to give all relevant information.

@contents
@bye