File: plplot_traditional.adb

package info (click to toggle)
plplot 5.10.0%2Bdfsg2-0.4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 25,792 kB
  • ctags: 13,517
  • sloc: ansic: 83,001; xml: 27,081; ada: 18,878; cpp: 15,966; tcl: 11,651; python: 7,075; f90: 7,058; ml: 6,974; java: 6,665; perl: 5,029; sh: 2,208; makefile: 210; lisp: 75; sed: 25; fortran: 7
file content (3525 lines) | stat: -rw-r--r-- 136,737 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
-- $Id: plplot_traditional.adb 12862 2013-12-13 10:18:08Z jbauck $

-- Ada binding to PLplot using the traditional PLplot subprogram names

-- Copyright (C) 2006-2013 Jerry Bauck

-- This file is part of PLplot.

-- PLplot is free software; you can redistribute it and/or modify
-- it under the terms of the GNU Library General Public License as published
-- by the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.

-- PLplot is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-- GNU Library General Public License for more details.

-- You should have received a copy of the GNU Library General Public License
-- along with PLplot; if not, write to the Free Software
-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

with
    PLplot_Thin,
    PLplot_Auxiliary,
    Ada.Text_IO,
    Ada.Numerics.Long_Elementary_Functions,
    Ada.Strings.Unbounded,
    Ada.Unchecked_Conversion,
    Ada.Strings.Maps,
    Ada.Command_Line,
    System,
    System.Address_To_Access_Conversions,
    Interfaces.C.Pointers,
    Interfaces.C;
use
    Ada.Text_IO,
    PLplot_Auxiliary,
    Ada.Numerics.Long_Elementary_Functions,
    Ada.Strings.Unbounded,
    Interfaces.C;

package body PLplot_Traditional is    

--------------------------------------------------------------------------------
--        High-Level subroutines for thick binding                            --
--------------------------------------------------------------------------------

    -- When asked to draw white lines on black background, do it.
    -- This is the default.
    procedure Draw_On_Black is
    begin
        plscol0(Black, 0,   0  ,   0);
        plscol0(White, 255, 255, 255);
    end Draw_On_Black;

    
    -- When asked to draw black lines on white background, reverse black and white.
    -- This might look better on anti-aliased displays.
    -- fix this Darken some colors which have low contrast on white background, e.g. Yellow.
    -- fix this Make a version that draws on white and converts _all_ colors to black for publications.
    -- fix this Make this so that it works on Color Map 1 because as of now, it does
    -- not change the background color for e.g. surface plots. See also Draw_On_Black.
    procedure Draw_On_White is
    begin
        plscol0(Black, 255, 255, 255);
        plscol0(White, 0,   0,   0);
    end Draw_On_White;
    
    
    -- Set default pen width. Docs don't say, so I'll make it 1.
    -- I could make this depend on the type of outut device used.
    Default_Pen_Width : constant Long_Float := 1.0;
    procedure Set_Default_Pen_Width is
    begin
        plwidth(Default_Pen_Width);
    end Set_Default_Pen_Width;


    -- Plotter for up to five x-y pairs and settable axis style, plot 
    -- line colors, widths, and styles, justification, zoom, and labels.
    -- Can be used directly or as part of a "simple" plotter 
    -- such as those that follow or which are made by the user.
    -- fixme Add capability for labels, legends.
    procedure Multiplot_Pairs
       (x1            : Real_Vector     := Dont_Plot_This;
        y1            : Real_Vector     := Dont_Plot_This;
        x2            : Real_Vector     := Dont_Plot_This;
        y2            : Real_Vector     := Dont_Plot_This;
        x3            : Real_Vector     := Dont_Plot_This;
        y3            : Real_Vector     := Dont_Plot_This;
        x4            : Real_Vector     := Dont_Plot_This;
        y4            : Real_Vector     := Dont_Plot_This;
        x5            : Real_Vector     := Dont_Plot_This;
        y5            : Real_Vector     := Dont_Plot_This;
        X_Labels      : Label_String_Array_Type := Default_Label_String_Array;
        Y_Labels      : Label_String_Array_Type := Default_Label_String_Array;
        Title_Labels  : Label_String_Array_Type := Default_Label_String_Array;
        Axis_Style    : Axis_Style_Type         := Linear_Box_Plus;
        Colors        : Color_Array_Type        := Default_Color_Array;
        Line_Widths   : Line_Width_Array_Type   := Default_Line_Width_Array;
        Line_Styles   : Line_Style_Array_Type   := Default_Line_Style_Array;
        Justification : Justification_Type      := Not_Justified;
        x_Min_Zoom    : Long_Float              := Long_Float'small;
        x_Max_Zoom    : Long_Float              := Long_Float'large;
        y_Min_Zoom    : Long_Float              := Long_Float'small;
        y_Max_Zoom    : Long_Float              := Long_Float'large) is

        x_Min, y_Min : Long_Float := Long_Float'large;
        x_Max, y_Max : Long_Float := Long_Float'small;

    begin
        -- Set or find x_Min.
        if x_Min_Zoom /= Long_Float'small then -- zoom
            x_Min := x_Min_Zoom;
        else -- Auto-scale x_Min.
            if x1'length /= 1 then
                x_Min := Long_Float'min(x_Min, Vector_Min(x1));
            end if;
            if x2'length /= 1 then
                x_Min := Long_Float'min(x_Min, Vector_Min(x2));
            end if;
            if x3'length /= 1 then
                x_Min := Long_Float'min(x_Min, Vector_Min(x3));
            end if;
            if x4'length /= 1 then
                x_Min := Long_Float'min(x_Min, Vector_Min(x4));
            end if;
            if x5'length /= 1 then
                x_Min := Long_Float'min(x_Min, Vector_Min(x5));
            end if;            
        end if; -- Set or find x_Min.
        
        -- Set or find x_Max.
        if x_Max_Zoom /= Long_Float'large then -- zoom
            x_Max := x_Max_Zoom;
        else  -- Auto-scale x_Max.
            if x1'length /= 1 then
                x_Max := Long_Float'max(x_Max, Vector_Max(x1));
            end if;
            if x2'length /= 1 then
                x_Max := Long_Float'max(x_Max, Vector_Max(x2));
            end if;
            if x3'length /= 1 then
                x_Max := Long_Float'max(x_Max, Vector_Max(x3));
            end if;
            if x4'length /= 1 then
                x_Max := Long_Float'max(x_Max, Vector_Max(x4));
            end if;
            if x5'length /= 1 then
                x_Max := Long_Float'max(x_Max, Vector_Max(x5));
            end if;
        end if; -- Set or find x_Max.

        -- Set or find y_Min.
        if y_Min_Zoom /= Long_Float'small then -- zoom
            y_Min := y_Min_Zoom;
        else -- Auto-scale y_Min.
            if y1'length /= 1 then
                y_Min := Long_Float'min(y_Min, Vector_Min(y1));
            end if;
            if y2'length /= 1 then
                y_Min := Long_Float'min(y_Min, Vector_Min(y2));
            end if;
            if y3'length /= 1 then
                y_Min := Long_Float'min(y_Min, Vector_Min(y3));
            end if;
            if y4'length /= 1 then
                y_Min := Long_Float'min(y_Min, Vector_Min(y4));
            end if;
            if y5'length /= 1 then
                y_Min := Long_Float'min(y_Min, Vector_Min(y5));
            end if;            
        end if; -- Set or find y_Min.
        
        -- Set or find y_Max.
        if y_Max_Zoom /= Long_Float'large then -- zoom
            y_Max := y_Max_Zoom;
        else  -- Auto-scale y_Max.
            if y1'length /= 1 then
                y_Max := Long_Float'max(y_Max, Vector_Max(y1));
            end if;
            if y2'length /= 1 then
                y_Max := Long_Float'max(y_Max, Vector_Max(y2));
            end if;
            if y3'length /= 1 then
                y_Max := Long_Float'max(y_Max, Vector_Max(y3));
            end if;
            if y4'length /= 1 then
                y_Max := Long_Float'max(y_Max, Vector_Max(y4));
            end if;
            if y5'length /= 1 then
                y_Max := Long_Float'max(y_Max, Vector_Max(y5));
            end if;
        end if; -- Set or find x_Max.


        -- Set environment and its color.
        plcol0(White);
--        Set_Environment_Clear_Subpage(x_Min, x_Max, y_Min, y_Max, Justification, Axis_Style);
        plenv(x_Min, x_Max, y_Min, y_Max, Justification, Axis_Style);
        
        if x1'length /= 1 and y1'length /= 1 then
            pllab(To_String(X_Labels(1)), To_String(Y_Labels(1)), To_String(Title_Labels(1)));
            plcol0(Colors(1));
            --Set_Pen_Width(Line_Widths(1));
            pllsty(Line_Styles(1));
            plline(x1, y1);
        end if;

        if x2'length /= 1 and y2'length /= 1 then
            pllab(To_String(X_Labels(2)), To_String(Y_Labels(2)), To_String(Title_Labels(2)));
            plcol0(Colors(2));
            --Set_Pen_Width(Line_Widths(2));
            pllsty(Line_Styles(2));
            plline(x2, y2);
        end if;

        if x3'length /= 1 and y3'length /= 1 then
            pllab(To_String(X_Labels(3)), To_String(Y_Labels(3)), To_String(Title_Labels(3)));
            plcol0(Colors(3));
            --Set_Pen_Width(Line_Widths(3));
            pllsty(Line_Styles(3));
            plline(x3, y3);
        end if;

        if x4'length /= 1 and y4'length /= 1 then
            pllab(To_String(X_Labels(4)), To_String(Y_Labels(4)), To_String(Title_Labels(4)));
            plcol0(Colors(4));
            --Set_Pen_Width(Line_Widths(4));
            pllsty(Line_Styles(4));
            plline(x4, y4);
        end if;

        if x5'length /= 1 and y5'length /= 1 then
            pllab(To_String(X_Labels(5)), To_String(Y_Labels(5)), To_String(Title_Labels(5)));
            plcol0(Colors(5));
            --Set_Pen_Width(Line_Widths(5));
            pllsty(Line_Styles(5));
            plline(x5, y5);
        end if;
        
        plcol0(White);
        Set_Default_Pen_Width;
        pllsty(1); --solid
    end Multiplot_Pairs;


--------- Simple plotters requiring minimal arguments -----

    
    -- Quick plotter requires no x-axis as input; makes x up from indices of first of multiple y's.
    procedure Quick_Plot
       (y1 : Real_Vector := Dont_Plot_This;
        y2 : Real_Vector := Dont_Plot_This;
        y3 : Real_Vector := Dont_Plot_This;
        y4 : Real_Vector := Dont_Plot_This;
        y5 : Real_Vector := Dont_Plot_This;
        X_Label     : String := To_String(Default_Label_String);
        Y_Label     : String := To_String(Default_Label_String);
        Title_Label : String := To_String(Default_Label_String))
    is
        x : Real_Vector(y1'range);
        X_Label_String_Array     : Label_String_Array_Type := Default_Label_String_Array;
        Y_Label_String_Array     : Label_String_Array_Type := Default_Label_String_Array;
        Title_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array;
    begin
        for i in x'range loop
            x(i) := Long_Float(i);
        end loop;

        X_Label_String_Array(1)     := TUB(X_Label);     -- First slot only; others not used.
        Y_Label_String_Array(1)     := TUB(Y_Label);     -- First slot only; others not used.
        Title_Label_String_Array(1) := TUB(Title_Label); -- First slot only; others not used.

        Multiplot_Pairs(x, y1, x, y2, x, y3, x, y4, x, y5, 
            X_Labels     => X_Label_String_Array,
            Y_Labels     => Y_Label_String_Array,
            Title_Labels => Title_Label_String_Array,
            Axis_Style   => Linear_Major_Grid);
    end Quick_Plot;


    -- Simple plotter for single x array and multiple y arrays
    procedure Simple_Plot 
       (x  : Real_Vector;
        y1 : Real_Vector := Dont_Plot_This;
        y2 : Real_Vector := Dont_Plot_This;
        y3 : Real_Vector := Dont_Plot_This;
        y4 : Real_Vector := Dont_Plot_This;
        y5 : Real_Vector := Dont_Plot_This;
        X_Label     : String := To_String(Default_Label_String);
        Y_Label     : String := To_String(Default_Label_String);
        Title_Label : String := To_String(Default_Label_String)) is

        X_Label_String_Array     : Label_String_Array_Type := Default_Label_String_Array;
        Y_Label_String_Array     : Label_String_Array_Type := Default_Label_String_Array;
        Title_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array;

    begin
        X_Label_String_Array(1)     := TUB(X_Label);     -- First slot only; others not used.
        Y_Label_String_Array(1)     := TUB(Y_Label);     -- First slot only; others not used.
        Title_Label_String_Array(1) := TUB(Title_Label); -- First slot only; others not used.

        Multiplot_Pairs(x, y1, x, y2, x, y3, x, y4, x, y5, 
            X_Labels     => X_Label_String_Array,
            Y_Labels     => Y_Label_String_Array,
            Title_Labels => Title_Label_String_Array,
            Axis_Style   => Linear_Major_Grid);
    end Simple_Plot;
    
    
    -- Simple log x plotter for single x array and multiple y arrays
    -- fix this: Automatically skip zero-valued abscissa; place marker at the
    -- left-hand side of the plot at the ordinate of the deleted point.
    procedure Simple_Plot_Log_X
       (x  : Real_Vector;
        y1 : Real_Vector := Dont_Plot_This;
        y2 : Real_Vector := Dont_Plot_This;
        y3 : Real_Vector := Dont_Plot_This;
        y4 : Real_Vector := Dont_Plot_This;
        y5 : Real_Vector := Dont_Plot_This;
        X_Label     : String := To_String(Default_Label_String);
        Y_Label     : String := To_String(Default_Label_String);
        Title_Label : String := To_String(Default_Label_String);
        Log_Base : Long_Float := 10.0) is -- Should this default to e?

        X_Label_String_Array     : Label_String_Array_Type := Default_Label_String_Array;
        Y_Label_String_Array     : Label_String_Array_Type := Default_Label_String_Array;
        Title_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array;

        x_Log : Real_Vector(x'range);

    begin
        X_Label_String_Array(1)     := TUB(X_Label);     -- First slot only; others not used.
        Y_Label_String_Array(1)     := TUB(Y_Label);     -- First slot only; others not used.
        Title_Label_String_Array(1) := TUB(Title_Label); -- First slot only; others not used.

        for i in x_Log'range loop
            x_Log(i) := Log(x(i), Log_Base);
        end loop;        
        Multiplot_Pairs(x_Log, y1, x_Log, y2, x_Log, y3, x_Log, y4, x_Log, y5, 
            X_Labels     => X_Label_String_Array,
            Y_Labels     => Y_Label_String_Array,
            Title_Labels => Title_Label_String_Array,
            Axis_Style   => Log_X_Minor_Grid);
    end Simple_Plot_Log_X;
    
    
    -- Simple log y plotter for multiple x arrays and single y array
    -- fix this: Automatically skip zero-valued ordinate; place marker at the
    -- bottom of the plot at the abscissa of the deleted point.
    procedure Simple_Plot_Log_Y
       (x1 : Real_Vector := Dont_Plot_This;
        y  : Real_Vector := Dont_Plot_This; -- Beware of argument order.
        x2 : Real_Vector := Dont_Plot_This;
        x3 : Real_Vector := Dont_Plot_This;
        x4 : Real_Vector := Dont_Plot_This;
        x5 : Real_Vector := Dont_Plot_This;
        X_Label     : String := To_String(Default_Label_String);
        Y_Label     : String := To_String(Default_Label_String);
        Title_Label : String := To_String(Default_Label_String);
        Log_Base : Long_Float := 10.0) is -- Should this default to e?

        X_Label_String_Array     : Label_String_Array_Type := Default_Label_String_Array;
        Y_Label_String_Array     : Label_String_Array_Type := Default_Label_String_Array;
        Title_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array;

        y_Log : Real_Vector(y'range);

    begin
        X_Label_String_Array(1)     := TUB(X_Label);     -- First slot only; others not used.
        Y_Label_String_Array(1)     := TUB(Y_Label);     -- First slot only; others not used.
        Title_Label_String_Array(1) := TUB(Title_Label); -- First slot only; others not used.

        for i in y_Log'range loop
            y_Log(i) := Log(y(i), Log_Base);
        end loop;        
        Multiplot_Pairs(x1, y_Log, x2, y_Log, x3, y_Log, x4, y_Log, x5, y_Log, 
            X_Labels     => X_Label_String_Array,
            Y_Labels     => Y_Label_String_Array,
            Title_Labels => Title_Label_String_Array,
            Axis_Style   => Log_Y_Minor_Grid);
    end Simple_Plot_Log_Y;
    
    
    -- Simple log x - log y plotter
    procedure Simple_Plot_Log_XY
       (x, y        : Real_Vector;
        X_Label     : String := To_String(Default_Label_String);
        Y_Label     : String := To_String(Default_Label_String);
        Title_Label : String := To_String(Default_Label_String);
        x_Log_Base, y_Log_Base : Long_Float := 10.0) is -- Should this default to e?

        X_Label_String_Array     : Label_String_Array_Type := Default_Label_String_Array;
        Y_Label_String_Array     : Label_String_Array_Type := Default_Label_String_Array;
        Title_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array;

        x_Log : Real_Vector(x'range);
        y_Log : Real_Vector(y'range);
    begin
        X_Label_String_Array(1)     := TUB(X_Label);     -- First slot only; others not used.
        Y_Label_String_Array(1)     := TUB(Y_Label);     -- First slot only; others not used.
        Title_Label_String_Array(1) := TUB(Title_Label); -- First slot only; others not used.

        for i in x_Log'range loop
            x_Log(i) := Log(x(i), x_Log_Base);
            y_Log(i) := Log(y(i), y_Log_Base);
        end loop;        
        Multiplot_Pairs(x_Log, y_Log, 
            X_Labels     => X_Label_String_Array,
            Y_Labels     => Y_Label_String_Array,
            Title_Labels => Title_Label_String_Array,
            Axis_Style   => Log_XY_Minor_Grid);
    end Simple_Plot_Log_XY;
    
    
    -- Simple plotter for multiple x-y arrays specified pairwise.
    procedure Simple_Plot_Pairs
       (x1 : Real_Vector := Dont_Plot_This;
        y1 : Real_Vector := Dont_Plot_This;
        x2 : Real_Vector := Dont_Plot_This;
        y2 : Real_Vector := Dont_Plot_This;
        x3 : Real_Vector := Dont_Plot_This;
        y3 : Real_Vector := Dont_Plot_This;
        x4 : Real_Vector := Dont_Plot_This;
        y4 : Real_Vector := Dont_Plot_This;
        x5 : Real_Vector := Dont_Plot_This;
        y5 : Real_Vector := Dont_Plot_This;
        X_Label     : String := To_String(Default_Label_String);
        Y_Label     : String := To_String(Default_Label_String);
        Title_Label : String := To_String(Default_Label_String)) is

        X_Label_String_Array     : Label_String_Array_Type := Default_Label_String_Array;
        Y_Label_String_Array     : Label_String_Array_Type := Default_Label_String_Array;
        Title_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array;
    begin
        X_Label_String_Array(1)     := TUB(X_Label);     -- First slot only; others not used.
        Y_Label_String_Array(1)     := TUB(Y_Label);     -- First slot only; others not used.
        Title_Label_String_Array(1) := TUB(Title_Label); -- First slot only; others not used.

        Multiplot_Pairs(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, 
            X_Labels     => X_Label_String_Array,
            Y_Labels     => Y_Label_String_Array,
            Title_Labels => Title_Label_String_Array,
            Axis_Style   => Linear_Major_Grid);
    end Simple_Plot_Pairs;


--------- Plotter requiring somewhat more arguments ------

    -- Single plotter with flexible attributes
    -- Similar to Multiplot_Pairs except single trace and no attribute arrays.
    procedure Single_Plot
       (x, y          : Real_Vector;
        X_Label       : String             := To_String(Default_Label_String);
        Y_Label       : String             := To_String(Default_Label_String);
        Title_Label   : String             := To_String(Default_Label_String);
        Axis_Style    : Axis_Style_Type    := Linear_Major_Grid;
        Color         : Plot_Color_Type    := Red;
        Line_Width    : Long_Float         := 1.0;
        Line_Style    : Line_Style_Type    := 1;
        Justification : Justification_Type := Not_Justified;
        x_Min_Zoom    : Long_Float         := Long_Float'small;
        x_Max_Zoom    : Long_Float         := Long_Float'large;
        y_Min_Zoom    : Long_Float         := Long_Float'small;
        y_Max_Zoom    : Long_Float         := Long_Float'large) is
    
        X_Label_String_Array     : Label_String_Array_Type := Default_Label_String_Array;
        Y_Label_String_Array     : Label_String_Array_Type := Default_Label_String_Array;
        Title_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array;
        Color_Array              : Color_Array_Type        := Default_Color_Array;
        Line_Width_Array         : Line_Width_Array_Type   := Default_Line_Width_Array;
        Line_Style_Array         : Line_Style_Array_Type   := Default_Line_Style_Array;

    begin
        X_Label_String_Array(1)     := TUB(X_Label);     -- First slot only; others not used.
        Y_Label_String_Array(1)     := TUB(Y_Label);     -- First slot only; others not used.
        Title_Label_String_Array(1) := TUB(Title_Label); -- First slot only; others not used.
        Color_Array(1)              := Color;
        Line_Width_Array(1)         := Line_Width;  -- First slot only; others not used.
        Line_Style_Array(1)         := Line_Style;  -- First slot only; others not used.

        -- Process arrays if log plot is indicated.
        -- The declare blocks save memory and time for non-log plots.

        -- Log x.
        if Axis_Style in Log_X_Box_Plus..Log_X_Minor_Grid then
            declare
                x_Log : Real_Vector(x'range);
            begin
                for i in x_Log'range loop
                    x_Log(i) := Log(x(i), 10.0);
                end loop;

                Multiplot_Pairs(
                    x_Log, y, 
                    X_Labels      => X_Label_String_Array,
                    Y_Labels      => Y_Label_String_Array,
                    Title_Labels  => Title_Label_String_Array,
                    Axis_Style    => Axis_Style, 
                    Colors        => Color_Array, 
                    Line_Widths   => Line_Width_Array, 
                    Line_Styles   => Line_Style_Array, 
                    Justification => Justification, 
                    x_Min_Zoom    => x_Min_Zoom, 
                    x_Max_Zoom    => x_Max_Zoom, 
                    y_Min_Zoom    => y_Min_Zoom, 
                    y_Max_Zoom    => y_Max_Zoom);
            end; -- declare
        end if; -- log x

        -- Log y
        if Axis_Style in Log_Y_Box_Plus..Log_Y_Minor_Grid then
            declare
                y_Log : Real_Vector(y'range);
            begin
                for i in y_Log'range loop
                    y_Log(i) := Log(y(i), 10.0);
                end loop;
                Multiplot_Pairs(
                    x, y_Log, 
                    X_Labels      => X_Label_String_Array,
                    Y_Labels      => Y_Label_String_Array,
                    Title_Labels  => Title_Label_String_Array,
                    Axis_Style    => Axis_Style, 
                    Colors        => Color_Array, 
                    Line_Widths   => Line_Width_Array, 
                    Line_Styles   => Line_Style_Array, 
                    Justification => Justification, 
                    x_Min_Zoom    => x_Min_Zoom, 
                    x_Max_Zoom    => x_Max_Zoom, 
                    y_Min_Zoom    => y_Min_Zoom, 
                    y_Max_Zoom    => y_Max_Zoom);
            end; -- declare
        end if; -- log y

        -- Log x and log y
        if Axis_Style in Log_XY_Box_Plus..Log_XY_Minor_Grid then
            declare
                x_Log : Real_Vector(x'range);
                y_Log : Real_Vector(y'range);
            begin
                for i in x_Log'range loop
                    x_Log(i) := Log(x(i), 10.0);
                    y_Log(i) := Log(y(i), 10.0);
                end loop;
                Multiplot_Pairs(
                    x_Log, y_Log, 
                    X_Labels      => X_Label_String_Array,
                    Y_Labels      => Y_Label_String_Array,
                    Title_Labels  => Title_Label_String_Array,
                    Axis_Style    => Axis_Style, 
                    Colors        => Color_Array, 
                    Line_Widths   => Line_Width_Array, 
                    Line_Styles   => Line_Style_Array, 
                    Justification => Justification, 
                    x_Min_Zoom    => x_Min_Zoom, 
                    x_Max_Zoom    => x_Max_Zoom, 
                    y_Min_Zoom    => y_Min_Zoom, 
                    y_Max_Zoom    => y_Max_Zoom);
            end; -- declare
        end if; -- log x and log y

        -- Linear plot is indicated.
        if Axis_Style in No_Box..Linear_Minor_Grid then
            Multiplot_Pairs(
                x, y, 
                X_Labels      => X_Label_String_Array,
                Y_Labels      => Y_Label_String_Array,
                Title_Labels  => Title_Label_String_Array,
                Axis_Style    => Axis_Style, 
                Colors        => Color_Array, 
                Line_Widths   => Line_Width_Array, 
                Line_Styles   => Line_Style_Array, 
                Justification => Justification, 
                x_Min_Zoom    => x_Min_Zoom, 
                x_Max_Zoom    => x_Max_Zoom, 
                y_Min_Zoom    => y_Min_Zoom, 
                y_Max_Zoom    => y_Max_Zoom);
        end if; -- Linear plot
    end Single_Plot;


--------- Simple Contour Plotter ------

    procedure Simple_Contour
       (z             : Real_Matrix;
        Number_Levels : Integer := 10;
        X_Label       : String  := To_String(Default_Label_String);
        Y_Label       : String  := To_String(Default_Label_String);
        Title_Label   : String  := To_String(Default_Label_String)) is
       
        Contour_Levels : Real_Vector (0 .. Number_Levels);

    begin
        -- Fill the contour vector with some levels.
        Calculate_Contour_Levels(Contour_Levels, Matrix_Min(z), Matrix_Max(z));
        
        pladv(Next_Subpage);
        plvpor(0.1, 0.9, 0.1, 0.9);
        plwind(1.0, 35.0, 1.0, 46.0); -- fix
        plcol0(White);
        PLplot_Traditional.plbox("bcnst", 0.0, 0, "bcnstv", 0.0, 0); -- I have no idea why the compiler requires PLplot_Traditional. here.
        plcol0(White);
        pllab(X_Label, Y_Label, Title_Label);
        plcol0(White);
        pl_setcontlabelparam(0.008, 0.6, 0.1, True);
        plcont(z, z'First(1), z'Last(1), z'First(2), z'Last(2), 
            Contour_Levels, PLplot_Thin.pltr0'access, System.Null_Address);          
    end Simple_Contour;


--------- Simple 3D Mesh Plotter ------

    procedure Simple_Mesh_3D
       (x, y     : Real_Vector; -- data definition points 
        z        : Real_Matrix; -- z(x, y) = z(x(i), y(j))
        x_Min    : Long_Float := 0.0;  -- user coordinate limits
        x_Max    : Long_Float := 0.0;  -- If x_Min = x_Max = 0.0 then plot
        y_Min    : Long_Float := 0.0;  -- x-limits are found automatically.
        y_Max    : Long_Float := 0.0;  -- Ditto y_Min and y_Max.
        Altitude : Long_Float := 30.0; -- viewing elevation angle in degrees
        Azimuth  : Long_Float := 30.0; -- viewing azimuth in degrees
        X_Label  : String := "x";
        Y_Label  : String := "y";
        Z_Label  : String := "z") is

        x_Min_Local, x_Max_Local, y_Min_Local, y_Max_Local : Long_Float;
        
    begin
        -- Check for compatible lengths in x, y, and z.
        if x'length /= z'length(1) then
            Put_Line("*** WARNING: Mismatached x-lengths in Simple_Mesh_3D");
        end if;
        if y'length /= z'length(2) then
            Put_Line("*** WARNING: Mismatached y-lengths in Simple_Mesh_3D");
        end if;
        
        -- Set min and max for x and y if they are not the defaults.
        if x_Min = 0.0 and x_Max = 0.0 then -- override
            x_Min_Local := Vector_Min(x);
            x_Max_Local := Vector_Max(x);
        else
            x_Min_Local := x_Min;
            x_Max_Local := x_Max;
        end if;
        
        if y_Min = 0.0 and y_Max = 0.0 then -- override
            y_Min_Local := Vector_Min(y);
            y_Max_Local := Vector_Max(y);
        else
            y_Min_Local := y_Min;
            y_Max_Local := y_Max;
        end if;
        
        Quick_Set_Color_Map_1(Blue_Green_Red); -- no way to restore after doing this
        pladv(Next_Subpage);
        plcol0(White);
        plvpor(0.0, 1.0, 0.0, 1.0);
        plwind(-0.9, 0.9, -0.8, 1.5);
        plw3d(1.0, 1.0, 1.0, x_Min_Local, x_Max_Local, y_Min_Local, y_Max_Local, 
            Matrix_Min(z), Matrix_Max(z), Altitude, Azimuth); -- plw3d
        plbox3("bnstu", X_Label, 0.0, 0, 
            "bnstu", Y_Label, 0.0, 0, 
            "bcdmnstuv", Z_Label, 0.0, 0); -- plbox3
        plmesh(x, y, z, Lines_Parallel_To_X_And_Y + Magnitude_Color); -- plmesh
    end Simple_Mesh_3D;


--------- Simple 3D Surface Plotter ------

    procedure Simple_Surface_3D
       (x, y     : Real_Vector; -- data definition points 
        z        : Real_Matrix; -- z(x, y) = z(x(i), y(j))
        x_Min    : Long_Float := 0.0;  -- user coordinate limits;
        x_Max    : Long_Float := 0.0;  -- If x_Min = x_Max = 0.0 then plot
        y_Min    : Long_Float := 0.0;  -- x-limits are found automatically.
        y_Max    : Long_Float := 0.0;  -- Ditto y_Min and y_Max.
        Altitude : Long_Float := 30.0; -- viewing elevation angle in degrees
        Azimuth  : Long_Float := 30.0; -- viewing azimuth in degrees
        X_Label  : String := "x";
        Y_Label  : String := "y";
        Z_Label  : String := "z") is

        x_Min_Local, x_Max_Local, y_Min_Local, y_Max_Local : Long_Float;
        Contour_Levels_Dummy : Real_Vector(0..1) := (others => 0.0);
        
    begin
        -- Check for compatible lengths in x, y, and z.
        if x'length /= z'length(1) then
            Put_Line("*** WARNING: Mismatached x-lengths in Simple_Mesh_3D");
        end if;
        if y'length /= z'length(2) then
            Put_Line("*** WARNING: Mismatached y-lengths in Simple_Mesh_3D");
        end if;
        
        -- Set min and max for x and y if they are not the defaults.
        if x_Min = 0.0 and x_Max = 0.0 then -- override
            x_Min_Local := Vector_Min(x);
            x_Max_Local := Vector_Max(x);
        else
            x_Min_Local := x_Min;
            x_Max_Local := x_Max;
        end if;
        
        if y_Min = 0.0 and y_Max = 0.0 then -- override
            y_Min_Local := Vector_Min(y);
            y_Max_Local := Vector_Max(y);
        else
            y_Min_Local := y_Min;
            y_Max_Local := y_Max;
        end if;
        
        Quick_Set_Color_Map_1(Blue_Green_Red); -- no way to restore after doing this
        pladv(Next_Subpage);
        plcol0(White);
        plvpor(0.0, 1.0, 0.0, 1.0);
        plwind(-0.9, 0.9, -0.8, 1.5);
        plw3d(1.0, 1.0, 1.0, x_Min_Local, x_Max_Local, y_Min_Local, y_Max_Local, 
            Matrix_Min(z), Matrix_Max(z), Altitude, Azimuth); -- plw3d
        plbox3("bnstu", X_Label, 0.0, 0, 
            "bnstu", Y_Label, 0.0, 0, 
            "bcdmnstuv", Z_Label, 0.0, 0); -- plbox3
        plmesh(x, y, z, Lines_Parallel_To_X_And_Y + Magnitude_Color); -- plmesh
        plsurf3d(x, y, z, Magnitude_Color, Contour_Levels_Dummy);
    end Simple_Surface_3D;
        


--------- Simple color table manipulatons -----

    -- Things for manipulating color map 0 --

    -- Make a snapshot of color map 0 for possible later full or partial restoration.
    -- This is automatically called at package initialization with results stored
    -- in Default_Red_Components, Default_Green_Components, Default_Blue_Components.
    procedure Make_Snapshot_Of_Color_Map_0 
       (Reds, Greens, Blues : out Integer_Array_1D) is
    begin
        for i in Reds'range loop
            plgcol0(i, Reds(i), Greens(i), Blues(i));
        end loop;
    end Make_Snapshot_Of_Color_Map_0;
    
    
    -- Restore an arbitray snapshot of color map 0.
    procedure Restore_Snapshot_Of_Color_Map_0
       (Reds, Greens, Blues : Integer_Array_1D) is
    begin
        plscmap0(Reds, Greens, Blues);
    end Restore_Snapshot_Of_Color_Map_0;
    
    
    -- Restore the default colors of color map 0 taken as a snapshot at initialization.
    procedure Restore_Default_Snapshot_Of_Color_Map_0 is
    begin
        plscmap0n(Number_Of_Default_Colors);
        plscmap0(Default_Red_Components, Default_Green_Components, Default_Blue_Components);
    end Restore_Default_Snapshot_Of_Color_Map_0;
    
    
    -- Functions which correspond to the default colors of color map 0. Calling
    -- one of these (1) resets the corresponding slot in color map 0 to its 
    -- default value, and (2) returns the correct integer value for the default 
    -- color specified. Thus, using plcol0(Reset_Red) instead of 
    -- plcol0(Red) guarantees that the color will be set to Red even if 
    -- there have been prior manipulations of color 1.
    
    function Reset_Black return Integer is
    begin
        plscol0(0, Default_Red_Components(0), Default_Green_Components(0), Default_Blue_Components(0));
        return 0;
    end Reset_Black;
    
    function Reset_Red return Integer is
    begin
        plscol0(1, Default_Red_Components(1), Default_Green_Components(1), Default_Blue_Components(1));
        return 1;
    end Reset_Red;
    
    function Reset_Yellow return Integer is
    begin
        plscol0(2, Default_Red_Components(2), Default_Green_Components(2), Default_Blue_Components(2));
        return 2;
    end Reset_Yellow;
    
    function Reset_Green return Integer is
    begin
        plscol0(3, Default_Red_Components(3), Default_Green_Components(3), Default_Blue_Components(3));
        return 3;
    end Reset_Green;
    
    function Reset_Aquamarine return Integer is
    begin
        plscol0(4, Default_Red_Components(4), Default_Green_Components(4), Default_Blue_Components(4));
        return 4;
    end Reset_Aquamarine;
    
    function Reset_Pink return Integer is
    begin
        plscol0(5, Default_Red_Components(5), Default_Green_Components(5), Default_Blue_Components(5));
        return 5;
    end Reset_Pink;
    
    function Reset_Wheat return Integer is
    begin
        plscol0(6, Default_Red_Components(6), Default_Green_Components(6), Default_Blue_Components(6));
        return 6;
    end Reset_Wheat;
    
    function Reset_Grey return Integer is
    begin
        plscol0(7, Default_Red_Components(7), Default_Green_Components(7), Default_Blue_Components(7));
        return 7;
    end Reset_Grey;
    
    function Reset_Brown return Integer is
    begin
        plscol0(8, Default_Red_Components(8), Default_Green_Components(8), Default_Blue_Components(8));
        return 8;
    end Reset_Brown;
    
    function Reset_Blue return Integer is
    begin
        plscol0(9, Default_Red_Components(9), Default_Green_Components(9), Default_Blue_Components(9));
        return 9;
    end Reset_Blue;
    
    function Reset_BlueViolet return Integer is
    begin
        plscol0(10, Default_Red_Components(10), Default_Green_Components(10), Default_Blue_Components(10));
        return 10;
    end Reset_BlueViolet;
    
    function Reset_Cyan return Integer is
    begin
        plscol0(11, Default_Red_Components(11), Default_Green_Components(11), Default_Blue_Components(11));
        return 11;
    end Reset_Cyan;
    
    function Reset_Turquoise return Integer is
    begin
        plscol0(12, Default_Red_Components(12), Default_Green_Components(12), Default_Blue_Components(12));
        return 12;
    end Reset_Turquoise;
    
    function Reset_Magenta return Integer is
    begin
        plscol0(13, Default_Red_Components(13), Default_Green_Components(13), Default_Blue_Components(13));
        return 13;
    end Reset_Magenta;
    
    function Reset_Salmon return Integer is
    begin
        plscol0(14, Default_Red_Components(14), Default_Green_Components(14), Default_Blue_Components(14));
        return 14;
    end Reset_Salmon;
    
    function Reset_White return Integer is
    begin
        plscol0(15, Default_Red_Components(15), Default_Green_Components(15), Default_Blue_Components(15));
        return 15;
    end Reset_White;


    -- Things for manipulating color map 1 --

    -- Quick application of pre-fabricated color schemes to color map 1.
    procedure Quick_Set_Color_Map_1(Color_Theme : Color_Themes_For_Map_1_Type) is
    
        Controls_3 : Real_Vector (0..2); -- 3 control points
        Controls_4 : Real_Vector (0..3); -- 4 control points
        Red_3, Green_3, Blue_3 : Real_Vector (0..2); -- define 3
        Red_4, Green_4, Blue_4 : Real_Vector (0..3); -- define 4
        Hue_3, Lightness_3, Saturation_3 : Real_Vector (0..2); -- define 3
        Hue_4, Lightness_4, Saturation_4 : Real_Vector (0..3); -- define 4
        Alt_Hue_Path_3 : Boolean_Array_1D (0..2);
        Alt_Hue_Path_4 : Boolean_Array_1D (0..3);
    begin
        plscmap1n(256);

        Controls_3(0) := 0.0;
        Controls_3(1) := 0.5;
        Controls_3(2) := 1.0;
        
        Controls_4(0) := 0.0;
        Controls_4(1) := 0.5; -- allow a "bend" at the mid-point
        Controls_4(2) := 0.5; -- allow a "bend" at the mid-point
        Controls_4(3) := 1.0;

        -- Initialize everything, even unused stuff.
        Red_3(0)   := 0.0;
        Red_3(1)   := 0.0;
        Red_3(2)   := 0.0;
        Green_3(0) := 0.0;
        Green_3(1) := 0.0;
        Green_3(2) := 0.0;
        Blue_3(0)  := 0.0;
        Blue_3(1)  := 0.0;
        Blue_3(2)  := 0.0;

        Red_4(0)   := 0.0;
        Red_4(1)   := 0.0;
        Red_4(2)   := 0.0;
        Red_4(3)   := 0.0;
        Green_4(0) := 0.0;
        Green_4(1) := 0.0;
        Green_4(2) := 0.0;
        Green_4(3) := 0.0;
        Blue_4(0)  := 0.0;
        Blue_4(1)  := 0.0;
        Blue_4(2)  := 0.0;
        Blue_4(3)  := 0.0;

        Hue_3(0)        := 0.0;
        Hue_3(1)        := 0.0;
        Hue_3(2)        := 0.0;
        Lightness_3(0)  := 0.0;
        Lightness_3(1)  := 0.0;
        Lightness_3(2)  := 0.0;
        Saturation_3(0) := 0.0;
        Saturation_3(1) := 0.0;
        Saturation_3(2) := 0.0;

        Hue_4(0)        := 0.0;
        Hue_4(1)        := 0.0;
        Hue_4(2)        := 0.0;
        Hue_4(3)        := 0.0;
        Lightness_4(0)  := 0.0;
        Lightness_4(1)  := 0.0;
        Lightness_4(2)  := 0.0;
        Lightness_4(3)  := 0.0;
        Saturation_4(0) := 0.0;
        Saturation_4(1) := 0.0;
        Saturation_4(2) := 0.0;
        Saturation_4(3) := 0.0;

        case Color_Theme is
            when Gray =>
                begin
                    Hue_3(0) := 0.0;
                    Hue_3(1) := 0.0;
                    Hue_3(2) := 0.0;
                    Lightness_3(0) := 0.0;
                    Lightness_3(1) := 0.5;
                    Lightness_3(2) := 1.0;
                    Saturation_3(0) := 0.0;
                    Saturation_3(1) := 0.0;
                    Saturation_3(2) := 0.0;
                    Alt_Hue_Path_3(0) := False;
                    Alt_Hue_Path_3(1) := False;
                    Alt_Hue_Path_3(2) := False;
                    plscmap1l(HLS, Controls_3, Hue_3, Lightness_3, Saturation_3, Alt_Hue_Path_3);
                end;
            when Blue_Green_Red => -- This appears to be the PLplot default color theme.
                begin
                    Blue_3(0) := 1.0;
                    Blue_3(1) := 0.0;
                    Blue_3(2) := 0.0;
                    Green_3(0) := 0.0;
                    Green_3(1) := 1.0;
                    Green_3(2) := 0.0;
                    Red_3(0) := 0.0;
                    Red_3(1) := 0.0;
                    Red_3(2) := 1.0;
                    Alt_Hue_Path_3(0) := False;
                    Alt_Hue_Path_3(1) := False;
                    Alt_Hue_Path_3(2) := False;
                    plscmap1l(RGB, Controls_3, Red_3, Green_3, Blue_3, Alt_Hue_Path_3);
                end;
            when Red_Green_Blue =>
                begin
                    Blue_3(0) := 0.0;
                    Blue_3(1) := 0.0;
                    Blue_3(2) := 1.0;
                    Green_3(0) := 0.0;
                    Green_3(1) := 1.0;
                    Green_3(2) := 0.0;
                    Red_3(0) := 1.0;
                    Red_3(1) := 0.0;
                    Red_3(2) := 0.0;
                    Alt_Hue_Path_3(0) := False;
                    Alt_Hue_Path_3(1) := False;
                    Alt_Hue_Path_3(2) := False;
                    plscmap1l(RGB, Controls_3, Red_3, Green_3, Blue_3, Alt_Hue_Path_3);
                end;
            when Red_Cyan_Blue =>
                begin
                    Hue_3(0) := 360.0;
                    Hue_3(1) := 300.0;
                    Hue_3(2) := 240.0;
                    Saturation_3(0) := 1.0;
                    Saturation_3(1) := 1.0;
                    Saturation_3(2) := 1.0;
                    Lightness_3(0) := 0.5;
                    Lightness_3(1) := 0.5;
                    Lightness_3(2) := 0.5;
                    Alt_Hue_Path_3(0) := False;
                    Alt_Hue_Path_3(1) := False;
                    Alt_Hue_Path_3(2) := False;
                    plscmap1l(HLS, Controls_3, Hue_3, Lightness_3, Saturation_3, Alt_Hue_Path_3);
                end;
            when Blue_Black_Red =>
                begin
                    Hue_4(0) := 240.0; -- Blue
                    Hue_4(1) := 240.0; -- Blue
                    Hue_4(2) := 0.0;   -- Red
                    Hue_4(3) := 0.0;   -- Red
                    Saturation_4(0) := 1.0;
                    Saturation_4(1) := 1.0;
                    Saturation_4(2) := 1.0;
                    Saturation_4(3) := 1.0;
                    Lightness_4(0) := 0.5; -- Apparently different from Brightness
                    Lightness_4(1) := 0.0;
                    Lightness_4(2) := 0.0;
                    Lightness_4(3) := 0.5;
                    Alt_Hue_Path_4(0) := False;
                    Alt_Hue_Path_4(1) := False;
                    Alt_Hue_Path_4(2) := False;
                    Alt_Hue_Path_4(3) := False;
                    plscmap1l(HLS, Controls_4, Hue_4, Lightness_4, Saturation_4, Alt_Hue_Path_4);
                end;
            when Red_Blue_Green =>
                begin
                    Hue_3(0) := 360.0; -- red
                    Hue_3(1) := 210.0; -- blue
                    Hue_3(2) := 120.0;  -- green
                    Lightness_3(0) := 0.5;
                    Lightness_3(1) := 0.5;
                    Lightness_3(2) := 0.5;
                    Saturation_3(0) := 1.0;
                    Saturation_3(1) := 1.0;
                    Saturation_3(2) := 1.0;
                    Alt_Hue_Path_3(0) := False;
                    Alt_Hue_Path_3(1) := False;
                    Alt_Hue_Path_3(2) := False;
                    plscmap1l(HLS, Controls_3, Hue_3, Lightness_3, Saturation_3, Alt_Hue_Path_3);
                end;
            when Red_Yellow =>
                begin
                    Hue_3(0) := 0.0;  -- red
                    Hue_3(1) := 30.0; -- orange
                    Hue_3(2) := 60.0; -- yellow
                    Lightness_3(0) := 0.5;
                    Lightness_3(1) := 0.5;
                    Lightness_3(2) := 0.5;
                    Saturation_3(0) := 1.0;
                    Saturation_3(1) := 1.0;
                    Saturation_3(2) := 1.0;
                    Alt_Hue_Path_3(0) := False;
                    Alt_Hue_Path_3(1) := False;
                    Alt_Hue_Path_3(2) := False;
                    plscmap1l(HLS, Controls_3, Hue_3, Lightness_3, Saturation_3, Alt_Hue_Path_3);
                end;
        end case;
    end Quick_Set_Color_Map_1;

        
--------------------------------------------------------------------------------
--        Auxiliary things                                                    --
--------------------------------------------------------------------------------

    -- This is a mask function for Shade_Regions (aka plshades) et al that always
    -- returns 1 so that all points are plotted. Can be used as a template 
    -- for other user-written mask functions. This behaves the same as 
    -- when passing null for the second argument in Shade_Regions.
    function Mask_Function_No_Mask(x, y : Long_Float) return Integer is
    begin
        return 1;
    end Mask_Function_No_Mask;


    -- Given an array to hold contour levels and function minimum and maximum,
    -- fill it and return. Useful for contour and shade plots.
    procedure Calculate_Contour_Levels
       (Contour_Levels : in out Real_Vector;
        z_Min, z_Max : Long_Float) is
        
        step : Long_Float;
        ii : Integer;
    begin
        step := (z_Max - z_Min) / Long_Float(Contour_Levels'Last - Contour_Levels'First);
        for i in Contour_Levels'range loop
            ii := i - Contour_Levels'First; -- reference back to 0.
            Contour_Levels(i) := z_Min + step * Long_Float(ii);
        end loop;
    end Calculate_Contour_Levels;


--------------------------------------------------------------------------------
--        Re-define PLplot procedures using Ada style.                        --
--------------------------------------------------------------------------------

-- These correspond to the section in plot.h called "Function Prototypes".

    -- set the format of the contour labels
    procedure pl_setcontlabelformat
       (Limit_Exponent     : Integer := 4;
        Significant_Digits : Integer := 2) is
    begin
        PLplot_Thin.pl_setcontlabelformat(Limit_Exponent, Significant_Digits);
    end pl_setcontlabelformat;


    -- set offset and spacing of contour labels
    procedure pl_setcontlabelparam
       (Label_Offset       : Long_Float := 0.006; -- Units are ???
        Label_Font_Height  : Long_Float := 0.3;   -- Units are ???
        Label_Spacing      : Long_Float := 0.1;   -- Units are???
        Labels_Active      : Boolean := False) is
    
        active : Integer;
    
    begin
        if Labels_Active then
            active := 1;
        else
            active := 0;
        end if;
        PLplot_Thin.pl_setcontlabelparam(Label_Offset, Label_Font_Height, Label_Spacing, active);
    end pl_setcontlabelparam;


    -- Advance to subpage "page", or to the next one if "page" = 0.
    procedure pladv(Page : Natural) is
    begin
        PLplot_Thin.pladv(Page);
    end pladv;


    -- Plot an arc.
    procedure plarc
       (x, y, a, b, angle1, angle2, rotate : Long_Float;
        fill : Boolean) is

        fill_arc : PLBOOL;

    begin
        if fill then
            fill_arc := PLtrue;
        else
            fill_arc := PLfalse;
        end if;
        PLplot_Thin.plarc(x, y, a, b, angle1, angle2, rotate, fill_arc);
    end plarc;


    -- Draw a 2D vector plot.
    procedure plvect
       (u, v                             : Real_Matrix;
        Scale                            : Long_Float;
        Transformation_Procedure_Pointer : Transformation_Procedure_Pointer_Type;
        Transformation_Data_Pointer      : PLpointer) is
    begin
        PLplot_Thin.plvect(Matrix_To_Pointers(u), Matrix_To_Pointers(v), u'Length(1), u'Length(2), 
            Scale, Transformation_Procedure_Pointer, Transformation_Data_Pointer);
    end plvect;
       

    -- Set the style for the arrow used by plvect to plot vectors.
    procedure plsvect
       (X_Vertices, Y_Vertices : Real_Vector; -- Should be range -0.5..0.5
        Fill_Arrow             : Boolean) is
        
        fill : PLBOOL;
        
    begin
        if Fill_Arrow then
            fill := PLtrue;
        else
            fill := PLfalse;
        end if;
        PLplot_Thin.plsvect(X_Vertices, Y_Vertices, X_Vertices'length, fill);
    end plsvect;

    
    -- Set the default style for the arrow used by plvect to plot vectors.
    procedure plsvect
       (X_Vertices, Y_Vertices : PLPointer;
        Fill_Arrow : Boolean) is
        
        fill : PLBOOL;
        
    begin
        if Fill_Arrow then
            fill := PLtrue;
        else
            fill := PLfalse;
        end if;
        PLplot_Thin.plsvectdefault(X_Vertices, Y_Vertices, 0, fill);
    end plsvect;

    
    -- Simple method to set the default style for the arrow used by plvect to plot vectors.
    -- This is not part of the C API and is Ada-specific.
    procedure plsvect is
    begin
        PLplot_Thin.plsvectdefault(System.Null_Address, System.Null_Address, 0, PLfalse);
    end plsvect;
    
 
    -- Another simple method to set the default style for the arrow used by plvect to plot vectors.
    -- This is not part of the C API and is Ada-specific.
    procedure Reset_Vector_Arrow_Style is
    begin
        PLplot_Thin.plsvectdefault(System.Null_Address, System.Null_Address, 0, PLfalse);
    end Reset_Vector_Arrow_Style;
        
        
    -- This functions similarly to plbox() except that the origin of the axes
    -- is placed at the user-specified point (x0, y0).
    procedure plaxes
       (X_Origin, Y_Origin       : Long_Float;
        X_Option_String          : String;
        X_Major_Tick_Interval    : Long_Float;
        X_Number_Of_Subintervals : Natural;
        Y_Option_String          : String;
        Y_Major_Tick_Interval    : Long_Float;
        Y_Number_Of_Subintervals : Natural) is
    begin
        PLplot_Thin.plaxes
           (X_Origin, Y_Origin,
            To_C(X_Option_String, True), X_Major_Tick_Interval, X_Number_Of_Subintervals,
            To_C(Y_Option_String, True), Y_Major_Tick_Interval, Y_Number_Of_Subintervals);
    end plaxes;


    -- Plot a histogram using x to store data values and y to store frequencies
    procedure plbin
       (Bin_Values     : Real_Vector; -- "x"
        Bin_Counts     : Real_Vector; -- "y"
        Options        : Integer) is -- Options are not defined in plplot.h.
    begin
        PLplot_Thin.plbin(Bin_Values'length, Bin_Values, Bin_Counts, Options);
    end plbin;


    -- Calculate broken-down time from continuous time for current stream.
    procedure plbtime
       (year, month, day, hour, min : out Integer;
        sec                         : out Long_Float;
        ctime                       : Long_Float) is
    begin
        PLplot_Thin.plbtime(year, month, day, hour, min, sec, ctime);
    end plbtime;
        

    -- Start new page. Should only be used with pleop().
    procedure plbop is
    begin
        PLplot_Thin.plbop;
    end plbop;


    -- This draws a box around the current viewport.
    procedure plbox
       (X_Option_String          : String;
        X_Major_Tick_Interval    : Long_Float;
        X_Number_Of_Subintervals : Natural := 0;
        Y_Option_String          : String;
        Y_Major_Tick_Interval    : Long_Float;
        Y_Number_Of_Subintervals : Natural := 0) is
    begin
        PLplot_Thin.plbox
           (To_C(X_Option_String, True), X_Major_Tick_Interval, X_Number_Of_Subintervals,
            To_C(Y_Option_String, True), Y_Major_Tick_Interval, Y_Number_Of_Subintervals);
    end plbox;


    -- This is the 3-d analogue of plbox().
    procedure plbox3
       (X_Option_String          : String;
        X_Label                  : String := To_String(Default_Label_String);
        X_Major_Tick_Interval    : Long_Float := 0.0;
        X_Number_Of_Subintervals : Natural := 0;

        Y_Option_String          : String;
        Y_Label                  : String := To_String(Default_Label_String);
        Y_Major_Tick_Interval    : Long_Float := 0.0;
        Y_Number_Of_Subintervals : Natural := 0;

        Z_Option_String          : String;
        Z_Label                  : String := To_String(Default_Label_String);
        Z_Major_Tick_Interval    : Long_Float := 0.0;
        Z_Number_Of_Subintervals : Natural := 0) is
    begin
        PLplot_Thin.plbox3
           (To_C(X_Option_String, True), To_C(X_Label, True), X_Major_Tick_Interval, X_Number_Of_Subintervals,
            To_C(Y_Option_String, True), To_C(Y_Label, True), Y_Major_Tick_Interval, Y_Number_Of_Subintervals,
            To_C(Z_Option_String, True), To_C(Z_Label, True), Z_Major_Tick_Interval, Z_Number_Of_Subintervals);
    end plbox3;
        

    -- Calculate world coordinates and subpage from relative device coordinates.
    procedure plcalc_world
       (x_Relative, y_Relative : Long_Float_0_1_Type;
        x_World,    y_World    : out Long_Float;
        Last_Window_Index      : out Integer) is
    begin
        PLplot_Thin.plcalc_world(x_Relative, y_Relative, x_World, y_World, Last_Window_Index);
    end plcalc_world;


    -- Clear current subpage.
    procedure plclear is
    begin
        PLplot_Thin.plclear;
    end plclear;


    -- Set color, map 0. Argument is integer between 0 and 15.
    procedure plcol0(A_Color : Plot_Color_Type) is
    begin
        PLplot_Thin.plcol0(A_Color);
    end plcol0;


    -- Set color, map 1. Argument is a float between 0. and 1.
    procedure plcol1(Color : Long_Float_0_1_Type) is
    begin
        PLplot_Thin.plcol1(Color);
    end plcol1;


    -- Configure transformation between continuous and broken-down time (and
    -- vice versa) for current stream.
    procedure plconfigtime
       (skale, offset1, offset2      : Long_Float;
        ccontrol                     : Integer;
        ifbtime_offset               : Boolean;
        year, month, day, hour, min : Integer;
        sec                          : Long_Float) is
        
        ifbtime_offset_As_Integer : Integer;
    begin
        if ifbtime_offset then
            ifbtime_offset_As_Integer := 1;
        else
            ifbtime_offset_As_Integer := 0;
        end if;
        PLplot_Thin.plconfigtime(skale, offset1, offset2, ccontrol,
            ifbtime_offset_As_Integer, year, month, day, hour, min, sec);
    end plconfigtime;


    -- Draws a contour plot from data in f(nx,ny). Is just a front-end to
    -- plfcont, with a particular choice for f2eval and f2eval_data.

    -- (Universal version using System.Address to the transformation data)
    procedure plcont
       (z                                : Real_Matrix;
        x_Min_Index, x_Max_Index         : Integer;
        y_Min_Index, y_Max_Index         : Integer;
        Contour_Levels                   : Real_Vector;
        Transformation_Procedure_Pointer : Transformation_Procedure_Pointer_Type;
        Transformation_Data_Pointer      : PLpointer) is
    begin
        PLplot_Thin.plcont(Matrix_To_Pointers(z), z'Length(1), z'Length(2), 
            x_Min_Index, x_Max_Index, y_Min_Index, y_Max_Index, Contour_Levels, 
            Contour_Levels'Length, Transformation_Procedure_Pointer, 
            Transformation_Data_Pointer);
    end plcont;


    -- The procedure plfcont is not documented and is not part of the API. 
    -- However, it is a very useful capability to have available.
    -- I have tried to implement it as I think was intended but this may be incorrect.
    -- It appears as though the intent is to pass the arbitrarily organized 
    -- data (pointed to by Irregular_Data_Pointer) as a (single) pointer to a 
    -- 2D C-style array. Thus, for examaple, it is not possible to pass the data  
    -- as triples.
    -- For further conversion insight, see plcont, above.
    
    -- Draws a contour plot using the function evaluator f2eval and data stored
    -- by way of the f2eval_data pointer. This allows arbitrary organizations
    -- of 2d array data to be used.

    procedure plfcont
       (Function_Evaluator_Pointer       : Function_Evaluator_Pointer_Type;
        Irregular_Data                   : Real_Matrix;
        x_Min_Index, x_Max_Index         : Integer;
        y_Min_Index, y_Max_Index         : Integer;
        Contour_Levels                   : Real_Vector;
        Transformation_Procedure_Pointer : Transformation_Procedure_Pointer_Type;
        Transformation_Data              : Transformation_Data_Type) is

        -- This is a good place to change from the convenient form of passing 
        -- the transformation data (a record) to the form required by the PLplot 
        -- API (a pointer); same for the irregularly spaced data matrix.
        Transformation_Data_Address : PLpointer;
        Irregular_Data_Address      : PLpointer;
    begin
        Transformation_Data_Address := Transformation_Data'Address;
        Irregular_Data_Address      := Irregular_Data'Address;

        PLplot_Thin.plfcont(Function_Evaluator_Pointer, Irregular_Data_Address, 
            Irregular_Data'Length(1), Irregular_Data'Length(2), 
            x_Min_Index, x_Max_Index, y_Min_Index, y_Max_Index, 
            Contour_Levels, Contour_Levels'Length, 
            Transformation_Procedure_Pointer, Transformation_Data_Address);
    end plfcont;


    -- Copies state parameters from the reference stream to the current stream.
    procedure plcpstrm
       (Stream_ID                      : Integer;
        Do_Not_Copy_Device_Coordinates : Boolean) is
    
        PL_Do_Not_Copy_Device_Coordinates : PLBOOL;
        
    begin
        if Do_Not_Copy_Device_Coordinates then
            PL_Do_Not_Copy_Device_Coordinates := PLtrue;
        else
            PL_Do_Not_Copy_Device_Coordinates := PLfalse;
        end if;
        PLplot_Thin.plcpstrm(Stream_ID, PL_Do_Not_Copy_Device_Coordinates);
    end plcpstrm;


    -- Calculate continuous time from broken-down time for current stream.
    procedure plctime
       (year, month, day, hour, min : Integer;
        sec                         : Long_Float;
        ctime                       : out Long_Float) is
    begin
        PLplot_Thin.plctime(year, month, day, hour, min, sec, ctime);
    end plctime;


    -- fix this
    -- Converts input values from relative device coordinates to relative plot
    -- coordinates.
    procedure pldid2pc is
    begin
        Put_Line("Not implemented due to lack of documentation.");
    end pldid2pc;


    -- fix this
    -- Converts input values from relative plot coordinates to relative
    -- device coordinates.
    procedure pldip2dc is
    begin
        Put_Line("Not implemented due to lack of documentation.");
    end pldip2dc;


    -- End a plotting session for all open streams.
    procedure plend is
    begin
        PLplot_Thin.plend;
    end plend;


    -- End a plotting session for the current stream only.
    procedure plend1 is
    begin
        PLplot_Thin.plend1;
    end plend1;


    -- Simple interface for defining viewport and window.
    procedure plenv
       (x_Min, x_Max, y_Min, y_Max : Long_Float;
        Justification              : Justification_Type;
        Axis_Style                 : Axis_Style_Type) is
    begin
        PLplot_Thin.plenv(x_Min, x_Max, y_Min, y_Max, Justification, Axis_Style);
    end plenv;


    -- similar to plenv() above, but in multiplot mode does not advance the subpage,
    -- instead the current subpage is cleared
    procedure plenv0
       (x_Min, x_Max, y_Min, y_Max : Long_Float;
        Justification              : Justification_Type;
        Axis_Style                 : Axis_Style_Type) is
    begin
        PLplot_Thin.plenv0(x_Min, x_Max, y_Min, y_Max, Justification, Axis_Style);
    end plenv0;


    -- End current page. Should only be used with plbop().
    procedure pleop is
    begin
        PLplot_Thin.pleop;
    end pleop;


    -- Plot horizontal error bars (xmin(i),y(i)) to (xmax(i),y(i))
    procedure plerrx(x_Min, x_Max, y : Real_Vector) is
    begin
        PLplot_Thin.plerrx(x_Min'Length, x_Min, x_Max, y);
    end plerrx;


    -- Plot vertical error bars (x,ymin(i)) to (x(i),ymax(i))
    procedure plerry(x, y_Min, y_Max : Real_Vector) is
    begin
        PLplot_Thin.plerry(y_Min'Length, x, y_Min, y_Max);
    end plerry;


    -- Advance to the next family file on the next new page
    procedure plfamadv is
    begin
        PLplot_Thin.plfamadv;
    end plfamadv;

    -- Other "fill" routines similar to plfill could be written in Ada if 
    -- desired, but if they are intended to be used as callbacks in subprograms 
    -- such as plshade, plshade1, and plshades, they should be called with C 
    -- calling conventions.
    
    -- Pattern fills the polygon bounded by the input points.
    procedure plfill(x, y : Real_Vector) is -- might have to put n:Integer first
    begin
        PLplot_Thin.plfill(x'Length, x, y);
    end plfill;


    -- Pattern fills the 3d polygon bounded by the input points.
    procedure plfill3 (x, y, z : Real_Vector) is
    begin
        PLplot_Thin.plfill3(x'Length, x, y, z);
    end plfill3;


    -- Flushes the output stream. Use sparingly, if at all.
    procedure plflush is
    begin
        PLplot_Thin.plflush;
    end plflush;


    -- Sets the global font flag to 'ifont'.
    procedure plfont(Font_Style : Font_Style_Type) is
    begin
        PLplot_Thin.plfont(Font_Style);
    end plfont;


    -- Load specified font set.
    procedure plfontld(Character_Set : Character_Set_Type) is
    begin
        PLplot_Thin.plfontld(Character_Set);
    end plfontld;


    -- Get character default height and current (scaled) height
    procedure plgchr(Default_Height, Current_Height : out Long_Float) is
    begin
        PLplot_Thin.plgchr(Default_Height, Current_Height);
    end plgchr;


    -- Returns 8 bit RGB values for given color from color map 0
    procedure plgcol0
       (Color_Index      : Integer;
        Red_Component, Green_Component, Blue_Component : out Integer) is
    begin
        PLplot_Thin.plgcol0(Color_Index, Red_Component, Green_Component, Blue_Component);
    end plgcol0;


    -- Returns 8 bit RGB values for given color from color map 0 and alpha value
    procedure plgcol0a
       (Color_Index                                    : Integer;
        Red_Component, Green_Component, Blue_Component : out Integer;
        Alpha                                          : out Long_Float_0_1_Type) is
    begin
        PLplot_Thin.plgcol0a(Color_Index, Red_Component, Green_Component, Blue_Component, Alpha);
    end plgcol0a;

    -- Returns the background color by 8 bit RGB value
    procedure plgcolbg
       (Red_Component, Green_Component, Blue_Component : out Integer) is
    begin
        PLplot_Thin.plgcolbg(Red_Component, Green_Component, Blue_Component);
    end plgcolbg;


    -- Returns the background color by 8 bit RGB value and alpha value
    procedure plgcolbga
       (Red_Component, Green_Component, Blue_Component : out Integer;
        Alpha                                          : out Long_Float_0_1_Type) is
    begin
        PLplot_Thin.plgcolbga(Red_Component, Green_Component, Blue_Component,
            Alpha);
    end;


    -- Returns the current compression setting
    procedure plgcompression(Compression_Level : out Integer) is
    begin
        PLplot_Thin.plgcompression(Compression_Level);
    end plgcompression;


    -- Make a function version of plgdev so that the caller can use it whereever
    -- a String type is expected without fooling around with conversions between
    -- Ada string types. See Example 14 for useage.
    -- This _replaces_ the procedure version.
    -- THIS IS NOT IN THE C API.

    -- Get the current device (keyword) name
    function plgdev return String is
        PL_Device_Name : char_array(0..79);
    begin
        PLplot_Thin.plgdev(PL_Device_Name);
        return To_Ada(PL_Device_Name, True);
    end plgdev;


    -- Retrieve current window into device space
    procedure plgdidev
       (Relative_Margin_Width : out Long_Float;
        Aspect_Ratio          : out Long_Float;
        x_Justification       : out Long_Float;
        y_Justification       : out Long_Float) is
    begin
        PLplot_Thin.plgdidev(Relative_Margin_Width, Aspect_Ratio, x_Justification, y_Justification);
    end plgdidev;


    -- Get plot orientation
    procedure plgdiori(Rotation : out Long_Float) is
    begin
        PLplot_Thin.plgdiori(Rotation);
    end plgdiori;


    -- Retrieve current window into plot space
    procedure plgdiplt
       (x_Min : out Long_Float;
        y_Min : out Long_Float;
        x_Max : out Long_Float;
        y_Max : out Long_Float) is
    begin
        PLplot_Thin.plgdiplt(x_Min, y_Min, x_Max, y_Max);
    end plgdiplt;


    -- Get FCI (font characterization integer)
    procedure plgfci(Font_Characterization_Integer : out Unicode) is
    begin
        PLplot_Thin.plgfci(Font_Characterization_Integer);
    end plgfci;


    -- Get family, style and weight of the current font
    procedure plgfont(Family, Style, Weight : out Integer) is
    begin
        PLplot_Thin.plgfont(Family, Style, Weight);
    end;


    -- Get family file parameters
    procedure plgfam
       (Family_Enabled : out Boolean;
        Family_File_Number : out Integer;
        Maximum_File_Size : out Integer) is
        
        PL_Family_Enabled : PLBOOL;
        
    begin
        PLplot_Thin.plgfam(PL_Family_Enabled, Family_File_Number, Maximum_File_Size);
        if PL_Family_Enabled = 0 then
            Family_Enabled := False;
        else
            Family_Enabled := True;
        end if;
    end plgfam;


    -- Make a function version of plgfnam so that the caller can use it whereever
    -- a String type is expected without fooling around with conversions between
    -- Ada string types. See Example 14 for useage.
    -- This _replaces_ the procedure version.
    -- THIS IS NOT IN THE C API.

    -- Get the (current) output file name.
    function plgfnam return String is
        PL_Output_File_Name : char_array(0..79);
    begin
        PLplot_Thin.plgfnam(PL_Output_File_Name);
        return To_Ada(PL_Output_File_Name, True);
    end plgfnam;


    -- Get the (current) run level.
    procedure plglevel(Run_Level : out Integer) is
    begin
        PLplot_Thin.plglevel(Run_Level);
    end plglevel;


    -- Get output device parameters.
    procedure plgpage
       (x_Pixels, y_Pixels           : out Long_Float;
        x_Page_Length, y_Page_Length : out Integer;
        x_Page_Offset, y_Page_Offset : out Integer) is
    begin
        PLplot_Thin.plgpage(x_Pixels, y_Pixels, x_Page_Length, y_Page_Length, x_Page_Offset, y_Page_Offset);
    end plgpage;


    -- Switches to graphics screen.
    procedure plgra is
    begin
        PLplot_Thin.plgra;
    end plgra;


    -- Draw gradient in polygon.
    procedure plgradient(x, y : Real_Vector; Angle : Long_Float) is
    begin
        plgradient(x'Length, x, y, Angle);
    end plgradient;


    -- Grid irregularly sampled data.
    procedure plgriddata
       (x, y, z                : Real_Vector; -- ungridded x- and y-points; z is height
        x_Grid, y_Grid         : Real_Vector;
        z_Gridded              : in out Real_Matrix;
        Gridding_Algorithm     : Gridding_Algorithm_Type;
        Griding_Algorithm_Data : Long_Float) is
    begin
        -- Note that since z_Gridded is converted to and passed as an array of 
        -- pointers, this is effectively the same as pass-by-reference so 
        -- "in out" is not required for the formal argument zg in plgriddata.
        PLplot_Thin.plgriddata(x, y, z, x'Length, x_Grid, x_Grid'Length, y_Grid, y_Grid'Length, 
            Matrix_To_Pointers(z_Gridded), Gridding_Algorithm, Griding_Algorithm_Data);            
    end plgriddata;


    -- Get subpage boundaries in absolute coordinates
    -- Results are millimeters from the lower left corner.
    procedure plgspa
       (Left_Edge, Right_Edge, Bottom_Edge, Top_Edge : out Long_Float) is
    begin
        PLplot_Thin.plgspa(Left_Edge, Right_Edge, Bottom_Edge, Top_Edge);
    end plgspa;


    -- Get current stream number.
    procedure plgstrm(Stream_Number : out Integer) is
    begin
        PLplot_Thin.plgstrm(Stream_Number);
    end plgstrm;


    -- Make a function version of plgver so that the caller can use it whereever
    -- a String type is expected without fooling around with conversions between
    -- Ada string types. See Example 14 for useage.
    -- This _replaces_ the procedure version.
    -- THIS IS NOT IN THE C API.

    -- Get the current library version number
    function plgver return String is
        PL_Version_Number : char_array(0..79);
    begin
        PLplot_Thin.plgver(PL_Version_Number);
        return To_Ada(PL_Version_Number, True);
    end plgver;


    -- Get viewport boundaries in normalized device coordinates
    procedure plgvpd(x_Min, x_Max, y_Min, y_Max : out Long_Float) is
    begin
        PLplot_Thin.plgvpd(x_Min, x_Max, y_Min, y_Max);
    end plgvpd;


    -- Get viewport boundaries in world coordinates
    procedure plgvpw(x_Min, x_Max, y_Min, y_Max : out Long_Float) is
    begin
        PLplot_Thin.plgvpw(x_Min, x_Max, y_Min, y_Max);
    end plgvpw;


    -- Get x axis labeling parameters
    procedure plgxax(Max_Digits, Actual_Digits : out Integer) is
    begin
        PLplot_Thin.plgxax(Max_Digits, Actual_Digits);
    end plgxax;


    -- Get y axis labeling parameters
    procedure plgyax(Max_Digits, Actual_Digits : out Integer) is
    begin
        PLplot_Thin.plgyax(Max_Digits, Actual_Digits);
    end plgyax;


    -- Get z axis labeling parameters
    procedure plgzax(Max_Digits, Actual_Digits : out Integer) is
    begin
        PLplot_Thin.plgzax(Max_Digits, Actual_Digits);
    end plgzax;


    -- Draws a histogram of n values of a variable in array data[0..n-1]
    procedure plhist
       (Data           : Real_Vector;
        Data_Min       : Long_Float; -- left  edge of left-most bin
        Data_Max       : Long_Float; -- right edge of right-most bin
        Number_Of_Bins : Positive; -- equal-sized, between Data_Min and Data_Max
        Options : Integer) is -- Options are not defined in plplot.h.
    begin
        PLplot_Thin.plhist
           (Data'length, Data, Data_Min, Data_Max, Number_Of_Bins, Options);
    end plhist;


    -- Set current color (map 0) by hue, lightness, and saturation.
    -- procedure plhls
    --    (Hue_Component        : Long_Float; -- Not documented; presumably 0.0..360.0.
    --     Lightness_Component  : Long_Float_0_1_Type;
    --     Saturation_Component : Long_Float_0_1_Type) is
    -- begin
    --     PLplot_Thin.plhls(Hue_Component, Lightness_Component, Saturation_Component);
    -- end plhls;


    -- Functions for converting between HLS and RGB color space
    procedure plhlsrgb
       (Hue_Component        : Long_Float;
        Lightness_Component  : Long_Float_0_1_Type;
        Saturation_Component : Long_Float_0_1_Type;
        Red_Component        : out Long_Float_0_1_Type;
        Green_Component      : out Long_Float_0_1_Type;
        Blue_Component       : out Long_Float_0_1_Type) is
    begin
        PLplot_Thin.plhlsrgb(Hue_Component, Lightness_Component, Saturation_Component, Red_Component, Green_Component, Blue_Component);
    end plhlsrgb;


    -- Initialization. Must be called before starting plot.
    -- Certain other procedures, if used, must be called first.
    -- Initializes PLplot, using preset or default options
    procedure plinit is
    begin
        PLplot_Thin.plinit;
    end plinit;


    -- Draws a line segment from (x1, y1) to (x2, y2).
    procedure pljoin(x1, y1, x2, y2 : Long_Float) is
    begin
        PLplot_Thin.pljoin(x1, y1, x2, y2);
    end pljoin;


    -- Simple routine for labelling graphs.
    procedure pllab(X_Label, Y_Label, Title_Label : String := To_String(Default_Label_String)) is
    begin
        PLplot_Thin.pllab(To_C(X_Label, True), To_C(Y_Label, True), To_C(Title_Label, True));
    end pllab;


    -- Arrays that could have elements of Plot_Color_Type are merely arrays of 
    -- integers; we have not defined special arrays (e.g., array(somerange) of 
    -- Plot_Color_Type) for the arguments Text_Colors, Box_Colors, Line_Colors, 
    -- or Symbol_Colors. Similarly for Entry_Options which could be an array
    -- of Legend_Flag_Type and some other arguments. fixme
    -- Routine for drawing discrete line, symbol, or cmap0 legends
    procedure pllegend
       (Legend_Width, Legend_Height           : out Long_Float;
        Options, Position                     : Integer;
        X_Offset, Y_Offset                    : Long_Float;
        Plot_Area_Width                       : Long_Float;
        Background_Color, Bounding_Box_Color  : Plot_Color_Type;
        Bounding_Box_Style                    : Line_Style_Type;
        Number_Rows, Number_Columns           : Integer;
        Entry_Options                         : Integer_Array_1D;
        Text_Offset, Text_Scale, Text_Spacing : Long_Float;
        Text_Justification                    : Long_Float;
        Text_Colors                           : Integer_Array_1D;
        Label_Text                            : Legend_String_Array_Type;
        Box_Colors, Box_Patterns              : Integer_Array_1D;
        Box_Scales                            : Real_Vector;
        Box_Line_Widths                       : Real_Vector;
        Line_Colors, Line_Styles              : Integer_Array_1D;
        Line_Widths                           : Real_Vector;
        Symbol_Colors                         : Integer_Array_1D;
        Symbol_Scales                         : Real_Vector;
        Symbol_Numbers                        : Integer_Array_1D;
        Symbols                               : Legend_String_Array_Type)
    is
        Number_Entries : Integer := Label_Text'length;
        L : Integer; -- Used to check lengths of arrays.
        PL_Label_Text, PL_Symbols : PL_Legend_String_Array(Label_Text'range);
        C_Legend_String_Array  : array(Label_Text'range) of PL_Legend_String;
        C_Symbols_String_Array : array(Symbols'range)    of PL_Legend_String;
        Dum_Text : Legend_String_Array_Type(Label_Text'range);
    begin
        -- Check that all array lengths in the argument list are the same.
        L := Entry_Options'length;
        if L /= Text_Colors'length or L /= Label_Text'length or L /= Box_Colors'length or
            L /= Box_Patterns'length or L /= Box_Scales'length or 
            L /= Box_Line_Widths'length or L /= Line_Colors'length or L /= Line_Styles'length or
            L /= Line_Widths'length or L /= Symbol_Colors'length or L /= Symbol_Scales'length or
            L /= Symbol_Numbers'length or L /= Symbols'length
        then
            Put_Line("*** WARNING: Mismatched array lengths at pllegend");
        end if;
        
        -- Adapt Label_Text and Symbols to C. See the comment at plstripc.
        -- Adapt Label_Text first.
        for I in Label_Text'range loop

            -- Check length and adjust if necessary.
            if Length(Label_Text(I)) >= Max_Legend_Label_Length then
                Put_Line("*** Warning: Legend label was truncated to" 
                    & Integer'Image(Max_Legend_Label_Length) & " characters. ***");
                Dum_Text(I) := Head(Label_Text(I), Max_Legend_Label_Length);
            else
                Dum_Text(I) := Label_Text(I);
            end if;

            -- Make the C-style string with null character and spaces immediately after the text.
            C_Legend_String_Array(I) := To_C(To_String(Dum_Text(I) 
                & Character'val(0) 
                & (Max_Legend_Label_Length - Length(Dum_Text(I))) * " "), False);

            -- Set the I-th pointer in the array of pointers.
            PL_Label_Text(I) := C_Legend_String_Array(I)'Address;
        end loop;

        -- Adapt Symbols next.
        for I in Symbols'range loop

            -- Check length and adjust if necessary.
            if Length(Symbols(I)) >= Max_Legend_Label_Length then
                Put_Line("*** Warning: Legend symbols label was truncated to" 
                    & Integer'Image(Max_Legend_Label_Length) & " characters. ***");
                Dum_Text(I) := Head(Symbols(I), Max_Legend_Label_Length);
            else
                Dum_Text(I) := Symbols(I);
            end if;

            -- Make the C-style string with null character and spaces immediately after the text.
            C_Symbols_String_Array(I) := To_C(To_String(Dum_Text(I) 
                & Character'val(0) 
                & (Max_Legend_Label_Length - Length(Dum_Text(I))) * " "), False);

            -- Set the I-th pointer in the array of pointers.
            PL_Symbols(I) := C_Symbols_String_Array(I)'Address;
        end loop;            

        PLplot_Thin.pllegend(Legend_Width, Legend_Height, Options, Position,
            X_Offset, Y_Offset, Plot_Area_Width, Background_Color, Bounding_Box_Color,
            Bounding_Box_Style, Number_Rows, Number_Columns, Number_Entries, 
            Entry_Options, Text_Offset, Text_Scale, Text_Spacing, Text_Justification,
            Text_Colors, PL_Label_Text, Box_Colors, Box_Patterns, Box_Scales,
            Box_Line_Widths, Line_Colors, Line_Styles, Line_Widths, Symbol_Colors,
            Symbol_Scales, Symbol_Numbers, PL_Symbols);
    end pllegend;


    -- Routine for drawing continous colour legends
    procedure plcolorbar
       (Colorbar_Width, Colorbar_Height      : out Long_Float;
        Options, Position                    : Integer;
        X_Offset, Y_Offset                   : Long_Float;
        X_Length, Y_Length                   : Long_Float;
        Background_Color, Bounding_Box_Color : Plot_Color_Type;
        Bounding_Box_Style                   : Line_Style_Type;
        Low_Cap_Color, High_Cap_Color        : Long_Float;
        Contour_Color_For_Shade              : Plot_Color_Type;
        Contour_Width_For_Shade              : Long_Float;
        Label_Options                        : Integer_Array_1D; 
        Label_Text                           : Legend_String_Array_Type;
        Axis_Options                         : Legend_String_Array_Type;
        Tick_Spacing                         : Real_Vector;
        Number_Subticks                      : Integer_Array_1D;
        Number_Values                        : Integer_Array_1D;
        Values                               : Real_Matrix)
    is
        Number_Labels : Integer := Label_Options'length;
        Number_Axes : Integer := Axis_Options'length;
        PL_Label_Text : PL_Legend_String_Array(Label_Text'range);
        C_Legend_String_Array  : array(Label_Text'range) of PL_Legend_String;
        PL_Axis_Options : PL_Legend_String_Array(Axis_Options'range);
        C_Axis_Options_String_Array  : array(Axis_Options'range) of PL_Legend_String;
        Dum_Text : Legend_String_Array_Type(Label_Text'range);
        PL_Values : Long_Float_Pointer_Array(values'range(2));
    begin
        -- Check some array lengths.
        if Number_Labels /= Label_Text'length then
            Put_Line("*** WARNING: Mismatched array lengths at plcolorbar labels");
        end if;
        if Number_Axes /= Tick_Spacing'length or Number_Axes /= Number_Subticks'length
            or Number_Axes /= Values'length(1) then
            Put_Line("*** WARNING: Mismatched array lengths at plcolorbar values");
        end if;

        -- Adapt Label_Text and Axis_Options to C. See the comment at Create_Stripchart.
        -- Adapt Label_Text first.
        for I in Label_Text'range loop

            -- Check length and adjust if necessary.
            if Length(Label_Text(I)) >= Max_Legend_Label_Length then
                Put_Line("*** Warning: Colorbar label was truncated to" 
                    & Integer'Image(Max_Legend_Label_Length) & " characters. ***");
                Dum_Text(I) := Head(Label_Text(I), Max_Legend_Label_Length);
            else
                Dum_Text(I) := Label_Text(I);
            end if;

            -- Make the C-style string with null character and spaces immediately after the text.
            C_Legend_String_Array(I) := To_C(To_String(Dum_Text(I) 
                & Character'val(0) 
                & (Max_Legend_Label_Length - Length(Dum_Text(I))) * " "), False);

            -- Set the I-th pointer in the array of pointers.
            PL_Label_Text(I) := C_Legend_String_Array(I)'Address;
        end loop;

        -- Adapt Axis_Options next.
        for I in Axis_Options'range loop

            -- Check length and adjust if necessary.
            if Length(Axis_Options(I)) >= Max_Legend_Label_Length then
                Put_Line("*** Warning: Colorbar asix options label was truncated to" 
                    & Integer'Image(Max_Legend_Label_Length) & " characters. ***");
                Dum_Text(I) := Head(Axis_Options(I), Max_Legend_Label_Length);
            else
                Dum_Text(I) := Axis_Options(I);
            end if;

            -- Make the C-style string with null character and spaces immediately after the text.
            C_Axis_Options_String_Array(I) := To_C(To_String(Dum_Text(I) 
                & Character'val(0) 
                & (Max_Legend_Label_Length - Length(Dum_Text(I))) * " "), False);

            -- Set the I-th pointer in the array of pointers.
            PL_Axis_Options(I) := C_Axis_Options_String_Array(I)'Address;
        end loop;            

        -- Adapt values in a similar way as Label_Text: make an array of pointers to Real_Vector.
        -- We need to transpose because we present the Values matrix to the user as described in the
        -- PLplot documentation for plcolorbar as rows indexing axes and columns indexing the axis
        -- values, and Matrix_To_Pointers wants things the other way.
        PL_Values := Matrix_To_Pointers(PLplot_Thin.PL_Transpose(Values));
        PLplot_Thin.plcolorbar(Colorbar_Width, Colorbar_Height, Options, Position, X_Offset, 
            Y_Offset, X_Length, Y_Length, Background_Color, Bounding_Box_Color, Bounding_Box_Style,
            Low_Cap_Color, High_Cap_Color, Contour_Color_For_Shade, Contour_Width_For_Shade,
            Number_Labels, Label_Options, PL_Label_Text, Number_Axes, 
            PL_Axis_Options, Tick_Spacing, Number_Subticks, Number_Values, PL_Values);
    end plcolorbar;


    -- Sets position of the light source
    procedure pllightsource
       (x : Long_Float := 1.0;
        y: Long_Float := 1.0;
        z: Long_Float := 1.0) is
    begin
        PLplot_Thin.pllightsource(x, y, z);
    end pllightsource;


    -- Draws line segments connecting a series of points.
    procedure plline(x, y : Real_Vector) is
    begin
        PLplot_Thin.plline(x'Length, x, y);
    end plline;


    -- Draws a line in 3 space.
    procedure plline3(x, y, z : Real_Vector) is
    begin
        PLplot_Thin.plline3(x'Length, x, y, z);
    end plline3;


    -- Set line style.
    procedure pllsty(Line_Style : Line_Style_Type) is
    begin
        PLplot_Thin.pllsty(Line_Style);
    end pllsty;


    -- fix this See comment in Example 19, x19a.adb or xthick19a.adb for how to 
    -- possibly eliminate the need to pass array size as the first argument in 
    -- the function poinetd to by Map_Form_Function_Pointer. Ditto for plmeridians.

    -- plot continental outline in world coordinates
    procedure plmap
       (Map_Form_Function_Pointer            : Map_Form_Function_Pointer_Type;
        Map_Kind                             : Map_Type;
        Minimum_Longitude, Maximum_Longitude : Long_Float;
        Minimum_Latitude,  Maximum_Latitude  : Long_Float) is
        
        Map_Kind_String : Unbounded_String;
    begin
        -- Convert Map_Kind into a string; later, a C string.
        case Map_Kind is
            when Continents =>
                begin
                    Map_Kind_String := TUB("globe");
                end;
            when USA_and_States =>
                begin
                    Map_Kind_String := TUB("usa");
                end;
            when Continents_and_Countries =>
                begin
                    Map_Kind_String := TUB("cglobe");
                end;
            when USA_States_and_Continents =>
                begin
                    Map_Kind_String := TUB("usaglobe");
                end;
        end case;
        
        PLplot_Thin.plmap(Map_Form_Function_Pointer, To_C(To_String(Map_Kind_String), True), 
            Minimum_Longitude, Maximum_Longitude, Minimum_Latitude, Maximum_Latitude);
    end plmap;


    -- fix this See comment for plmap.

    -- Plot the latitudes and longitudes on the background.
    procedure plmeridians
       (Map_Form_Function_Pointer            : Map_Form_Function_Pointer_Type;
        Delta_Longitude, Delta_Latitude      : Long_Float;
        Minimum_Longitude, Maximum_Longitude : Long_Float;
        Minimum_Latitude,  Maximum_Latitude  : Long_Float) is
    begin
        PLplot_Thin.plmeridians(Map_Form_Function_Pointer, Delta_Longitude, Delta_Latitude, 
            Minimum_Longitude, Maximum_Longitude, Minimum_Latitude, Maximum_Latitude);
    end plmeridians;


    -- Plots a mesh representation of the function z(x, y).
    procedure plmesh
       (x, y    : Real_Vector; -- surface definition points
        z       : Real_Matrix; -- height of surface at definition points
        Options : Integer) is
    begin        
        PLplot_Thin.plmesh(x, y, Matrix_To_Pointers(z), x'Length, y'Length, Options);
    end plmesh;


    -- Plots a mesh representation of the function z(x, y) with contour
    procedure plmeshc -- prototype
       (x, y           : Real_Vector; -- surface definition points
        z              : Real_Matrix; -- height of surface at definition points
        Options        : Integer;
        Contour_Levels : Real_Vector) is -- levels at which to draw contours
    begin        
        PLplot_Thin.plmeshc(x, y, Matrix_To_Pointers(z), x'Length, y'Length, Options, Contour_Levels, Contour_Levels'Length);
    end plmeshc;


    -- Creates a new stream and makes it the default.
    procedure plmkstrm(New_Stream_Number : out Integer) is
    begin
        PLplot_Thin.plmkstrm(New_Stream_Number);
    end plmkstrm;


    -- Prints out "text" at specified position relative to viewport
    procedure plmtex
       (Side : String;
        Position_From_Edge : Long_Float;
        Position_Along_Edge : Long_Float;
        Justification : Long_Float;
        The_Text : String) is
    begin
        PLplot_Thin.plmtex(To_C(Side, True), Position_From_Edge, Position_Along_Edge, Justification, To_C(The_Text, True));
    end plmtex;


    -- Prints out "The_Text" at specified position relative to viewport (3D)
    procedure plmtex3
       (Side : String;
        Position_From_Edge : Long_Float;
        Position_Along_Edge : Long_Float;
        Justification : Long_Float;
        The_Text : String) is
    begin
        PLplot_Thin.plmtex3(To_C(Side, True), Position_From_Edge, Position_Along_Edge, Justification, To_C(The_Text, True));
    end plmtex3;



    -- Plots a 3-d representation of the function z(x, y).
    procedure plot3d
       (x, y    : Real_Vector; -- surface definition points
        z       : Real_Matrix; -- height of surface at definition points
        Options : Integer;
        Sides   : Boolean) is -- draw sides?    

        PLsides : PLBOOL;
    
    begin
        if Sides then
            PLsides := PLtrue;
        else
            PLsides := PLfalse;
        end if;
        PLplot_Thin.plot3d(x, y, Matrix_To_Pointers(z), x'Length, y'Length, Options, PLsides);
    end plot3d;


    -- Plots a 3-d representation of the function z(x, y) with contour.
    procedure plot3dc
       (x, y           : Real_Vector; -- surface definition points
        z              : Real_Matrix; -- height of surface at definition points
        Options        : Integer;
        Contour_Levels : Real_Vector) is -- levels at which to draw contours
    begin        
        PLplot_Thin.plot3dc(x, y, Matrix_To_Pointers(z), x'Length, y'Length, Options, Contour_Levels, Contour_Levels'Length);
    end plot3dc;


    -- fix this; update variable names when documentation becomes available.
    -- Plots a 3-d representation of the function z(x, y) with contour and
    -- y index limits.
    procedure plot3dcl -- Lacks documentation in Chapter 17 of Ref. Man.
       (x, y                 : Real_Vector; -- surface definition points
        z                    : Real_Matrix; -- height of surface at definition points
        Options              : Integer;
        Contour_Levels       : Real_Vector;
        ixstart, ixn         : Integer;
        indexymin, indexymax : Integer_Array_1D) is -- levels at which to draw contours
    begin        
        PLplot_Thin.plot3dcl(x, y, Matrix_To_Pointers(z), x'Length, y'Length, Options, Contour_Levels, Contour_Levels'Length, ixstart, ixn, indexymin, indexymax);
    end plot3dcl;
 

    -- Set fill pattern directly.
    procedure plpat
       (Inclinations : Integer_Array_1D;
        Spacings     : Integer_Array_1D) is
    begin
        PLplot_Thin.plpat(Inclinations'Length, Inclinations, Spacings);
    end plpat;


    -- Draw a line connecting two points, accounting for coordinate transform
    procedure plpath
       (Num_Segments   : Integer;
        x1, y1, x2, y2 : Long_Float) is
    begin
        PLplot_Thin.plpath(Num_Segments, x1, y1, x2, y2);
    end plpath;


    -- Plots array y against x for n points using ASCII code "code".
    procedure plpoin
       (x, y             : Real_Vector;
        Symbol_As_Number : Integer) is
    begin
        PLplot_Thin.plpoin(x'Length, x, y, Symbol_As_Number);
    end plpoin;
    


    -- Draws a series of points in 3 space.
    procedure plpoin3
       (x, y, z          : Real_Vector;
        Symbol_As_Number : Integer) is
    begin
        PLplot_Thin.plpoin3(x'Length, x, y, z, Symbol_As_Number);
    end plpoin3;


    -- Draws a polygon in 3 space.
    procedure plpoly3
       (x, y, z : Real_Vector;
        Draw_Segments : Boolean_Array_1D;
        Draw_Counterclockwise : Boolean) is
    
        PL_Draw_Segments : PL_Bool_Array(Draw_Segments'range);
        PL_Draw_Counterclockwise : PLBOOL;
    
    begin
        if Draw_Counterclockwise then
            PL_Draw_Counterclockwise := PLTrue;
        else
            PL_Draw_Counterclockwise := PLfalse;
        end if;
        
        for Index in Draw_Segments'range loop
            if Draw_Segments(Index) then
                PL_Draw_Segments(Index) := PLtrue;
            else
                PL_Draw_Segments(Index) := PLfalse;
            end if;
        end loop;
        PLplot_Thin.plpoly3(x'length, x, y, z, PL_Draw_Segments, PL_Draw_Counterclockwise);
    end plpoly3;


    -- Set the floating point precision (in number of places) in numeric labels.
    procedure plprec
       (Set_Manually : Boolean := True;
        Number_Digits_After_Decimal_Point : Integer := 2) is
    begin
        if Set_Manually then
            PLplot_Thin.plprec(1, Number_Digits_After_Decimal_Point);
        else
            PLplot_Thin.plprec(0, Number_Digits_After_Decimal_Point);
        end if;
    end plprec;


    -- Set fill pattern, using one of the predefined patterns.
    procedure plpsty(Fill_Pattern : Fill_Pattern_Type) is
    begin
        PLplot_Thin.plpsty(Fill_Pattern);
    end plpsty;


    -- Prints out "The_Text" at world cooordinate (x, y).
    procedure plptex
       (x, y             : Long_Float;
        Delta_X, Delta_Y : Long_Float;
        Justification    : Long_Float;
        The_Text         : String) is
    begin
        PLplot_Thin.plptex(x, y, Delta_X, Delta_Y, Justification, To_C(The_Text, True));
    end plptex;


    -- Prints out "The_Text" at world cooordinate (x, y, z).
    procedure plptex3
       (x, y, z                   : Long_Float;
        Delta_X, Delta_Y, Delta_Z : Long_Float;
        Shear_X, Shear_Y, Shear_Z : Long_Float;
        Justification             : Long_Float;
        The_Text                  : String) is
    begin
        PLplot_Thin.plptex3(x, y, z, Delta_X, Delta_Y, Delta_Z, Shear_X, Shear_Y, Shear_Z, 
            Justification, To_C(The_Text, True));
    end plptex3;


    -- Random number generator based on Mersenne Twister.
    -- Obtain real random number in range [0,1].
    function plrandd return Long_Float is
    begin
        return PLplot_Thin.plrandd;
    end plrandd;


    -- Replays contents of plot buffer to current device/file.
    procedure plreplot is
    begin
        PLplot_Thin.plreplot;
    end plreplot;


    -- Set line color by red, green, blue from 0.0 to 1.0
    -- procedure plrgb(Red_Component, Blue_Component, Green_Component : Long_Float_0_1_Type) is
    -- begin
    --     PLplot_Thin.plrgb(Red_Component, Blue_Component, Green_Component);
    -- end plrgb;


    -- Set line color by 8 bit RGB values.
    -- procedure plrgb1(Red_Component, Blue_Component, Green_Component : Integer) is
    -- begin
    --     PLplot_Thin.plrgb1(Red_Component, Blue_Component, Green_Component);
    -- end plrgb1;


    -- Functions for converting between HLS and RGB color space
    procedure plrgbhls
       (Red_Component        : Long_Float_0_1_Type;
        Green_Component      : Long_Float_0_1_Type;
        Blue_Component       : Long_Float_0_1_Type;
        Hue_Component        : out Long_Float;
        Lightness_Component  : out Long_Float_0_1_Type;
        Saturation_Component : out Long_Float_0_1_Type) is
    begin
        PLplot_Thin.plrgbhls(Red_Component, Green_Component, Blue_Component, Hue_Component, Lightness_Component, Saturation_Component);
    end plrgbhls;


    -- Set character height.
    procedure plschr(Default_Height, Scale_Factor : Long_Float) is
    begin
        PLplot_Thin.plschr(Default_Height, Scale_Factor);
    end plschr;


    -- Set color map 0 colors by 8 bit RGB values
    procedure plscmap0(Red_Components, Green_Components, Blue_Components : Integer_Array_1D) is
    begin
        PLplot_Thin.plscmap0(Red_Components, Green_Components, Blue_Components, Red_Components'Length);
    end plscmap0;


    -- Set color map 0 colors by 8 bit RGB values and alpha values
    procedure plscmap0a
       (Red_Components, Green_Components, Blue_Components : Integer_Array_1D;
        Alpha                                             : Real_Vector) is
    begin
        PLplot_Thin.plscmap0a(Red_Components, Green_Components, Blue_Components, Alpha, Red_Components'Length);
    end plscmap0a;


    -- Set number of colors in cmap 0
    procedure plscmap0n(Number_Of_Colors : Integer) is
    begin
        PLplot_Thin.plscmap0n(Number_Of_Colors);
    end plscmap0n;


    -- Set color map 1 colors by 8 bit RGB values
    procedure plscmap1
       (Red_Component, Green_Component, Blue_Component : Integer_0_255_Array) is
       
       PL_Red_Component, PL_Green_Component, PL_Blue_Component : Integer_Array_1D(Red_Component'range);
    begin
        -- Copy constrained color integers to unconstrained integers.
        for i in Red_Component'range loop -- Should use slices
            PL_Red_Component(i)   := Red_Component(i);
            PL_Green_Component(i) := Green_Component(i);
            PL_Blue_Component(i)  := Blue_Component(i);
        end loop;
        PLplot_Thin.plscmap1(PL_Red_Component, PL_Green_Component, PL_Blue_Component, PL_Red_Component'Length);
    end plscmap1;


    -- Set color map 1 colors by 8 bit RGB values
    procedure plscmap1a
       (Red_Component, Green_Component, Blue_Component : Integer_0_255_Array;
        Alpha                                          : Real_Vector) is
       
       PL_Red_Component, PL_Green_Component, PL_Blue_Component : Integer_Array_1D(Red_Component'range);
    begin
        -- Copy constrained color integers to unconstrained integers.
        for i in Red_Component'range loop -- Should use slices
            PL_Red_Component(i)   := Red_Component(i);
            PL_Green_Component(i) := Green_Component(i);
            PL_Blue_Component(i)  := Blue_Component(i);
        end loop;
        PLplot_Thin.plscmap1a(PL_Red_Component, PL_Green_Component, PL_Blue_Component, Alpha, PL_Red_Component'Length);
    end plscmap1a;


    -- Set color map 1 colors using a piece-wise linear relationship between
    -- intensity [0,1] (cmap 1 index) and position in HLS or RGB color space.
    procedure plscmap1l
       (Color_Model    : Color_Model_Type; -- HLS or RGB
        Control_Points : Real_Vector; -- range 0.0 .. 1.0; not checked here
        H_Or_R         : Real_Vector; -- range 0.0 .. 1.0; not checked here
                                              -- Note: Hue is 0.0 .. 360.0.
        L_Or_G         : Real_Vector; -- range 0.0 .. 1.0; not checked here
        S_Or_B         : Real_Vector; -- range 0.0 .. 1.0; not checked here
        Alt_Hue_Path   : Boolean_Array_1D) is -- True means use alternative hue interpolation path which always includes the point hue = 0.  False reverses.
        
        PL_Color_Model : PLBOOL;
        PL_Alt_Hue_Path : PL_Bool_Array (Alt_Hue_Path'range);
        
    begin
        -- Check for consistent array lengths.
        if  Control_Points'length /= H_Or_R'length or Control_Points'length /= L_or_G'length or
            Control_Points'length /= S_Or_B'length or Control_Points'length /= Alt_Hue_Path'length 
        then
            Put_Line("*** WARNING: Inconsistent array lengths when setting color map 1 ***");
        end if;
        
        if Color_Model = RGB then
            PL_Color_Model := PLtrue;
        else
            PL_Color_Model := PLfalse;
        end if;

        for i in Alt_Hue_Path'range loop
            if Alt_Hue_Path(i) then
                PL_Alt_Hue_Path(i) := PLtrue;
            else
                PL_Alt_Hue_Path(i) := PLfalse;
            end if;
        end loop;

        PLplot_Thin.plscmap1l(PL_Color_Model, Control_Points'Length, Control_Points, H_Or_R, L_Or_G, S_Or_B, PL_Alt_Hue_Path);
    end plscmap1l;
    
    
    -- Overloaded version of plscmap1l which allows simplified (alt_hue_path false) interpolation.
    -- This is an Ada-like way of doing what is described
    -- in the PLplot documentation when a C user passes a null pointer as the
    -- final argument instead of an array of booleans to indicate which
    -- of the two hue interpolation paths to take.
    procedure plscmap1l
       (Color_Model    : Color_Model_Type; -- HLS or RGB
        Control_Points : Real_Vector; -- range 0.0 .. 1.0; not checked here
        H_Or_R         : Real_Vector; -- range 0.0 .. 1.0; not checked here
                                              -- Note: Hue is 0.0 .. 360.0.
        L_Or_G         : Real_Vector; -- range 0.0 .. 1.0; not checked here
        S_Or_B         : Real_Vector; -- range 0.0 .. 1.0; not checked here
        Alt_Hue_Path    : Alt_Hue_Path_Type) is
        
        Alt_Hue_Path_Array : Boolean_Array_1D(Control_Points'range);
    begin
        if Alt_Hue_Path = Alt_Hue_Path_All then
            for i in Alt_Hue_Path_Array'range loop
                Alt_Hue_Path_Array(i) := True;
            end loop;
        elsif Alt_Hue_Path = Alt_Hue_Path_None then
            for i in Alt_Hue_Path_Array'range loop
                Alt_Hue_Path_Array(i) := False;
            end loop;
        end if;
        plscmap1l(Color_Model, Control_Points, H_Or_R, L_Or_G, S_Or_B, Alt_Hue_Path_Array);
    end plscmap1l;


    -- Set color map 1 colors using a piece-wise linear relationship between
    -- intensity [0,1] (cmap 1 index) and position in HLS or RGB color space.
    -- Will also linear interpolate alpha values.
    procedure plscmap1la
       (Color_Model    : Color_Model_Type; -- HLS or RGB
        Control_Points : Real_Vector; -- range 0.0 .. 1.0; not checked here
        H_Or_R         : Real_Vector; -- range 0.0 .. 1.0; not checked here
        L_Or_G         : Real_Vector; -- range 0.0 .. 1.0; not checked here
        S_Or_B         : Real_Vector; -- range 0.0 .. 1.0; not checked here
        Alpha          : Real_Vector; -- range 0.0 .. 1.0; not checked here
        Alt_Hue_Path    : Boolean_Array_1D) is -- True means use alternative hue interpolation path which always includes the point hue = 0.  False reverses.
        
        PL_Color_Model : PLBOOL;
        PL_Alt_Hue_Path : PL_Bool_Array (Alt_Hue_Path'range);
        
    begin
        -- Check for consistent array lengths.
        if  Control_Points'length /= H_Or_R'length or Control_Points'length /= L_or_G'length or
            Control_Points'length /= S_Or_B'length or Control_Points'length /= Alt_Hue_Path'length 
        then
            Put_Line("*** WARNING: Inconsistent array lengths when setting color map 1 ***");
        end if;

        if Color_Model = RGB then
            PL_Color_Model := PLtrue;
        else
            PL_Color_Model := PLfalse;
        end if;

        for i in Alt_Hue_Path'range loop
            if Alt_Hue_Path(i) then
                PL_Alt_Hue_Path(i) := PLtrue;
            else
                PL_Alt_Hue_Path(i) := PLfalse;
            end if;
        end loop;

        PLplot_Thin.plscmap1la(PL_Color_Model, Control_Points'Length, Control_Points, H_Or_R, L_Or_G, S_Or_B, Alpha, PL_Alt_Hue_Path);
    end plscmap1la;
    
    
    -- Overloaded version of plscmap1la which allows simplified (alt_hue_path false) interpolation.
    -- This is an Ada-like way of doing what is described
    -- in the PLplot documentation when a C user passes a null pointer as the
    -- final argument instead of an array of booleans to indicate which
    -- of the two hue interpolation paths to take.
    procedure plscmap1la
       (Color_Model    : Color_Model_Type; -- HLS or RGB
        Control_Points : Real_Vector; -- range 0.0 .. 1.0; not checked here
        H_Or_R         : Real_Vector; -- range 0.0 .. 1.0; not checked here
        L_Or_G         : Real_Vector; -- range 0.0 .. 1.0; not checked here
        S_Or_B         : Real_Vector; -- range 0.0 .. 1.0; not checked here
        Alpha          : Real_Vector; -- range 0.0 .. 1.0; not checked here
        Alt_Hue_Path    : Alt_Hue_Path_Type) is
        
        Alt_Hue_Path_Array : Boolean_Array_1D(Control_Points'range);
    begin
        if Alt_Hue_Path = Alt_Hue_Path_All then
            for i in Alt_Hue_Path_Array'range loop
                Alt_Hue_Path_Array(i) := True;
            end loop;
        elsif Alt_Hue_Path = Alt_Hue_Path_None then
            for i in Alt_Hue_Path_Array'range loop
                Alt_Hue_Path_Array(i) := False;
            end loop;
        end if;
        plscmap1la(Color_Model, Control_Points, H_Or_R, L_Or_G, S_Or_B, Alpha, Alt_Hue_Path_Array);
    end plscmap1la;


    -- Set number of colors in cmap 1
    procedure plscmap1n(Number_Of_Colors : Integer) is
    begin
        PLplot_Thin.plscmap1n(Number_Of_Colors);
    end plscmap1n;


    -- Set the color map 1 range used in continuous plots.
    procedure plscmap1_range(Min_Color, Max_Color : Long_Float) is
    begin
        PLplot_Thin.plscmap1_range(Min_Color, Max_Color);
    end plscmap1_range;


    -- Get the color map 1 range used in continuous plots
    procedure plgcmap1_range(Min_Color : out Long_Float; Max_Color : out Long_Float) is
    begin
        PLplot_Thin.plgcmap1_range(Min_Color, Max_Color);
    end plgcmap1_range;


    -- Set a given color from color map 0 by 8 bit RGB value
    procedure plscol0
       (Plot_Color : Plot_Color_Type;
        Red_Component, Green_Component, Blue_Component : Integer) is
    begin
        PLplot_Thin.plscol0(Plot_Color, Red_Component, Green_Component, Blue_Component);
    end plscol0;
    

    -- Set a given color from color map 0 by 8 bit RGB value and alpha value
    procedure plscol0a
       (Plot_Color                                     : Plot_Color_Type;
        Red_Component, Green_Component, Blue_Component : Integer;
        Alpha                                          : Long_Float_0_1_Type) is
    begin
        PLplot_Thin.plscol0a(Plot_Color, Red_Component, Green_Component, Blue_Component, Alpha);
    end plscol0a;


    -- Set the background color by 8 bit RGB value
    procedure plscolbg
       (Red_Component, Green_Component, Blue_Component : Integer) is
    begin
        PLplot_Thin.plscolbg(Red_Component, Green_Component, Blue_Component);
    end plscolbg;


    -- Set the background color by 8 bit RGB value and alpha value
    procedure plscolbga
       (Red_Component, Green_Component, Blue_Component : Integer;
        Alpha                                          : Long_Float_0_1_Type) is
    begin
        PLplot_Thin.plscolbga(Red_Component, Green_Component, Blue_Component, Alpha);
    end plscolbga;


    -- Used to globally turn color output on/off
    procedure plscolor(Enable_Color : Boolean) is

        PL_Enable_Color : PLBOOL;
        
    begin
        if Enable_Color then
            PL_Enable_Color := 1;
        else
            PL_Enable_Color := 0;
        end if;
        PLplot_Thin.plscolor(PL_Enable_Color);
    end plscolor;


    -- Set the compression level
    procedure plscompression(Compression_Level : Integer) is
    begin
        PLplot_Thin.plscompression(Compression_Level);
    end plscompression;


    -- Set the device (keyword) name
    procedure plsdev(Device_Name : String) is
    begin
        PLplot_Thin.plsdev(To_C(Device_Name, True));
    end plsdev;


    -- Set window into device space using margin, aspect ratio, and
    -- justification
    procedure plsdidev
       (Margin          : Long_Float;
        Aspect_Ratio    : Long_Float;
        x_Justification : Long_Float;
        y_Justification : Long_Float) is
    begin
        PLplot_Thin.plsdidev(Margin, Aspect_Ratio, x_Justification, y_Justification);
    end plsdidev;


    -- Set up transformation from metafile coordinates.
    procedure plsdimap
       (dimxmin : Integer;
        dimxmax : Integer;
        dimymin : Integer;
        dimymax : Integer;
        dimxpmm : Long_Float;
        dimypmm : Long_Float) is
    begin
        PLplot_Thin.plsdimap(dimxmin, dimxmax, dimymin, dimymax, dimxpmm, dimypmm);
    end plsdimap;
    

    -- Set plot orientation, specifying rotation in units of pi/2.
    procedure plsdiori(Rotation : Long_Float) is
    begin
        PLplot_Thin.plsdiori(Rotation);
    end plsdiori;


    -- Set window into plot space
    procedure plsdiplt
       (x_Min : Long_Float := 0.0;
        y_Min : Long_Float := 0.0;
        x_Max : Long_Float := 1.0;
        y_Max : Long_Float := 1.0) is
    begin
        PLplot_Thin.plsdiplt(x_Min, y_Min, x_Max, y_Max);
    end plsdiplt;
    

    -- Set window into plot space incrementally (zoom)
    procedure plsdiplz
       (x_Min_Relative : Long_Float;
        y_Min_Relative : Long_Float;
        x_Max_Relative : Long_Float;
        y_Max_Relative : Long_Float) is
    begin
        PLplot_Thin.plsdiplz(x_Min_Relative, y_Min_Relative, x_Max_Relative, y_Max_Relative);
    end plsdiplz;


    -- Set seed for internal random number generator
    procedure plseed(Seed : Unsigned_Int) is
    begin
        PLplot_Thin.plseed(Seed);
    end plseed;


    -- Set the escape character for text strings.
    procedure plsesc(Escape_Character : Character) is
    
        Escape_Characters : Ada.Strings.Maps.Character_Set;
        
    begin

        Escape_Characters := Ada.Strings.Maps.To_Set("!#$%&*@^~");
        
        if Ada.Strings.Maps.Is_In(Escape_Character, Escape_Characters) then
            PLplot_Thin.plsesc(To_C(Escape_Character));
        else
            Put_Line("Illegal escape character passed to Set_Escape_Character.");
        end if;
    end plsesc;


    -- Set family file parameters
    procedure plsfam
       (Enable_Family : Boolean;
        Family_File_Number : Integer := 1;
        Maximum_File_Size : Integer := 1_000_000) is
    
        PL_Enable_Family : PLBOOL;
        
    begin
        if Enable_Family then
            PL_Enable_Family := 1;
        else
            PL_Enable_Family := 0;
        end if;
        PLplot_Thin.plsfam(PL_Enable_Family, Family_File_Number, Maximum_File_Size);
    end plsfam;


    -- Set FCI (font characterization integer)
    procedure plsfci(Font_Characterization_Integer : Unicode) is
    begin
        PLplot_Thin.plsfci(Font_Characterization_Integer);
    end plsfci;
    
    
    -- Set the font family, style and weight
    procedure plsfont(Family, Style, Weight : Integer) is
    begin
        PLplot_Thin.plsfont(Family, Style, Weight);
    end;


    -- Set the output file name.
    procedure plsfnam(Output_File_Name : String) is
    begin
        PLplot_Thin.plsfnam(To_C(Output_File_Name, True));
    end plsfnam;


    -- Shade region.
    procedure plshade
       (z                                        : Real_Matrix;
        Mask_Function_Pointer                    : Mask_Function_Pointer_Type;
        x_Min, x_Max, y_Min, y_Max               : Long_Float; -- world mins and maxes
        Shade_Min, Shade_Max                     : Long_Float;
        Select_Color_Map                         : Natural; -- should be 0 or 1
        Color                                    : Long_Float;
        Fill_Pattern_Pen_Width                   : Long_Float;
        Shade_Min_Pen_Color                      : Natural;
        Shade_Min_Pen_Width                      : Long_Float;
        Shade_Max_Pen_Color                      : Natural;
        Shade_Max_Pen_Width                      : Long_Float;
        Fill_Procedure_Pointer                   : Fill_Procedure_Pointer_Type;
        Preserve_Rectangles                      : Boolean;
        Transformation_Procedure_Pointer         : Transformation_Procedure_Pointer_Type;
        Transformation_Data_Pointer              : PLpointer) is

        Preserve_Rectangles_As_Integer : Integer;
    begin
        if Preserve_Rectangles then
            Preserve_Rectangles_As_Integer := 1;
        else
            Preserve_Rectangles_As_Integer := 0;
        end if;
        
        PLplot_Thin.plshade(Matrix_To_Pointers(z), z'Length(1), z'Length(2), Mask_Function_Pointer,
            x_Min, x_Max, y_Min, y_Max, Shade_Min, Shade_Max, Select_Color_Map, 
            Color, Fill_Pattern_Pen_Width, 
            Shade_Min_Pen_Color, Shade_Min_Pen_Width, 
            Shade_Max_Pen_Color, Shade_Max_Pen_Width, 
            Fill_Procedure_Pointer, Preserve_Rectangles_As_Integer,
            Transformation_Procedure_Pointer, Transformation_Data_Pointer);
    end plshade;


    procedure plshade1
       (z                                        : Real_Matrix;
        Mask_Function_Pointer                    : Mask_Function_Pointer_Type;
        x_Min, x_Max, y_Min, y_Max               : Long_Float; -- world mins and maxes
        Shade_Min, Shade_Max                     : Long_Float;
        Select_Color_Map                         : Natural; -- should be 0 or 1
        Color                                    : Long_Float;
        Fill_Pattern_Pen_Width                   : Long_Float;
        Shade_Min_Pen_Color                      : Natural;
        Shade_Min_Pen_Width                      : Long_Float;
        Shade_Max_Pen_Color                      : Natural;
        Shade_Max_Pen_Width                      : Long_Float;
        Fill_Procedure_Pointer                   : Fill_Procedure_Pointer_Type;
        Preserve_Rectangles                      : Boolean;
        Transformation_Procedure_Pointer         : Transformation_Procedure_Pointer_Type;
        Transformation_Data_Pointer              : PLpointer) is

        Preserve_Rectangles_As_Integer : Integer;
    begin
        if Preserve_Rectangles then
            Preserve_Rectangles_As_Integer := 1;
        else
            Preserve_Rectangles_As_Integer := 0;
        end if;
        
        PLplot_Thin.plshade1(z, z'Length(1), z'Length(2), Mask_Function_Pointer,
            x_Min, x_Max, y_Min, y_Max, Shade_Min, Shade_Max, Select_Color_Map, 
            Color, Fill_Pattern_Pen_Width, 
            Shade_Min_Pen_Color, Shade_Min_Pen_Width, 
            Shade_Max_Pen_Color, Shade_Max_Pen_Width, 
            Fill_Procedure_Pointer, Preserve_Rectangles_As_Integer, 
            Transformation_Procedure_Pointer, Transformation_Data_Pointer);
    end plshade1;


    procedure plshades
       (z                                : Real_Matrix;
        Mask_Function_Pointer            : Mask_Function_Pointer_Type;
        x_Min, x_Max, y_Min, y_Max       : Long_Float; -- world mins and maxes
        Contour_Levels                   : Real_Vector;
        Fill_Pattern_Pen_Width           : Long_Float; -- 0.0 is allowed
        Contour_Pen_Color                : Natural; -- 0 for no contours
        Contour_Pen_Width                : Long_Float; -- 0.0 for no contours
        Fill_Procedure_Pointer           : Fill_Procedure_Pointer_Type;
        Preserve_Rectangles              : Boolean;
        Transformation_Procedure_Pointer : Transformation_Procedure_Pointer_Type;
        Transformation_Data_Pointer      : PLpointer) is

        Preserve_Rectangles_As_Integer : Integer;
    begin
        if Preserve_Rectangles then
            Preserve_Rectangles_As_Integer := 1;
        else
            Preserve_Rectangles_As_Integer := 0;
        end if;
        
        PLplot_Thin.plshades(Matrix_To_Pointers(z), z'Length(1), z'Length(2), Mask_Function_Pointer, 
            x_Min, x_Max, y_Min, y_Max, Contour_Levels, Contour_Levels'Length, 
            Fill_Pattern_Pen_Width, Contour_Pen_Color, Contour_Pen_Width, 
            Fill_Procedure_Pointer, Preserve_Rectangles_As_Integer, 
            Transformation_Procedure_Pointer, Transformation_Data_Pointer);
    end plshades;

    
    -- The procedure plfshade is not part of the API. If it should be necessary 
    -- to make it available to Ada programs, use the binding to plfcont in this 
    -- file as a guidline.

    -- fix this
    --    procedure
    --    plfshade(PLFLT (*f2eval) ( : PLINT;  : PLINT; PLPointer),
    --         PLPointer f2eval_data,
    --         PLFLT (*c2eval) ( : PLINT;  : PLINT; PLPointer),
    --         PLPointer c2eval_data,
    --         nx : PLINT; ny : PLINT;
    --         left : PLFLT; right : PLFLT; bottom : PLFLT; top : PLFLT;
    --         shade_min : PLFLT; shade_max : PLFLT;
    --         sh_cmap : PLINT; sh_color : PLFLT; sh_width : PLINT;
    --         min_color : PLINT; min_width : PLINT;
    --         max_color : PLINT; max_width : PLINT;
    --         void (*fill) ( : PLINT;  : PL_Float_Array;  : PL_Float_Array), rectangular : PLINT;
    --         void (*pltr) ( : PLFLT;  : PLFLT;  : PL_Float_Array;  : PL_Float_Array; PLPointer),
    --         PLPointer pltr_data);


    -- Setup a user-provided custom labeling function.
    procedure plslabelfunc
       (Custom_Label_Procedure_Pointer : Custom_Label_Procedure_Pointer_Type;
        label_data                     : PLPointer) is
    begin
        PLplot_Thin.plslabelfunc(Custom_Label_Procedure_Pointer, label_data);
    end plslabelfunc;
    
    
    -- Reset to default labeling. Not part of the C API.
    procedure Use_Default_Labels is
    begin
        plslabelfunc(null, System.Null_Address);
    end Use_Default_Labels;


    -- Set up lengths of major tick marks.
    procedure plsmaj(Default_Length, Scale_Factor : Long_Float) is
    begin
        PLplot_Thin.plsmaj(Default_Length, Scale_Factor);
    end plsmaj;


    -- Set the memory area to be plotted (with the 'mem' driver)
    procedure plsmem
       (x_Size, y_Size : Integer;
        Plot_This      : System.Address) is
    begin
        PLplot_Thin.plsmem(x_Size, y_Size, Plot_This);
    end plsmem;


    -- Set up lengths of minor tick marks.
    procedure plsmin(Default_Length, Scale_Factor : Long_Float) is
    begin
        PLplot_Thin.plsmin(Default_Length, Scale_Factor);
    end plsmin;


    -- Set orientation. Must be done before calling plinit.
    procedure plsori(Orientation : Orientation_Type) is
    begin
        if Orientation = Landscape then
            PLplot_Thin.plsori(0);
        else -- Orientation = Portrait
            PLplot_Thin.plsori(1);
        end if;
    end plsori;


    -- Set output device parameters. Usually ignored by the driver.
    procedure plspage
       (x_Pixels, y_Pixels : Long_Float;
        x_Length, y_Length : Integer;
        x_Offset, y_Offset : Integer) is
    begin
        PLplot_Thin.plspage(x_Pixels, y_Pixels, x_Length, y_Length, x_Offset, y_Offset);
    end plspage;


    -- Set the colors for color table 0 from a cmap0 file.
    procedure plspal0(Color_File_Name : String) is
    begin
        PLplot_Thin.plspal0(To_C(Color_File_Name, True));
    end plspal0;


    -- Set the colors for color table 1 from a cmap1 file.
    procedure plspal1(Color_File_Name : String; Interpolate : Boolean) is
    
        PL_Interpolate : PLBOOL;
        
    begin
        if Interpolate then
            PL_Interpolate := PLtrue;
        else
            PL_Interpolate := PLfalse;
        end if;
        PLplot_Thin.plspal1(To_C(Color_File_Name, True), PL_Interpolate);
    end plspal1;


    -- Set the pause (on end-of-page) status
    procedure plspause(Pause : Boolean) is
    
        PL_Pause : PLBOOL;
    
    begin
        if Pause then
            PL_Pause := PLtrue;
        else
            PL_Pause := PLfalse;
        end if;
        PLplot_Thin.plspause(PL_Pause);
    end plspause;


    -- Set stream number.
    procedure plsstrm(Stream_Number : Integer) is
    begin
        PLplot_Thin.plsstrm(Stream_Number);
    end plsstrm;


    -- Set the number of subwindows in x and y
    procedure plssub(x_Number, y_Number : Integer) is
    begin
        PLplot_Thin.plssub(x_Number, y_Number);
    end plssub;


    -- Set symbol height.
    procedure plssym(Default_Height, Scale_Factor : Long_Float) is
    begin
        PLplot_Thin.plssym(Default_Height, Scale_Factor);
    end plssym;


    -- Initialize PLplot, passing in the windows/page settings.
    procedure plstar
       (Number_Horizontal_Subpages, Number_Vertical_Subpages : Integer := 1) is
    begin
        PLplot_Thin.plstar(Number_Horizontal_Subpages, Number_Vertical_Subpages);
    end plstar;


    -- Initialize PLplot, passing the device name and windows/page settings.
    procedure plstart
       (Device_Name                                          : String;
        Number_Horizontal_Subpages, Number_Vertical_Subpages : Integer := 1) is
    begin
        PLplot_Thin.plstart(To_C(Device_Name), Number_Horizontal_Subpages, Number_Vertical_Subpages);
    end plstart;


    -- Set the coordinate transform.
    procedure plstransform
       (Coordinate_Transform_Procedure_Pointer : Coordinate_Transform_Procedure_Pointer_Type;
        Coordinate_Transform_Data_Pointer : PLpointer) is
    begin
        PLplot_Thin.plstransform(Coordinate_Transform_Procedure_Pointer,
            Coordinate_Transform_Data_Pointer);
    end plstransform;
    
    
    -- Clear the coordinate transform. Ada only; not part of the C API.
    procedure Clear_Custom_Coordinate_Transform is
    begin
        PLplot_Thin.plstransform(null, System.Null_Address);
    end Clear_Custom_Coordinate_Transform;


    -- Prints out the same string repeatedly at the n points in world
    -- coordinates given by the x and y arrays.  Supersedes plpoin and
    -- plsymbol for the case where text refers to a unicode glyph either
    -- directly as UTF-8 or indirectly via the standard text escape
    -- sequences allowed for PLplot input strings.
    procedure plstring
       (x, y : Real_Vector;
        Plot_This_String : String) is
    begin
        PLplot_Thin.plstring(x'Length, x, y, To_C(Plot_This_String));
    end plstring;


    -- Prints out the same string repeatedly at the n points in world
    -- coordinates given by the x, y, and z arrays.  Supersedes plpoin3
    -- for the case where text refers to a unicode glyph either directly
    -- as UTF-8 or indirectly via the standard text escape sequences
    -- allowed for PLplot input strings.
    procedure plstring3
       (x, y, z : Real_Vector;
        Plot_This_String : String) is
    begin
        PLplot_Thin.plstring3(x'Length, x, y, z, To_C(Plot_This_String));
    end plstring3;


    -- Add a point to a stripchart.
    procedure plstripa
       (ID         : Integer;
        Pen_Number : Integer;
        x, y       : Long_Float) is
    begin
        PLplot_Thin.plstripa(ID, Pen_Number, x, y);
    end plstripa;


    -- Create 1d stripchart
    procedure plstripc
       (ID                                   : out Integer;
        X_Options, Y_Options                 : String;
        x_Min, x_Max                         : Long_Float;
        x_Jump                               : Long_Float;
        y_Min, y_Max                         : Long_Float;
        x_Legend_Position, y_Legend_Position : Long_Float;
        Autoscale_Y                          : Boolean;
        Accumulate                           : Boolean; --Accumulate or slide
        Box_Color, Legend_Color              : Plot_Color_Type;
        Pen_Colors                           : Integer_Array_1D;
        Line_Styles                          : Integer_Array_1D;
        Pen_Labels                           : in out Stripchart_Label_String_Array_Type;
        X_Label, Y_Label, Title_Label        : String := To_String(Default_Label_String)) is
        
        PL_Autoscale_Y, PL_Accumulate : PLBOOL;
        PL_Pen_Labels : PL_Stripchart_String_Array;
        
        x_LP : Long_Float renames x_Legend_Position;
        y_LP : Long_Float renames y_Legend_Position;

    begin
        if Autoscale_Y then
            PL_Autoscale_Y := PLtrue;
        else
            PL_Autoscale_Y := PLfalse;
        end if;
        
        if Accumulate then
            PL_Accumulate := PLtrue;
        else
            PL_Accumulate := PLfalse;
        end if;
        
        -- Adapt strings for Pen_Labels to C. We have to pass an array of 
        -- pointers (here, System.Address) to C-style strings, except that the 
        -- C-style strings usually have the null terminator somewhere in the
        -- middle of the allocated string memory, after the "significant text."
        -- I'm not sure if C allocates the memory or not--probably not, since 
        -- this is not a callback as in plslabelfunc where string memory was 
        -- allocated by the intervening C code. Here, the C string length is set
        -- by Max_Stripchart_Label_Length, ranging 0 .. Max_Stripchart_Label_Length.
        for I in Pen_Labels'range loop

            -- Check length and adjust if necessary.
            if Length(Pen_Labels(I)) >= Max_Stripchart_Label_Length then
                Put_Line("*** Warning: Stripchart label was truncated to" 
                    & Integer'Image(Max_Stripchart_Label_Length) & " characters. ***");
                Pen_Labels(I) := Head(Pen_Labels(I), Max_Stripchart_Label_Length);
            end if;

            -- Make the C-style string with null character immediately after the text.
            C_Stripchart_String_Array(I) := To_C(To_String(Pen_Labels(I) 
                & Character'val(0) 
                & (Max_Stripchart_Label_Length - Length(Pen_Labels(I))) * " "), False);

            -- Set the I-th pointer in the array of pointers.
            PL_Pen_Labels(I) := C_Stripchart_String_Array(I)'Address;
        end loop;
        
        PLplot_Thin.plstripc(ID, To_C(X_Options), To_C(Y_Options), 
            x_Min, x_Max, x_Jump, y_Min, y_Max, x_LP, y_LP, PL_Autoscale_Y, 
            PL_Accumulate, Box_Color, Legend_Color, Pen_Colors, Line_Styles, 
            PL_Pen_Labels, To_C(x_Label), To_C(y_Label), To_C(Title_Label));
    end plstripc;


    -- Deletes and releases memory used by a stripchart.
    procedure plstripd(ID : Integer) is
    begin
        PLplot_Thin.plstripd(ID);
    end plstripd;


    -- plots a 2d image (or a matrix too large for plshade() )
    procedure plimagefr
       (Data                             : Real_Matrix;
        x_Min,     x_Max                 : Long_Float;
        y_Min,     y_Max                 : Long_Float;
        z_Min,     z_Max                 : Long_Float;
        Value_Min, Value_Max             : Long_Float;
        Transformation_Procedure_Pointer : Transformation_Procedure_Pointer_Type;
        Transformation_Data_Pointer      : PLpointer) is
    begin
        PLplot_Thin.plimagefr(Matrix_To_Pointers(Data), Data'Length(1), Data'Length(2), 
            x_Min, x_Max, y_Min, y_Max, z_Min, z_Max, Value_Min, Value_Max, 
            Transformation_Procedure_Pointer, Transformation_Data_Pointer);
    end plimagefr;


    -- plots a 2d image (or a matrix too large for plshade() )
    procedure plimage
       (Data : Real_Matrix;
        x_Min, x_Max : Long_Float;
        y_Min, y_Max : Long_Float;
        z_Min, z_Max : Long_Float;
        Dxmin, Dxmax : Long_Float;
        Dymin, Dymax : Long_Float) is
    begin
        PLplot_Thin.plimage(Matrix_To_Pointers(Data), Data'Length(1), Data'Length(2), x_Min, x_Max, y_Min, y_Max, z_Min, z_Max, Dxmin, Dxmax, Dymin, Dymax);
    end plimage;


    -- Set up a new line style
    procedure plstyl(Marks, Spaces : Integer_Array_1D) is
    begin
        PLplot_Thin.plstyl(Marks'Length, Marks, Spaces);
    end plstyl;

    -- This is an overloaded procedure equivalent to calling plstyl with its
    -- first argument zero.
    procedure plstyl(Default_Continuous_Line : Integer) is
        Dummy_Marks, Dummy_Spaces : Integer_Array_1D(1 .. 1) := (others => 0);
    begin
        PLplot_Thin.plstyl(0, Dummy_Marks, Dummy_Spaces);
    end plstyl;


    -- Plots the 3d surface representation of the function z(x, y).
    procedure plsurf3d
       (x, y           : Real_Vector; -- surface definition points
        z              : Real_Matrix; -- height of surface at definition points
        Options        : Integer;
        Contour_Levels : Real_Vector) is -- levels at which to draw contours        
    begin
        PLplot_Thin.plsurf3d(x, y, Matrix_To_Pointers(z), x'Length, y'Length, Options, Contour_Levels, Contour_Levels'Length);
    end plsurf3d;


    -- Plots the 3d surface representation of the function z(x, y) with y
    -- index limits.
    -- plsurf3dl


    -- Sets the edges of the viewport to the specified absolute coordinates
    procedure plsvpa
       (Left_Edge   : Long_Float;    -- millimeters from edge of subpage
        Right_Edge  : Long_Float;    -- millimeters from edge of subpage
        Bottom_Edge : Long_Float;    -- millimeters from edge of subpage
        Top_Edge    : Long_Float) is -- millimeters from edge of subpage
    begin
        PLplot_Thin.plsvpa(Left_Edge, Right_Edge, Bottom_Edge, Top_Edge);
    end plsvpa;


    -- Set x axis labeling parameters
    -- "digits" changed to "field_digits".
    procedure plsxax(Max_Digits, Field_Digits : Integer) is
    begin
        PLplot_Thin.plsxax(Max_Digits, Field_Digits);
    end plsxax;


    -- fix this; undocumented in Chapter 17.
    -- Set inferior X window
    procedure plsxwin(Window_ID : Integer) is
    begin
        PLplot_Thin.plsxwin(Window_ID);
    end plsxwin;
    

    -- Set y axis labeling parameters
    -- "digits" changed to "field_digits".
    procedure plsyax(Max_Digits, Field_Digits : Integer) is
    begin
        PLplot_Thin.plsyax(Max_Digits, Field_Digits);
    end plsyax;


    -- Plots array y against x for n points using Hershey symbol "code"
    procedure plsym
       (x, y : Real_Vector;
        Hershey_Code : Integer) is
    begin
        PLplot_Thin.plsym(x'Length, x, y, Hershey_Code);
    end plsym;


    -- Set z axis labeling parameters
    -- "digits" changed to "field_digits".
    procedure plszax(Max_Digits, Field_Digits : Integer) is
    begin
        PLplot_Thin.plszax(Max_Digits, Field_Digits);
    end plszax;


    -- Switches to text screen.
    procedure pltext is
    begin
        PLplot_Thin.pltext;
    end pltext;


    -- Set the format for date / time labels
    procedure pltimefmt(Format : String) is
    begin
        PLplot_Thin.pltimefmt(To_C(Format));
    end pltimefmt;


    -- Sets the edges of the viewport with the given aspect ratio, leaving
    -- room for labels.
    procedure plvasp(Aspect_Ratio : Long_Float) is
    begin
        PLplot_Thin.plvasp(Aspect_Ratio);
    end plvasp;


    -- Creates the largest viewport of the specified aspect ratio that fits
    -- within the specified normalized subpage coordinates.
    procedure plvpas
       (x_Min, x_Max : Long_Float;
        y_Min, y_Max : Long_Float;
        Aspect_Ratio : Long_Float) is
    begin
        PLplot_Thin.plvpas(x_Min, x_Max, y_Min, y_Max, Aspect_Ratio);
    end plvpas;


    -- Creates a viewport with the specified normalized subpage coordinates.
    procedure plvpor
       (Left_Edge   : Long_Float := 0.0;
        Right_Edge  : Long_Float := 1.0;
        Bottom_Edge : Long_Float := 0.0;
        Top_Edge    : Long_Float := 1.0) is
    begin
        PLplot_Thin.plvpor(Left_Edge, Right_Edge, Bottom_Edge, Top_Edge);
    end plvpor;


    -- Defines a "standard" viewport with seven character heights for
    -- the left margin and four character heights everywhere else.
    procedure plvsta is
    begin
        PLplot_Thin.plvsta;
    end plvsta;


    -- Set up a window for three-dimensional plotting.
    procedure plw3d
       (X_Box, Y_Box, Z_Box                      : Long_Float; -- Extents of enclosing box; world coordinates
        X_Min, X_Max, Y_Min, Y_Max, Z_Min, Z_Max : Long_Float; -- Data limits; user coordinates
        Altitude, Azimuth                        : Long_Float) is -- Viewing angles in world coordinates
    begin
        PLplot_Thin.plw3d(X_Box, Y_Box, Z_Box, X_Min, X_Max, Y_Min, Y_Max, Z_Min, Z_Max, Altitude, Azimuth);
    end plw3d;


    -- Set pen width.
    procedure plwidth(Pen_Width : Long_Float) is
    begin
        PLplot_Thin.plwidth(Pen_Width);
    end plwidth;


    -- Set up world coordinates of the viewport boundaries (2d plots).
    procedure plwind
       (Left_Edge   : Long_Float;
        Right_Edge  : Long_Float;
        Bottom_Edge : Long_Float;
        Top_Edge    : Long_Float) is
    begin
        PLplot_Thin.plwind(Left_Edge, Right_Edge, Bottom_Edge, Top_Edge);
    end plwind;


    -- set xor mode; mode = 1-enter, 0-leave, status = 0 if not interactive device 
    procedure plxormod
       (Use_XOR : Boolean;
        Supports_XOR : out Boolean) is
        
        PL_Use_XOR, PL_Supports_XOR : PLBOOL;
        
    begin
        if Use_XOR then
            PL_Use_XOR := PLtrue;
        else
            PL_Use_XOR := PLfalse;
        end if;
        
        PLplot_Thin.plxormod(PL_Use_XOR, PL_Supports_XOR);
        
        if PL_Supports_XOR = PLtrue then
            Supports_XOR := True;
        elsif PL_Supports_XOR = PLfalse then
            Supports_XOR := False;
        else
            Put_Line("Invalid driver status returned from PLplot in Set_XOR_Mode.");
        end if;
    end plxormod;


--------------------------------------------------------------------------------
--         Functions for use from C or C++ only                               --
--         (Not really ;).                                                    --
--------------------------------------------------------------------------------
--  THESE FUNCTIONS ^^^ ARE NOT IMPLEMENTED FOR THE ADA BINDING
--  EXCEPT FOR THE FOLLOWING.

    -- This procedure is currently GNAT-specific, importing Gnat_Argc and Gnat_Argv.
    -- Process options list using current options info.
    procedure plparseopts(Mode : Parse_Mode_Type) is

        Gnat_Argc : aliased Integer;
        pragma Import (C, Gnat_Argc);

        Gnat_Argv : System.Address;
        pragma Import (C, Gnat_Argv);

        type Gnat_Argc_Access_Type is access all Integer;
        Gnat_Argc_Access : Gnat_Argc_Access_Type;

        procedure
        plparseopts_local(argc : Gnat_Argc_Access_Type;
                          argv : System.Address;
                          mode : Parse_Mode_Type);
        pragma Import(C, plparseopts_local, "c_plparseopts");

    begin
        Gnat_Argc_Access := Gnat_Argc'access;
        plparseopts_local(Gnat_Argc_Access, Gnat_Argv, Mode);
    end plparseopts;


    -- Process input strings, treating them as an option and argument pair.
    procedure plsetopt(Option, Argument : String) is
    begin
        PLplot_Thin.plsetopt(To_C(Option, True), To_C(Argument, True));
    end plsetopt;


	-- Transformation routines

    -- fix this These functions are redundant with those in plplot_thin.
    -- This might be OK since they are now available at all levels of binding. 
    -- I wonder if this is approaching "wrapper bloat" since these procedures 
    -- get called a lot of times during the making of a contour plot. 
    -- The way to eliminate one level of calling would be to move the bodies 
    -- of pltr? from plplot_thin.adb into plplot_traditional.adb and 
    -- plplot.adb, then optionally eliminating the bodies from plplot_thin.adb 
    -- on the idea that nobody is going to use them anyway. But even if the 
    -- bodies were left in plplot_thin.adb, having them here would still 
    -- remove the extra call level. The argument for the currend arrangement is 
    -- easier code maintainence.

    -- Identity transformation.
    procedure pltr0
       (x_Grid, y_Grid   : Long_Float;
        x_World, y_World : out Long_Float;
        Data             : PLpointer) is
    begin
        PLplot_Thin.pltr0(x_Grid, y_Grid, x_World, y_World, Data);
    end pltr0;
        

    -- Does linear interpolation from singly dimensioned coord arrays.
    procedure pltr1
       (x_Grid, y_Grid   : Long_Float;
        x_World, y_World : out Long_Float;
        Data_Pointer     : PLpointer) is
    begin
        PLplot_Thin.pltr1(x_Grid, y_Grid, x_World, y_World, Data_Pointer);
    end pltr1;


    -- Does linear interpolation from doubly dimensioned coord arrays
    -- (column dominant, as per normal C 2d arrays).
    procedure pltr2
       (x_Grid, y_Grid   : Long_Float;
        x_World, y_World : out Long_Float;
        Data_Pointer     : PLpointer) is
    begin
        PLplot_Thin.pltr2(x_Grid, y_Grid, x_World, y_World, Data_Pointer);
    end pltr2;
        

    -- Wait for graphics input event and translate to world coordinates.
    procedure plGetCursor(Graphics_Input : out PLGraphicsIn) is
    begin
        PLplot_Thin.plGetCursor(Graphics_Input);
    end plGetCursor;

begin -- package body for PLplot

    -- NOTE: One would ordinarily call the initialization procedure at this point.
    -- However, PLplot has several optional procedures that, if used, must be
    -- called _before_ the initializaiton, here called Initialize_PLplot (plinit).
    -- Therefore, Initialize_PLplot (plinit) MUST BE CALLED FROM THE USER'S PROGRAM, 
    -- before beginning normal plotting but AFTER any optional pre-initialization.

    -- The following lines marked by ========= are some examples of how the 
    -- entire initialzation can be done here if the user wants to do so, and is 
    -- willing to uncomment these lines and/or add new lines.

    -- =========================================================================
    -- Set_Compression_Level (plscompression) should be called before 
    -- Initialize_PLplot (plinit) when it is needed.
    -- There should be a list of devices which use compression, and
    -- Set_Compression_Level (plscompression) called conditioned on the current 
    -- device being in that list.
    
    -- Optionally call Set_Command_Line_Option (plsetopt) before Initialize_PLplot
    -- (plinit).
    
    -- Parse_Command_Line_Arguments(1);
    -- Set_File_Family_Parameters(False); -- (plsfam(False)). Default off; 
    -- other args are don't-cares here.
    -- Set_Orientation(Landscape); -- (plsori(Landscape)). Optional; before
    -- Initialize_PLplot if used.

    -- Initialize_PLplot;
    -- =========================================================================


    -- Capture the initial, default, settings of color map 0 since these will be  
    -- lost if the settings for color map 0 are set by the user. They can be 
    -- restored collectively by calling Restore_Default_Snapshot_Of_Color_Map_0 
    -- or individually by calling functions such as Reset_Red etc. for each of 
    -- the 16 default colors of color map 0.
    Make_Snapshot_Of_Color_Map_0(Default_Red_Components, Default_Green_Components, Default_Blue_Components);

end PLplot_Traditional;