File: graphics-Ex.Rout.save

package info (click to toggle)
r-base 3.1.1-1
  • links: PTS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 85,396 kB
  • sloc: ansic: 306,777; fortran: 91,908; sh: 11,216; makefile: 5,311; yacc: 4,994; tcl: 4,562; objc: 746; perl: 655; asm: 553; java: 31; sed: 6
file content (2989 lines) | stat: -rw-r--r-- 90,226 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

R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: x86_64-unknown-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> pkgname <- "graphics"
> source(file.path(R.home("share"), "R", "examples-header.R"))
> options(warn = 1)
> library('graphics')
> 
> base::assign(".oldSearch", base::search(), pos = 'CheckExEnv')
> cleanEx()
> nameEx("abline")
> ### * abline
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: abline
> ### Title: Add Straight Lines to a Plot
> ### Aliases: abline
> ### Keywords: aplot
> 
> ### ** Examples
> 
> ## Setup up coordinate system (with x == y aspect ratio):
> plot(c(-2,3), c(-1,5), type = "n", xlab = "x", ylab = "y", asp = 1)
> ## the x- and y-axis, and an integer grid
> abline(h = 0, v = 0, col = "gray60")
> text(1,0, "abline( h = 0 )", col = "gray60", adj = c(0, -.1))
> abline(h = -1:5, v = -2:3, col = "lightgray", lty = 3)
> abline(a = 1, b = 2, col = 2)
> text(1,3, "abline( 1, 2 )", col = 2, adj = c(-.1, -.1))
> 
> ## Simple Regression Lines:
> require(stats)
> sale5 <- c(6, 4, 9, 7, 6, 12, 8, 10, 9, 13)
> plot(sale5)
> abline(lsfit(1:10, sale5))
> abline(lsfit(1:10, sale5, intercept = FALSE), col = 4) # less fitting
> 
> z <- lm(dist ~ speed, data = cars)
> plot(cars)
> abline(z) # equivalent to abline(reg = z) or
> abline(coef = coef(z))
> 
> ## trivial intercept model
> abline(mC <- lm(dist ~ 1, data = cars)) ## the same as
> abline(a = coef(mC), b = 0, col = "blue")
> 
> 
> 
> cleanEx()
> nameEx("arrows")
> ### * arrows
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: arrows
> ### Title: Add Arrows to a Plot
> ### Aliases: arrows
> ### Keywords: aplot
> 
> ### ** Examples
> 
> x <- stats::runif(12); y <- stats::rnorm(12)
> i <- order(x, y); x <- x[i]; y <- y[i]
> plot(x,y, main = "arrows(.) and segments(.)")
> ## draw arrows from point to point :
> s <- seq(length(x)-1)  # one shorter than data
> arrows(x[s], y[s], x[s+1], y[s+1], col = 1:3)
> s <- s[-length(s)]
> segments(x[s], y[s], x[s+2], y[s+2], col = "pink")
> 
> 
> 
> cleanEx()
> nameEx("assocplot")
> ### * assocplot
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: assocplot
> ### Title: Association Plots
> ### Aliases: assocplot
> ### Keywords: hplot
> 
> ### ** Examples
> 
> ## Aggregate over sex:
> x <- margin.table(HairEyeColor, c(1, 2))
> x
       Eye
Hair    Brown Blue Hazel Green
  Black    68   20    15     5
  Brown   119   84    54    29
  Red      26   17    14    14
  Blond     7   94    10    16
> assocplot(x, main = "Relation between hair and eye color")
> 
> 
> 
> cleanEx()
> nameEx("axTicks")
> ### * axTicks
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: axTicks
> ### Title: Compute Axis Tickmark Locations
> ### Aliases: axTicks
> ### Keywords: dplot
> 
> ### ** Examples
> 
>  plot(1:7, 10*21:27)
>  axTicks(1)
[1] 1 2 3 4 5 6 7
>  axTicks(2)
[1] 210 220 230 240 250 260 270
>  stopifnot(identical(axTicks(1), axTicks(3)),
+            identical(axTicks(2), axTicks(4)))
> 
> ## Show how axTicks() and axis() correspond :
> op <- par(mfrow = c(3, 1))
> for(x in 9999 * c(1, 2, 8)) {
+     plot(x, 9, log = "x")
+     cat(formatC(par("xaxp"), width = 5),";", T <- axTicks(1),"\n")
+     rug(T, col =  adjustcolor("red", 0.5), lwd = 4)
+ }
 1000 1e+05     3 ; 200 500 1000 2000 5000 10000 20000 50000 1e+05 2e+05 5e+05 
 1000 1e+06     2 ; 500 1000 5000 10000 50000 1e+05 5e+05 1e+06 
 1000 1e+07     1 ; 1000 10000 1e+05 1e+06 1e+07 
> par(op)
> 
> x <- 9.9*10^(-3:10)
> plot(x, 1:14, log = "x")
> axTicks(1) # now length 5, in R <= 2.13.x gave the following
[1] 1e-02 1e+01 1e+04 1e+07 1e+10
> axTicks(1, nintLog = Inf) # rather too many
 [1] 1e-02 1e-01 1e+00 1e+01 1e+02 1e+03 1e+04 1e+05 1e+06 1e+07 1e+08 1e+09
[13] 1e+10 1e+11
> 
> ## An example using axTicks() without reference to an existing plot
> ## (copying R's internal procedures for setting axis ranges etc.),
> ## You do need to supply _all_ of axp, usr, log, nintLog
> ## standard logarithmic y axis labels
> ylims <- c(0.2, 88)
> get_axp <- function(x) 10^c(ceiling(x[1]), floor(x[2]))
> ## mimic par("yaxs") == "i"
> usr.i <- log10(ylims)
> (aT.i <- axTicks(side = 2, usr = usr.i,
+                  axp = c(get_axp(usr.i), n = 3), log = TRUE, nintLog = 5))
[1]  0.2  0.5  1.0  2.0  5.0 10.0 20.0 50.0
> ## mimic (default) par("yaxs") == "r"
> usr.r <- extendrange(r = log10(ylims), f = 0.04)
> (aT.r <- axTicks(side = 2, usr = usr.r,
+                  axp = c(get_axp(usr.r), 3), log = TRUE, nintLog = 5))
[1]   0.2   0.5   1.0   2.0   5.0  10.0  20.0  50.0 100.0
> 
> ## Prove that we got it right :
> plot(0:1, ylims, log = "y", yaxs = "i")
> stopifnot(all.equal(aT.i, axTicks(side = 2)))
> 
> plot(0:1, ylims, log = "y", yaxs = "r")
> stopifnot(all.equal(aT.r, axTicks(side = 2)))
> 
> 
> 
> graphics::par(get("par.postscript", pos = 'CheckExEnv'))
> cleanEx()
> nameEx("axis.POSIXct")
> ### * axis.POSIXct
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: axis.POSIXct
> ### Title: Date and Date-time Plotting Functions
> ### Aliases: axis.POSIXct axis.Date
> ### Keywords: utilities chron
> 
> ### ** Examples
> 
> with(beaver1, {
+ time <- strptime(paste(1990, day, time %/% 100, time %% 100),
+                  "%Y %j %H %M")
+ plot(time, temp, type = "l") # axis at 4-hour intervals.
+ # now label every hour on the time axis
+ plot(time, temp, type = "l", xaxt = "n")
+ r <- as.POSIXct(round(range(time), "hours"))
+ axis.POSIXct(1, at = seq(r[1], r[2], by = "hour"), format = "%H")
+ })
> 
> plot(.leap.seconds, seq_along(.leap.seconds), type = "n", yaxt = "n",
+      xlab = "leap seconds", ylab = "", bty = "n")
> rug(.leap.seconds)
> ## or as dates
> lps <- as.Date(.leap.seconds)
> plot(lps, seq_along(.leap.seconds),
+      type = "n", yaxt = "n", xlab = "leap seconds",
+      ylab = "", bty = "n")
> rug(lps)
> 
> ## 100 random dates in a 10-week period
> random.dates <- as.Date("2001/1/1") + 70*sort(stats::runif(100))
> plot(random.dates, 1:100)
> # or for a better axis labelling
> plot(random.dates, 1:100, xaxt = "n")
> axis.Date(1, at = seq(as.Date("2001/1/1"), max(random.dates)+6, "weeks"))
> axis.Date(1, at = seq(as.Date("2001/1/1"), max(random.dates)+6, "days"),
+      labels = FALSE, tcl = -0.2)
> 
> 
> 
> cleanEx()
> nameEx("axis")
> ### * axis
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: axis
> ### Title: Add an Axis to a Plot
> ### Aliases: axis
> ### Keywords: aplot
> 
> ### ** Examples
> 
> require(stats) # for rnorm
> plot(1:4, rnorm(4), axes = FALSE)
> axis(1, 1:4, LETTERS[1:4])
> axis(2)
> box() #- to make it look "as usual"
> 
> plot(1:7, rnorm(7), main = "axis() examples",
+      type = "s", xaxt = "n", frame = FALSE, col = "red")
> axis(1, 1:7, LETTERS[1:7], col.axis = "blue")
> # unusual options:
> axis(4, col = "violet", col.axis = "dark violet", lwd = 2)
> axis(3, col = "gold", lty = 2, lwd = 0.5)
> 
> # one way to have a custom x axis
> plot(1:10, xaxt = "n")
> axis(1, xaxp = c(2, 9, 7))
> 
> 
> 
> cleanEx()
> nameEx("barplot")
> ### * barplot
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: barplot
> ### Title: Bar Plots
> ### Aliases: barplot barplot.default
> ### Keywords: hplot
> 
> ### ** Examples
> 
> require(grDevices) # for colours
> tN <- table(Ni <- stats::rpois(100, lambda = 5))
> r <- barplot(tN, col = rainbow(20))
> #- type = "h" plotting *is* 'bar'plot
> lines(r, tN, type = "h", col = "red", lwd = 2)
> 
> barplot(tN, space = 1.5, axisnames = FALSE,
+         sub = "barplot(..., space= 1.5, axisnames = FALSE)")
> 
> barplot(VADeaths, plot = FALSE)
[1] 0.7 1.9 3.1 4.3
> barplot(VADeaths, plot = FALSE, beside = TRUE)
     [,1] [,2] [,3] [,4]
[1,]  1.5  7.5 13.5 19.5
[2,]  2.5  8.5 14.5 20.5
[3,]  3.5  9.5 15.5 21.5
[4,]  4.5 10.5 16.5 22.5
[5,]  5.5 11.5 17.5 23.5
> 
> mp <- barplot(VADeaths) # default
> tot <- colMeans(VADeaths)
> text(mp, tot + 3, format(tot), xpd = TRUE, col = "blue")
> barplot(VADeaths, beside = TRUE,
+         col = c("lightblue", "mistyrose", "lightcyan",
+                 "lavender", "cornsilk"),
+         legend = rownames(VADeaths), ylim = c(0, 100))
> title(main = "Death Rates in Virginia", font.main = 4)
> 
> hh <- t(VADeaths)[, 5:1]
> mybarcol <- "gray20"
> mp <- barplot(hh, beside = TRUE,
+         col = c("lightblue", "mistyrose",
+                 "lightcyan", "lavender"),
+         legend = colnames(VADeaths), ylim = c(0,100),
+         main = "Death Rates in Virginia", font.main = 4,
+         sub = "Faked upper 2*sigma error bars", col.sub = mybarcol,
+         cex.names = 1.5)
> segments(mp, hh, mp, hh + 2*sqrt(1000*hh/100), col = mybarcol, lwd = 1.5)
> stopifnot(dim(mp) == dim(hh))  # corresponding matrices
> mtext(side = 1, at = colMeans(mp), line = -2,
+       text = paste("Mean", formatC(colMeans(hh))), col = "red")
> 
> # Bar shading example
> barplot(VADeaths, angle = 15+10*1:5, density = 20, col = "black",
+         legend = rownames(VADeaths))
> title(main = list("Death Rates in Virginia", font = 4))
> 
> # border :
> barplot(VADeaths, border = "dark blue") 
> 
> # log scales (not much sense here):
> barplot(tN, col = heat.colors(12), log = "y")
> barplot(tN, col = gray.colors(20), log = "xy")
> 
> # args.legend
> barplot(height = cbind(x = c(465, 91) / 465 * 100,
+                        y = c(840, 200) / 840 * 100,
+                        z = c(37, 17) / 37 * 100),
+         beside = FALSE,
+         width = c(465, 840, 37),
+         col = c(1, 2),
+         legend.text = c("A", "B"),
+         args.legend = list(x = "topleft"))
> 
> 
> 
> cleanEx()
> nameEx("box")
> ### * box
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: box
> ### Title: Draw a Box around a Plot
> ### Aliases: box
> ### Keywords: aplot
> 
> ### ** Examples
> 
> plot(1:7, abs(stats::rnorm(7)), type = "h", axes = FALSE)
> axis(1, at = 1:7, labels = letters[1:7])
> box(lty = '1373', col = 'red')
> 
> 
> 
> cleanEx()
> nameEx("boxplot")
> ### * boxplot
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: boxplot
> ### Title: Box Plots
> ### Aliases: boxplot boxplot.default boxplot.formula
> ### Keywords: hplot
> 
> ### ** Examples
> 
> ## boxplot on a formula:
> boxplot(count ~ spray, data = InsectSprays, col = "lightgray")
> # *add* notches (somewhat funny here):
> boxplot(count ~ spray, data = InsectSprays,
+         notch = TRUE, add = TRUE, col = "blue")
Warning in bxp(list(stats = c(7, 11, 14, 18.5, 23, 7, 12, 16.5, 18, 21,  :
  some notches went outside hinges ('box'): maybe set notch=FALSE
> 
> boxplot(decrease ~ treatment, data = OrchardSprays,
+         log = "y", col = "bisque")
> 
> rb <- boxplot(decrease ~ treatment, data = OrchardSprays, col = "bisque")
> title("Comparing boxplot()s and non-robust mean +/- SD")
> 
> mn.t <- tapply(OrchardSprays$decrease, OrchardSprays$treatment, mean)
> sd.t <- tapply(OrchardSprays$decrease, OrchardSprays$treatment, sd)
> xi <- 0.3 + seq(rb$n)
> points(xi, mn.t, col = "orange", pch = 18)
> arrows(xi, mn.t - sd.t, xi, mn.t + sd.t,
+        code = 3, col = "pink", angle = 75, length = .1)
> 
> ## boxplot on a matrix:
> mat <- cbind(Uni05 = (1:100)/21, Norm = rnorm(100),
+              `5T` = rt(100, df = 5), Gam2 = rgamma(100, shape = 2))
> boxplot(as.data.frame(mat),
+         main = "boxplot(as.data.frame(mat), main = ...)")
> par(las = 1) # all axis labels horizontal
> boxplot(as.data.frame(mat), main = "boxplot(*, horizontal = TRUE)",
+         horizontal = TRUE)
> 
> ## Using 'at = ' and adding boxplots -- example idea by Roger Bivand :
> 
> boxplot(len ~ dose, data = ToothGrowth,
+         boxwex = 0.25, at = 1:3 - 0.2,
+         subset = supp == "VC", col = "yellow",
+         main = "Guinea Pigs' Tooth Growth",
+         xlab = "Vitamin C dose mg",
+         ylab = "tooth length",
+         xlim = c(0.5, 3.5), ylim = c(0, 35), yaxs = "i")
> boxplot(len ~ dose, data = ToothGrowth, add = TRUE,
+         boxwex = 0.25, at = 1:3 + 0.2,
+         subset = supp == "OJ", col = "orange")
> legend(2, 9, c("Ascorbic acid", "Orange juice"),
+        fill = c("yellow", "orange"))
> 
> ## more examples in  help(bxp)
> 
> 
> 
> graphics::par(get("par.postscript", pos = 'CheckExEnv'))
> cleanEx()
> nameEx("boxplot.matrix")
> ### * boxplot.matrix
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: boxplot.matrix
> ### Title: Draw a Boxplot for each Column (Row) of a Matrix
> ### Aliases: boxplot.matrix
> ### Keywords: hplot
> 
> ### ** Examples
> 
> ## Very similar to the example in ?boxplot
> mat <- cbind(Uni05 = (1:100)/21, Norm = rnorm(100),
+              T5 = rt(100, df = 5), Gam2 = rgamma(100, shape = 2))
> boxplot(mat, main = "boxplot.matrix(...., main = ...)",
+         notch = TRUE, col = 1:4)
> 
> 
> 
> cleanEx()
> nameEx("bxp")
> ### * bxp
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: bxp
> ### Title: Draw Box Plots from Summaries
> ### Aliases: bxp
> ### Keywords: aplot
> 
> ### ** Examples
> 
> require(stats)
> set.seed(753)
> (bx.p <- boxplot(split(rt(100, 4), gl(5, 20))))
$stats
            [,1]        [,2]        [,3]        [,4]        [,5]
[1,] -1.66391873 -2.02625162 -2.12785004 -2.76510496 -1.70034047
[2,] -0.55308292 -0.65897584 -0.86705616 -1.63431484 -0.81848966
[3,] -0.06763313  0.04887846  0.09674026 -0.06712275 -0.01150075
[4,]  0.68813940  0.91705734  1.05562526  0.56746581  0.49017934
[5,]  1.14222667  3.16270157  2.07574986  2.09523462  1.87734641

$n
[1] 20 20 20 20 20

$conf
           [,1]       [,2]       [,3]       [,4]       [,5]
[1,] -0.5061554 -0.5079321 -0.5825407 -0.8450091 -0.4738519
[2,]  0.3708891  0.6056890  0.7760212  0.7107636  0.4508504

$out
[1]  4.115274  3.224584  3.920438  4.168341 -4.357819  2.498006

$group
[1] 1 1 1 4 5 5

$names
[1] "1" "2" "3" "4" "5"

> op <- par(mfrow =  c(2, 2))
> bxp(bx.p, xaxt = "n")
> bxp(bx.p, notch = TRUE, axes = FALSE, pch = 4, boxfill = 1:5)
Warning in bxp(bx.p, notch = TRUE, axes = FALSE, pch = 4, boxfill = 1:5) :
  some notches went outside hinges ('box'): maybe set notch=FALSE
> bxp(bx.p, notch = TRUE, boxfill = "lightblue", frame = FALSE,
+     outl = FALSE, main = "bxp(*, frame= FALSE, outl= FALSE)")
Warning in bxp(bx.p, notch = TRUE, boxfill = "lightblue", frame = FALSE,  :
  some notches went outside hinges ('box'): maybe set notch=FALSE
> bxp(bx.p, notch = TRUE, boxfill = "lightblue", border = 2:6,
+     ylim = c(-4,4), pch = 22, bg = "green", log = "x",
+     main = "... log = 'x', ylim = *")
Warning in bxp(bx.p, notch = TRUE, boxfill = "lightblue", border = 2:6,  :
  some notches went outside hinges ('box'): maybe set notch=FALSE
> par(op)
> op <- par(mfrow = c(1, 2))
> 
> ## single group -- no label
> boxplot (weight ~ group, data = PlantGrowth, subset = group == "ctrl")
> ## with label
> bx <- boxplot(weight ~ group, data = PlantGrowth,
+               subset = group == "ctrl", plot = FALSE)
> bxp(bx, show.names=TRUE)
> par(op)
> 
> z <- split(rnorm(1000), rpois(1000, 2.2))
> boxplot(z, whisklty = 3, main = "boxplot(z, whisklty = 3)")
> 
> ## Colour support similar to plot.default:
> op <- par(mfrow = 1:2, bg = "light gray", fg = "midnight blue")
> boxplot(z,   col.axis = "skyblue3", main = "boxplot(*, col.axis=..,main=..)")
> plot(z[[1]], col.axis = "skyblue3", main =    "plot(*, col.axis=..,main=..)")
> mtext("par(bg=\"light gray\", fg=\"midnight blue\")",
+       outer = TRUE, line = -1.2)
> par(op)
> 
> ## Mimic S-Plus:
> splus <- list(boxwex = 0.4, staplewex = 1, outwex = 1, boxfill = "grey40",
+               medlwd = 3, medcol = "white", whisklty = 3, outlty = 1, outpch = NA)
> boxplot(z, pars = splus)
> ## Recycled and "sweeping" parameters
> op <- par(mfrow = c(1,2))
>  boxplot(z, border = 1:5, lty = 3, medlty = 1, medlwd = 2.5)
>  boxplot(z, boxfill = 1:3, pch = 1:5, lwd = 1.5, medcol = "white")
> par(op)
> ## too many possibilities
> boxplot(z, boxfill = "light gray", outpch = 21:25, outlty = 2,
+         bg = "pink", lwd = 2,
+         medcol = "dark blue", medcex = 2, medpch = 20)
> 
> 
> 
> graphics::par(get("par.postscript", pos = 'CheckExEnv'))
> cleanEx()
> nameEx("cdplot")
> ### * cdplot
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: cdplot
> ### Title: Conditional Density Plots
> ### Aliases: cdplot cdplot.default cdplot.formula
> ### Keywords: hplot
> 
> ### ** Examples
> 
> ## NASA space shuttle o-ring failures
> fail <- factor(c(2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1,
+                  1, 2, 1, 1, 1, 1, 1),
+                levels = 1:2, labels = c("no", "yes"))
> temperature <- c(53, 57, 58, 63, 66, 67, 67, 67, 68, 69, 70, 70,
+                  70, 70, 72, 73, 75, 75, 76, 76, 78, 79, 81)
> 
> ## CD plot
> cdplot(fail ~ temperature)
> cdplot(fail ~ temperature, bw = 2)
> cdplot(fail ~ temperature, bw = "SJ")
> 
> ## compare with spinogram
> (spineplot(fail ~ temperature, breaks = 3))
           fail
temperature no yes
    [50,60]  0   3
    (60,70]  8   3
    (70,80]  7   1
    (80,90]  1   0
> 
> ## highlighting for failures
> cdplot(fail ~ temperature, ylevels = 2:1)
> 
> ## scatter plot with conditional density
> cdens <- cdplot(fail ~ temperature, plot = FALSE)
> plot(I(as.numeric(fail) - 1) ~ jitter(temperature, factor = 2),
+      xlab = "Temperature", ylab = "Conditional failure probability")
> lines(53:81, 1 - cdens[[1]](53:81), col = 2)
> 
> 
> 
> cleanEx()
> nameEx("clip")
> ### * clip
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: clip
> ### Title: Set Clipping Region
> ### Aliases: clip
> ### Keywords: dplot
> 
> ### ** Examples
> 
> x <- rnorm(1000)
> hist(x, xlim = c(-4,4))
> usr <- par("usr")
> clip(usr[1], -2, usr[3], usr[4])
> hist(x, col = 'red', add = TRUE)
> clip(2, usr[2], usr[3], usr[4])
> hist(x, col = 'blue', add = TRUE)
> do.call("clip", as.list(usr))  # reset to plot region
> 
> 
> 
> graphics::par(get("par.postscript", pos = 'CheckExEnv'))
> cleanEx()
> nameEx("contour")
> ### * contour
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: contour
> ### Title: Display Contours
> ### Aliases: contour contour.default
> ### Keywords: hplot aplot
> 
> ### ** Examples
> 
> require(grDevices) # for colours
> x <- -6:16
> op <- par(mfrow = c(2, 2))
> contour(outer(x, x), method = "edge", vfont = c("sans serif", "plain"))
> z <- outer(x, sqrt(abs(x)), FUN = "/")
> image(x, x, z)
> contour(x, x, z, col = "pink", add = TRUE, method = "edge",
+         vfont = c("sans serif", "plain"))
> contour(x, x, z, ylim = c(1, 6), method = "simple", labcex = 1,
+         xlab = quote(x[1]), ylab = quote(x[2]))
> contour(x, x, z, ylim = c(-6, 6), nlev = 20, lty = 2, method = "simple",
+         main = "20 levels; \"simple\" labelling method")
> par(op)
> 
> ## Persian Rug Art:
> x <- y <- seq(-4*pi, 4*pi, len = 27)
> r <- sqrt(outer(x^2, y^2, "+"))
> opar <- par(mfrow = c(2, 2), mar = rep(0, 4))
> for(f in pi^(0:3))
+   contour(cos(r^2)*exp(-r/f),
+           drawlabels = FALSE, axes = FALSE, frame = TRUE)
> 
> rx <- range(x <- 10*1:nrow(volcano))
> ry <- range(y <- 10*1:ncol(volcano))
> ry <- ry + c(-1, 1) * (diff(rx) - diff(ry))/2
> tcol <- terrain.colors(12)
> par(opar); opar <- par(pty = "s", bg = "lightcyan")
> plot(x = 0, y = 0, type = "n", xlim = rx, ylim = ry, xlab = "", ylab = "")
> u <- par("usr")
> rect(u[1], u[3], u[2], u[4], col = tcol[8], border = "red")
> contour(x, y, volcano, col = tcol[2], lty = "solid", add = TRUE,
+         vfont = c("sans serif", "plain"))
> title("A Topographic Map of Maunga Whau", font = 4)
> abline(h = 200*0:4, v = 200*0:4, col = "lightgray", lty = 2, lwd = 0.1)
> 
> ## contourLines produces the same contour lines as contour
> plot(x = 0, y = 0, type = "n", xlim = rx, ylim = ry, xlab = "", ylab = "")
> u <- par("usr")
> rect(u[1], u[3], u[2], u[4], col = tcol[8], border = "red")
> contour(x, y, volcano, col = tcol[1], lty = "solid", add = TRUE,
+         vfont = c("sans serif", "plain"))
> line.list <- contourLines(x, y, volcano)
> invisible(lapply(line.list, lines, lwd=3, col=adjustcolor(2, .3)))
> par(opar)
> 
> 
> 
> graphics::par(get("par.postscript", pos = 'CheckExEnv'))
> cleanEx()
> nameEx("convertXY")
> ### * convertXY
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: convertXY
> ### Title: Convert between Graphics Coordinate Systems
> ### Aliases: grconvertX grconvertY
> ### Keywords: dplot
> 
> ### ** Examples
> 
> op <- par(omd=c(0.1, 0.9, 0.1, 0.9), mfrow = c(1, 2))
> plot(1:4)
> for(tp in c("in", "dev", "ndc", "nfc", "npc", "nic"))
+     print(grconvertX(c(1.0, 4.0), "user", tp))
[1] 1.577778 3.022222
[1] 113.6 217.6
[1] 0.2253968 0.4317460
[1] 0.3134921 0.8293651
[1] 0.03703704 0.96296296
[1] 0.1567460 0.4146825
> par(op)
> 
> 
> 
> graphics::par(get("par.postscript", pos = 'CheckExEnv'))
> cleanEx()
> nameEx("coplot")
> ### * coplot
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: coplot
> ### Title: Conditioning Plots
> ### Aliases: coplot co.intervals
> ### Keywords: hplot aplot
> 
> ### ** Examples
> 
> ## Tonga Trench Earthquakes
> coplot(lat ~ long | depth, data = quakes)
> given.depth <- co.intervals(quakes$depth, number = 4, overlap = .1)
> coplot(lat ~ long | depth, data = quakes, given.v = given.depth, rows = 1)
> 
> ## Conditioning on 2 variables:
> ll.dm <- lat ~ long | depth * mag
> coplot(ll.dm, data = quakes)
> coplot(ll.dm, data = quakes, number = c(4, 7), show.given = c(TRUE, FALSE))
> coplot(ll.dm, data = quakes, number = c(3, 7),
+        overlap = c(-.5, .1)) # negative overlap DROPS values
> 
> ## given two factors
> Index <- seq(length = nrow(warpbreaks)) # to get nicer default labels
> coplot(breaks ~ Index | wool * tension, data = warpbreaks,
+        show.given = 0:1)
> coplot(breaks ~ Index | wool * tension, data = warpbreaks,
+        col = "red", bg = "pink", pch = 21,
+        bar.bg = c(fac = "light blue"))
> 
> ## Example with empty panels:
> with(data.frame(state.x77), {
+ coplot(Life.Exp ~ Income | Illiteracy * state.region, number = 3,
+        panel = function(x, y, ...) panel.smooth(x, y, span = .8, ...))
+ ## y ~ factor -- not really sensible, but 'show off':
+ coplot(Life.Exp ~ state.region | Income * state.division,
+        panel = panel.smooth)
+ })
> 
> 
> 
> cleanEx()
> nameEx("curve")
> ### * curve
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: curve
> ### Title: Draw Function Plots
> ### Aliases: curve plot.function
> ### Keywords: hplot
> 
> ### ** Examples
> 
> plot(qnorm) # default range c(0, 1) is appropriate here,
>             # but end values are -/+Inf and so are omitted.
> plot(qlogis, main = "The Inverse Logit : qlogis()")
> abline(h = 0, v = 0:2/2, lty = 3, col = "gray")
> 
> curve(sin, -2*pi, 2*pi, xname = "t")
> curve(tan, xname = "t", add = NA,
+       main = "curve(tan)  --> same x-scale as previous plot")
> 
> op <- par(mfrow = c(2, 2))
> curve(x^3 - 3*x, -2, 2)
> curve(x^2 - 2, add = TRUE, col = "violet")
> 
> ## simple and advanced versions, quite similar:
> plot(cos, -pi,  3*pi)
> curve(cos, xlim = c(-pi, 3*pi), n = 1001, col = "blue", add = TRUE)
> 
> chippy <- function(x) sin(cos(x)*exp(-x/2))
> curve(chippy, -8, 7, n = 2001)
> plot (chippy, -8, -5)
> 
> for(ll in c("", "x", "y", "xy"))
+    curve(log(1+x), 1, 100, log = ll, sub = paste0("log = '", ll, "'"))
> par(op)
> 
> 
> 
> graphics::par(get("par.postscript", pos = 'CheckExEnv'))
> cleanEx()
> nameEx("dotchart")
> ### * dotchart
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: dotchart
> ### Title: Cleveland's Dot Plots
> ### Aliases: dotchart
> ### Keywords: hplot
> 
> ### ** Examples
> 
> dotchart(VADeaths, main = "Death Rates in Virginia - 1940")
> op <- par(xaxs = "i")  # 0 -- 100%
> dotchart(t(VADeaths), xlim = c(0,100),
+          main = "Death Rates in Virginia - 1940")
> par(op)
> 
> 
> 
> graphics::par(get("par.postscript", pos = 'CheckExEnv'))
> cleanEx()
> nameEx("filled.contour")
> ### * filled.contour
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: filled.contour
> ### Title: Level (Contour) Plots
> ### Aliases: filled.contour .filled.contour
> ### Keywords: hplot aplot
> 
> ### ** Examples
> 
> require(grDevices) # for colours
> filled.contour(volcano, color = terrain.colors, asp = 1) # simple
> 
> x <- 10*1:nrow(volcano)
> y <- 10*1:ncol(volcano)
> filled.contour(x, y, volcano, color = terrain.colors,
+     plot.title = title(main = "The Topography of Maunga Whau",
+     xlab = "Meters North", ylab = "Meters West"),
+     plot.axes = { axis(1, seq(100, 800, by = 100))
+                   axis(2, seq(100, 600, by = 100)) },
+     key.title = title(main = "Height\n(meters)"),
+     key.axes = axis(4, seq(90, 190, by = 10)))  # maybe also asp = 1
> mtext(paste("filled.contour(.) from", R.version.string),
+       side = 1, line = 4, adj = 1, cex = .66)
> 
> # Annotating a filled contour plot
> a <- expand.grid(1:20, 1:20)
> b <- matrix(a[,1] + a[,2], 20)
> filled.contour(x = 1:20, y = 1:20, z = b,
+                plot.axes = { axis(1); axis(2); points(10, 10) })
> 
> ## Persian Rug Art:
> x <- y <- seq(-4*pi, 4*pi, len = 27)
> r <- sqrt(outer(x^2, y^2, "+"))
> filled.contour(cos(r^2)*exp(-r/(2*pi)), axes = FALSE)
> ## rather, the key *should* be labeled:
> filled.contour(cos(r^2)*exp(-r/(2*pi)), frame.plot = FALSE,
+                plot.axes = {})
> 
> 
> 
> cleanEx()
> nameEx("fourfoldplot")
> ### * fourfoldplot
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: fourfoldplot
> ### Title: Fourfold Plots
> ### Aliases: fourfoldplot
> ### Keywords: hplot
> 
> ### ** Examples
> 
> ## Use the Berkeley admission data as in Friendly (1995).
> x <- aperm(UCBAdmissions, c(2, 1, 3))
> dimnames(x)[[2]] <- c("Yes", "No")
> names(dimnames(x)) <- c("Sex", "Admit?", "Department")
> stats::ftable(x)
              Department   A   B   C   D   E   F
Sex    Admit?                                   
Male   Yes               512 353 120 138  53  22
       No                313 207 205 279 138 351
Female Yes                89  17 202 131  94  24
       No                 19   8 391 244 299 317
> 
> ## Fourfold display of data aggregated over departments, with
> ## frequencies standardized to equate the margins for admission
> ## and sex.
> ## Figure 1 in Friendly (1994).
> fourfoldplot(margin.table(x, c(1, 2)))
> 
> ## Fourfold display of x, with frequencies in each table
> ## standardized to equate the margins for admission and sex.
> ## Figure 2 in Friendly (1994).
> fourfoldplot(x)
> 
> ## Fourfold display of x, with frequencies in each table
> ## standardized to equate the margins for admission. but not
> ## for sex.
> ## Figure 3 in Friendly (1994).
> fourfoldplot(x, margin = 2)
> 
> 
> 
> cleanEx()
> nameEx("grid")
> ### * grid
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: grid
> ### Title: Add Grid to a Plot
> ### Aliases: grid
> ### Keywords: aplot
> 
> ### ** Examples
> 
> plot(1:3)
> grid(NA, 5, lwd = 2) # grid only in y-direction
> 
> ## maybe change the desired number of tick marks:  par(lab = c(mx, my, 7))
> op <- par(mfcol = 1:2)
> with(iris,
+      {
+      plot(Sepal.Length, Sepal.Width, col = as.integer(Species),
+           xlim = c(4, 8), ylim = c(2, 4.5), panel.first = grid(),
+           main = "with(iris,  plot(...., panel.first = grid(), ..) )")
+      plot(Sepal.Length, Sepal.Width, col = as.integer(Species),
+           panel.first = grid(3, lty = 1, lwd = 2),
+           main = "... panel.first = grid(3, lty = 1, lwd = 2), ..")
+      }
+     )
> par(op)
> 
> 
> 
> 
> graphics::par(get("par.postscript", pos = 'CheckExEnv'))
> cleanEx()
> nameEx("hist.POSIXt")
> ### * hist.POSIXt
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: hist.POSIXt
> ### Title: Histogram of a Date or Date-Time Object
> ### Aliases: hist.POSIXt hist.Date
> ### Keywords: chron dplot hplot
> 
> ### ** Examples
> 
> hist(.leap.seconds, "years", freq = TRUE)
> hist(.leap.seconds,
+      seq(ISOdate(1970, 1, 1), ISOdate(2015, 1, 1), "5 years"))
> 
> ## 100 random dates in a 10-week period
> random.dates <- as.Date("2001/1/1") + 70*stats::runif(100)
> hist(random.dates, "weeks", format = "%d %b")
> 
> 
> 
> cleanEx()
> nameEx("hist")
> ### * hist
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: hist
> ### Title: Histograms
> ### Aliases: hist hist.default
> ### Keywords: dplot hplot distribution
> 
> ### ** Examples
> 
> op <- par(mfrow = c(2, 2))
> hist(islands)
> utils::str(hist(islands, col = "gray", labels = TRUE))
List of 6
 $ breaks  : num [1:10] 0 2000 4000 6000 8000 10000 12000 14000 16000 18000
 $ counts  : int [1:9] 41 2 1 1 1 1 0 0 1
 $ density : num [1:9] 4.27e-04 2.08e-05 1.04e-05 1.04e-05 1.04e-05 ...
 $ mids    : num [1:9] 1000 3000 5000 7000 9000 11000 13000 15000 17000
 $ xname   : chr "islands"
 $ equidist: logi TRUE
 - attr(*, "class")= chr "histogram"
> 
> hist(sqrt(islands), breaks = 12, col = "lightblue", border = "pink")
> ##-- For non-equidistant breaks, counts should NOT be graphed unscaled:
> r <- hist(sqrt(islands), breaks = c(4*0:5, 10*3:5, 70, 100, 140),
+           col = "blue1")
> text(r$mids, r$density, r$counts, adj = c(.5, -.5), col = "blue3")
> sapply(r[2:3], sum)
   counts   density 
48.000000  0.215625 
> sum(r$density * diff(r$breaks)) # == 1
[1] 1
> lines(r, lty = 3, border = "purple") # -> lines.histogram(*)
> par(op)
> 
> require(utils) # for str
> str(hist(islands, breaks = 12, plot =  FALSE)) #-> 10 (~= 12) breaks
List of 6
 $ breaks  : num [1:10] 0 2000 4000 6000 8000 10000 12000 14000 16000 18000
 $ counts  : int [1:9] 41 2 1 1 1 1 0 0 1
 $ density : num [1:9] 4.27e-04 2.08e-05 1.04e-05 1.04e-05 1.04e-05 ...
 $ mids    : num [1:9] 1000 3000 5000 7000 9000 11000 13000 15000 17000
 $ xname   : chr "islands"
 $ equidist: logi TRUE
 - attr(*, "class")= chr "histogram"
> str(hist(islands, breaks = c(12,20,36,80,200,1000,17000), plot = FALSE))
List of 6
 $ breaks  : num [1:7] 12 20 36 80 200 1000 17000
 $ counts  : int [1:6] 12 11 8 6 4 7
 $ density : num [1:6] 0.03125 0.014323 0.003788 0.001042 0.000104 ...
 $ mids    : num [1:6] 16 28 58 140 600 9000
 $ xname   : chr "islands"
 $ equidist: logi FALSE
 - attr(*, "class")= chr "histogram"
> 
> hist(islands, breaks = c(12,20,36,80,200,1000,17000), freq = TRUE,
+      main = "WRONG histogram") # and warning
Warning in plot.histogram(r, freq = freq1, col = col, border = border, angle = angle,  :
  the AREAS in the plot are wrong -- rather use 'freq = FALSE'
> 
> require(stats)
> set.seed(14)
> x <- rchisq(100, df = 4)
> ## Don't show: 
> op <- par(mfrow = 2:1, mgp = c(1.5, 0.6, 0), mar = .1 + c(3,3:1))
> ## End Don't show
> ## Comparing data with a model distribution should be done with qqplot()!
> qqplot(x, qchisq(ppoints(x), df = 4)); abline(0, 1, col = 2, lty = 2)
> 
> ## if you really insist on using hist() ... :
> hist(x, freq = FALSE, ylim = c(0, 0.2))
> curve(dchisq(x, df = 4), col = 2, lty = 2, lwd = 2, add = TRUE)
> ## Don't show: 
> par(op)
> ## End Don't show
> 
> 
> 
> graphics::par(get("par.postscript", pos = 'CheckExEnv'))
> cleanEx()
> nameEx("identify")
> ### * identify
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: identify
> ### Title: Identify Points in a Scatter Plot
> ### Aliases: identify identify.default
> ### Keywords: iplot
> 
> ### ** Examples
> 
> ## A function to use identify to select points, and overplot the
> ## points with another symbol as they are selected
> identifyPch <- function(x, y = NULL, n = length(x), pch = 19, ...)
+ {
+     xy <- xy.coords(x, y); x <- xy$x; y <- xy$y
+     sel <- rep(FALSE, length(x)); res <- integer(0)
+     while(sum(sel) < n) {
+         ans <- identify(x[!sel], y[!sel], n = 1, plot = FALSE, ...)
+         if(!length(ans)) break
+         ans <- which(!sel)[ans]
+         points(x[ans], y[ans], pch = pch)
+         sel[ans] <- TRUE
+         res <- c(res, ans)
+     }
+     res
+ }
> 
> 
> 
> cleanEx()
> nameEx("image")
> ### * image
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: image
> ### Title: Display a Color Image
> ### Aliases: image image.default
> ### Keywords: hplot aplot
> 
> ### ** Examples
> 
> require(grDevices) # for colours
> x <- y <- seq(-4*pi, 4*pi, len = 27)
> r <- sqrt(outer(x^2, y^2, "+"))
> image(z = z <- cos(r^2)*exp(-r/6), col  = gray((0:32)/32))
> image(z, axes = FALSE, main = "Math can be beautiful ...",
+       xlab = expression(cos(r^2) * e^{-r/6}))
> contour(z, add = TRUE, drawlabels = FALSE)
> 
> # Volcano data visualized as matrix. Need to transpose and flip
> # matrix horizontally.
> image(t(volcano)[ncol(volcano):1,])
> 
> # A prettier display of the volcano
> x <- 10*(1:nrow(volcano))
> y <- 10*(1:ncol(volcano))
> image(x, y, volcano, col = terrain.colors(100), axes = FALSE)
> contour(x, y, volcano, levels = seq(90, 200, by = 5),
+         add = TRUE, col = "peru")
> axis(1, at = seq(100, 800, by = 100))
> axis(2, at = seq(100, 600, by = 100))
> box()
> title(main = "Maunga Whau Volcano", font.main = 4)
> 
> 
> 
> cleanEx()
> nameEx("layout")
> ### * layout
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: layout
> ### Title: Specifying Complex Plot Arrangements
> ### Aliases: layout layout.show lcm
> ### Keywords: iplot dplot environment
> 
> ### ** Examples
> 
> def.par <- par(no.readonly = TRUE) # save default, for resetting...
> 
> ## divide the device into two rows and two columns
> ## allocate figure 1 all of row 1
> ## allocate figure 2 the intersection of column 2 and row 2
> layout(matrix(c(1,1,0,2), 2, 2, byrow = TRUE))
> ## show the regions that have been allocated to each plot
> layout.show(2)
> 
> ## divide device into two rows and two columns
> ## allocate figure 1 and figure 2 as above
> ## respect relations between widths and heights
> nf <- layout(matrix(c(1,1,0,2), 2, 2, byrow = TRUE), respect = TRUE)
> layout.show(nf)
> 
> ## create single figure which is 5cm square
> nf <- layout(matrix(1), widths = lcm(5), heights = lcm(5))
> layout.show(nf)
> 
> 
> ##-- Create a scatterplot with marginal histograms -----
> 
> x <- pmin(3, pmax(-3, stats::rnorm(50)))
> y <- pmin(3, pmax(-3, stats::rnorm(50)))
> xhist <- hist(x, breaks = seq(-3,3,0.5), plot = FALSE)
> yhist <- hist(y, breaks = seq(-3,3,0.5), plot = FALSE)
> top <- max(c(xhist$counts, yhist$counts))
> xrange <- c(-3, 3)
> yrange <- c(-3, 3)
> nf <- layout(matrix(c(2,0,1,3),2,2,byrow = TRUE), c(3,1), c(1,3), TRUE)
> layout.show(nf)
> 
> par(mar = c(3,3,1,1))
> plot(x, y, xlim = xrange, ylim = yrange, xlab = "", ylab = "")
> par(mar = c(0,3,1,1))
> barplot(xhist$counts, axes = FALSE, ylim = c(0, top), space = 0)
> par(mar = c(3,0,1,1))
> barplot(yhist$counts, axes = FALSE, xlim = c(0, top), space = 0, horiz = TRUE)
> 
> par(def.par)  #- reset to default
> 
> 
> 
> graphics::par(get("par.postscript", pos = 'CheckExEnv'))
> cleanEx()
> nameEx("legend")
> ### * legend
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: legend
> ### Title: Add Legends to Plots
> ### Aliases: legend
> ### Keywords: aplot
> 
> ### ** Examples
> 
> ## Run the example in '?matplot' or the following:
> leg.txt <- c("Setosa     Petals", "Setosa     Sepals",
+              "Versicolor Petals", "Versicolor Sepals")
> y.leg <- c(4.5, 3, 2.1, 1.4, .7)
> cexv  <- c(1.2, 1, 4/5, 2/3, 1/2)
> matplot(c(1, 8), c(0, 4.5), type = "n", xlab = "Length", ylab = "Width",
+         main = "Petal and Sepal Dimensions in Iris Blossoms")
> for (i in seq(cexv)) {
+   text  (1, y.leg[i] - 0.1, paste("cex=", formatC(cexv[i])), cex = 0.8, adj = 0)
+   legend(3, y.leg[i], leg.txt, pch = "sSvV", col = c(1, 3), cex = cexv[i])
+ }
> 
> ## 'merge = TRUE' for merging lines & points:
> x <- seq(-pi, pi, len = 65)
> plot(x, sin(x), type = "l", ylim = c(-1.2, 1.8), col = 3, lty = 2)
> points(x, cos(x), pch = 3, col = 4)
> lines(x, tan(x), type = "b", lty = 1, pch = 4, col = 6)
> title("legend(..., lty = c(2, -1, 1), pch = c(NA, 3, 4), merge = TRUE)",
+       cex.main = 1.1)
> legend(-1, 1.9, c("sin", "cos", "tan"), col = c(3, 4, 6),
+        text.col = "green4", lty = c(2, -1, 1), pch = c(NA, 3, 4),
+        merge = TRUE, bg = "gray90")
> 
> ## right-justifying a set of labels: thanks to Uwe Ligges
> x <- 1:5; y1 <- 1/x; y2 <- 2/x
> plot(rep(x, 2), c(y1, y2), type = "n", xlab = "x", ylab = "y")
> lines(x, y1); lines(x, y2, lty = 2)
> temp <- legend("topright", legend = c(" ", " "),
+                text.width = strwidth("1,000,000"),
+                lty = 1:2, xjust = 1, yjust = 1,
+                title = "Line Types")
> text(temp$rect$left + temp$rect$w, temp$text$y,
+      c("1,000", "1,000,000"), pos = 2)
> 
> 
> ##--- log scaled Examples ------------------------------
> leg.txt <- c("a one", "a two")
> 
> par(mfrow = c(2, 2))
> for(ll in c("","x","y","xy")) {
+   plot(2:10, log = ll, main = paste0("log = '", ll, "'"))
+   abline(1, 1)
+   lines(2:3, 3:4, col = 2)
+   points(2, 2, col = 3)
+   rect(2, 3, 3, 2, col = 4)
+   text(c(3,3), 2:3, c("rect(2,3,3,2, col=4)",
+                       "text(c(3,3),2:3,\"c(rect(...)\")"), adj = c(0, 0.3))
+   legend(list(x = 2,y = 8), legend = leg.txt, col = 2:3, pch = 1:2,
+          lty = 1, merge = TRUE)   #, trace = TRUE)
+ }
> par(mfrow = c(1,1))
> 
> ##-- Math expressions:  ------------------------------
> x <- seq(-pi, pi, len = 65)
> plot(x, sin(x), type = "l", col = 2, xlab = expression(phi),
+      ylab = expression(f(phi)))
> abline(h = -1:1, v = pi/2*(-6:6), col = "gray90")
> lines(x, cos(x), col = 3, lty = 2)
> ex.cs1 <- expression(plain(sin) * phi,  paste("cos", phi))  # 2 ways
> utils::str(legend(-3, .9, ex.cs1, lty = 1:2, plot = FALSE,
+            adj = c(0, 0.6)))  # adj y !
List of 2
 $ rect:List of 4
  ..$ w   : num 1.2
  ..$ h   : num 0.251
  ..$ left: num -3
  ..$ top : num 0.9
 $ text:List of 2
  ..$ x: num [1:2] -2.29 -2.29
  ..$ y: num [1:2] 0.816 0.733
> legend(-3, 0.9, ex.cs1, lty = 1:2, col = 2:3,  adj = c(0, 0.6))
> 
> require(stats)
> x <- rexp(100, rate = .5)
> hist(x, main = "Mean and Median of a Skewed Distribution")
> abline(v = mean(x),   col = 2, lty = 2, lwd = 2)
> abline(v = median(x), col = 3, lty = 3, lwd = 2)
> ex12 <- expression(bar(x) == sum(over(x[i], n), i == 1, n),
+                    hat(x) == median(x[i], i == 1, n))
> utils::str(legend(4.1, 30, ex12, col = 2:3, lty = 2:3, lwd = 2))
List of 2
 $ rect:List of 4
  ..$ w   : num 4.27
  ..$ h   : num 6.78
  ..$ left: num 4.1
  ..$ top : num 30
 $ text:List of 2
  ..$ x: num [1:2] 5.22 5.22
  ..$ y: num [1:2] 27.3 24.6
> 
> ## 'Filled' boxes -- for more, see example(plot.factor)
> op <- par(bg = "white") # to get an opaque box for the legend
> plot(cut(weight, 3) ~ group, data = PlantGrowth, col = NULL,
+      density = 16*(1:3))
> par(op)
> 
> ## Using 'ncol' :
> x <- 0:64/64
> matplot(x, outer(x, 1:7, function(x, k) sin(k * pi * x)),
+         type = "o", col = 1:7, ylim = c(-1, 1.5), pch = "*")
> op <- par(bg = "antiquewhite1")
> legend(0, 1.5, paste("sin(", 1:7, "pi * x)"), col = 1:7, lty = 1:7,
+        pch = "*", ncol = 4, cex = 0.8)
> legend(.8,1.2, paste("sin(", 1:7, "pi * x)"), col = 1:7, lty = 1:7,
+        pch = "*", cex = 0.8)
> legend(0, -.1, paste("sin(", 1:4, "pi * x)"), col = 1:4, lty = 1:4,
+        ncol = 2, cex = 0.8)
> legend(0, -.4, paste("sin(", 5:7, "pi * x)"), col = 4:6,  pch = 24,
+        ncol = 2, cex = 1.5, lwd = 2, pt.bg = "pink", pt.cex = 1:3)
> par(op)
> 
> ## point covering line :
> y <- sin(3*pi*x)
> plot(x, y, type = "l", col = "blue",
+     main = "points with bg & legend(*, pt.bg)")
> points(x, y, pch = 21, bg = "white")
> legend(.4,1, "sin(c x)", pch = 21, pt.bg = "white", lty = 1, col = "blue")
> 
> ## legends with titles at different locations
> plot(x, y, type = "n")
> legend("bottomright", "(x,y)", pch = 1, title = "bottomright")
> legend("bottom", "(x,y)", pch = 1, title = "bottom")
> legend("bottomleft", "(x,y)", pch = 1, title = "bottomleft")
> legend("left", "(x,y)", pch = 1, title = "left")
> legend("topleft", "(x,y)", pch = 1, title = "topleft, inset = .05",
+        inset = .05)
> legend("top", "(x,y)", pch = 1, title = "top")
> legend("topright", "(x,y)", pch = 1, title = "topright, inset = .02",
+        inset = .02)
> legend("right", "(x,y)", pch = 1, title = "right")
> legend("center", "(x,y)", pch = 1, title = "center")
> 
> # using text.font (and text.col):
> op <- par(mfrow = c(2, 2), mar = rep(2.1, 4))
> c6 <- terrain.colors(10)[1:6]
> for(i in 1:4) {
+    plot(1, type = "n", axes = FALSE, ann = FALSE); title(paste("text.font =",i))
+    legend("top", legend = LETTERS[1:6], col = c6,
+           ncol = 2, cex = 2, lwd = 3, text.font = i, text.col = c6)
+ }
> par(op)
> 
> 
> 
> graphics::par(get("par.postscript", pos = 'CheckExEnv'))
> cleanEx()
> nameEx("lines")
> ### * lines
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: lines
> ### Title: Add Connected Line Segments to a Plot
> ### Aliases: lines lines.default
> ### Keywords: aplot
> 
> ### ** Examples
> 
> # draw a smooth line through a scatter plot
> plot(cars, main = "Stopping Distance versus Speed")
> lines(stats::lowess(cars))
> 
> 
> 
> cleanEx()
> nameEx("matplot")
> ### * matplot
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: matplot
> ### Title: Plot Columns of Matrices
> ### Aliases: matplot matpoints matlines
> ### Keywords: hplot aplot array
> 
> ### ** Examples
> 
> require(grDevices)
> matplot((-4:5)^2, main = "Quadratic") # almost identical to plot(*)
> sines <- outer(1:20, 1:4, function(x, y) sin(x / 20 * pi * y))
> matplot(sines, pch = 1:4, type = "o", col = rainbow(ncol(sines)))
> matplot(sines, type = "b", pch = 21:23, col = 2:5, bg = 2:5,
+         main = "matplot(...., pch = 21:23, bg = 2:5)")
> 
> x <- 0:50/50
> matplot(x, outer(x, 1:8, function(x, k) sin(k*pi * x)),
+         ylim = c(-2,2), type = "plobcsSh",
+         main= "matplot(,type = \"plobcsSh\" )")
> ## pch & type =  vector of 1-chars :
> matplot(x, outer(x, 1:4, function(x, k) sin(k*pi * x)),
+         pch = letters[1:4], type = c("b","p","o"))
> 
> lends <- c("round","butt","square")
> matplot(matrix(1:12, 4), type="c", lty=1, lwd=10, lend=lends)
> text(cbind(2.5, 2*c(1,3,5)-.4), lends, col= 1:3, cex = 1.5)
> 
> table(iris$Species) # is data.frame with 'Species' factor

    setosa versicolor  virginica 
        50         50         50 
> iS <- iris$Species == "setosa"
> iV <- iris$Species == "versicolor"
> op <- par(bg = "bisque")
> matplot(c(1, 8), c(0, 4.5), type =  "n", xlab = "Length", ylab = "Width",
+         main = "Petal and Sepal Dimensions in Iris Blossoms")
> matpoints(iris[iS,c(1,3)], iris[iS,c(2,4)], pch = "sS", col = c(2,4))
> matpoints(iris[iV,c(1,3)], iris[iV,c(2,4)], pch = "vV", col = c(2,4))
> legend(1, 4, c("    Setosa Petals", "    Setosa Sepals",
+                "Versicolor Petals", "Versicolor Sepals"),
+        pch = "sSvV", col = rep(c(2,4), 2))
> 
> nam.var <- colnames(iris)[-5]
> nam.spec <- as.character(iris[1+50*0:2, "Species"])
> iris.S <- array(NA, dim = c(50,4,3),
+                 dimnames = list(NULL, nam.var, nam.spec))
> for(i in 1:3) iris.S[,,i] <- data.matrix(iris[1:50+50*(i-1), -5])
> 
> matplot(iris.S[, "Petal.Length",], iris.S[, "Petal.Width",], pch = "SCV",
+         col = rainbow(3, start = 0.8, end = 0.1),
+         sub = paste(c("S", "C", "V"), dimnames(iris.S)[[3]],
+                     sep = "=", collapse= ",  "),
+         main = "Fisher's Iris Data")
> par(op)
> 
> 
> 
> graphics::par(get("par.postscript", pos = 'CheckExEnv'))
> cleanEx()
> nameEx("mosaicplot")
> ### * mosaicplot
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: mosaicplot
> ### Title: Mosaic Plots
> ### Aliases: mosaicplot mosaicplot.default mosaicplot.formula
> ### Keywords: hplot
> 
> ### ** Examples
> 
> require(stats)
> mosaicplot(Titanic, main = "Survival on the Titanic", color = TRUE)
> ## Formula interface for tabulated data:
> mosaicplot(~ Sex + Age + Survived, data = Titanic, color = TRUE)
> 
> mosaicplot(HairEyeColor, shade = TRUE)
> ## Independence model of hair and eye color and sex.  Indicates that
> ## there are more blue eyed blonde females than expected in the case
> ## of independence and too few brown eyed blonde females.
> ## The corresponding model is:
> fm <- loglin(HairEyeColor, list(1, 2, 3))
2 iterations: deviation 5.684342e-14 
> pchisq(fm$pearson, fm$df, lower.tail = FALSE)
[1] 5.320872e-23
> 
> mosaicplot(HairEyeColor, shade = TRUE, margin = list(1:2, 3))
> ## Model of joint independence of sex from hair and eye color.  Males
> ## are underrepresented among people with brown hair and eyes, and are
> ## overrepresented among people with brown hair and blue eyes.
> ## The corresponding model is:
> fm <- loglin(HairEyeColor, list(1:2, 3))
2 iterations: deviation 5.684342e-14 
> pchisq(fm$pearson, fm$df, lower.tail = FALSE)
[1] 0.1891745
> 
> ## Formula interface for raw data: visualize cross-tabulation of numbers
> ## of gears and carburettors in Motor Trend car data.
> mosaicplot(~ gear + carb, data = mtcars, color = TRUE, las = 1)
> # color recycling
> mosaicplot(~ gear + carb, data = mtcars, color = 2:3, las = 1)
> 
> 
> 
> cleanEx()
> nameEx("mtext")
> ### * mtext
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: mtext
> ### Title: Write Text into the Margins of a Plot
> ### Aliases: mtext
> ### Keywords: aplot
> 
> ### ** Examples
> 
> plot(1:10, (-4:5)^2, main = "Parabola Points", xlab = "xlab")
> mtext("10 of them")
> for(s in 1:4)
+     mtext(paste("mtext(..., line= -1, {side, col, font} = ", s,
+           ", cex = ", (1+s)/2, ")"), line = -1,
+           side = s, col = s, font = s, cex = (1+s)/2)
> mtext("mtext(..., line= -2)", line = -2)
> mtext("mtext(..., line= -2, adj = 0)", line = -2, adj = 0)
> ##--- log axis :
> plot(1:10, exp(1:10), log = "y", main = "log =\"y\"", xlab = "xlab")
> for(s in 1:4) mtext(paste("mtext(...,side=", s ,")"), side = s)
> 
> 
> 
> cleanEx()
> nameEx("pairs")
> ### * pairs
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: pairs
> ### Title: Scatterplot Matrices
> ### Aliases: pairs pairs.default pairs.formula
> ### Keywords: hplot
> 
> ### ** Examples
> 
> pairs(iris[1:4], main = "Anderson's Iris Data -- 3 species",
+       pch = 21, bg = c("red", "green3", "blue")[unclass(iris$Species)])
> 
> ## formula method
> pairs(~ Fertility + Education + Catholic, data = swiss,
+       subset = Education < 20, main = "Swiss data, Education < 20")
> 
> pairs(USJudgeRatings)
> ## show only lower triangle (and suppress labeling for whatever reason):
> pairs(USJudgeRatings, text.panel = NULL, upper.panel = NULL)
> 
> ## put histograms on the diagonal
> panel.hist <- function(x, ...)
+ {
+     usr <- par("usr"); on.exit(par(usr))
+     par(usr = c(usr[1:2], 0, 1.5) )
+     h <- hist(x, plot = FALSE)
+     breaks <- h$breaks; nB <- length(breaks)
+     y <- h$counts; y <- y/max(y)
+     rect(breaks[-nB], 0, breaks[-1], y, col = "cyan", ...)
+ }
> pairs(USJudgeRatings[1:5], panel = panel.smooth,
+       cex = 1.5, pch = 24, bg = "light blue",
+       diag.panel = panel.hist, cex.labels = 2, font.labels = 2)
> 
> ## put (absolute) correlations on the upper panels,
> ## with size proportional to the correlations.
> panel.cor <- function(x, y, digits = 2, prefix = "", cex.cor, ...)
+ {
+     usr <- par("usr"); on.exit(par(usr))
+     par(usr = c(0, 1, 0, 1))
+     r <- abs(cor(x, y))
+     txt <- format(c(r, 0.123456789), digits = digits)[1]
+     txt <- paste0(prefix, txt)
+     if(missing(cex.cor)) cex.cor <- 0.8/strwidth(txt)
+     text(0.5, 0.5, txt, cex = cex.cor * r)
+ }
> pairs(USJudgeRatings, lower.panel = panel.smooth, upper.panel = panel.cor)
> 
> pairs(iris[-5], log = "xy") # plot all variables on log scale
> pairs(iris, log = 1:4, # log the first four
+       main = "Lengths and Widths in [log]", line.main=1.5, oma=c(2,2,3,2))
> 
> 
> 
> graphics::par(get("par.postscript", pos = 'CheckExEnv'))
> cleanEx()
> nameEx("panel.smooth")
> ### * panel.smooth
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: panel.smooth
> ### Title: Simple Panel Plot
> ### Aliases: panel.smooth
> ### Keywords: hplot dplot
> 
> ### ** Examples
> 
> pairs(swiss, panel = panel.smooth, pch = ".")  # emphasize the smooths
> pairs(swiss, panel = panel.smooth, lwd = 2, cex = 1.5, col = "blue")  # hmm...
> 
> 
> 
> cleanEx()
> nameEx("par")
> ### * par
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: par
> ### Title: Set or Query Graphical Parameters
> ### Aliases: par .Pars 'graphical parameter' 'graphical parameters'
> ### Keywords: iplot dplot environment
> 
> ### ** Examples
> 
> op <- par(mfrow = c(2, 2), # 2 x 2 pictures on one plot
+           pty = "s")       # square plotting region,
>                            # independent of device size
> 
> ## At end of plotting, reset to previous settings:
> par(op)
> 
> ## Alternatively,
> op <- par(no.readonly = TRUE) # the whole list of settable par's.
> ## do lots of plotting and par(.) calls, then reset:
> par(op)
> ## Note this is not in general good practice
> 
> par("ylog") # FALSE
[1] FALSE
> plot(1 : 12, log = "y")
> par("ylog") # TRUE
[1] TRUE
> 
> plot(1:2, xaxs = "i") # 'inner axis' w/o extra space
> par(c("usr", "xaxp"))
$usr
[1] 1.00 2.00 0.96 2.04

$xaxp
[1] 1 2 5

> 
> ( nr.prof <-
+ c(prof.pilots = 16, lawyers = 11, farmers = 10, salesmen = 9, physicians = 9,
+   mechanics = 6, policemen = 6, managers = 6, engineers = 5, teachers = 4,
+   housewives = 3, students = 3, armed.forces = 1))
 prof.pilots      lawyers      farmers     salesmen   physicians    mechanics 
          16           11           10            9            9            6 
   policemen     managers    engineers     teachers   housewives     students 
           6            6            5            4            3            3 
armed.forces 
           1 
> par(las = 3)
> barplot(rbind(nr.prof)) # R 0.63.2: shows alignment problem
> par(las = 0)  # reset to default
> 
> require(grDevices) # for gray
> ## 'fg' use:
> plot(1:12, type = "b", main = "'fg' : axes, ticks and box in gray",
+      fg = gray(0.7), bty = "7" , sub = R.version.string)
> 
> ex <- function() {
+    old.par <- par(no.readonly = TRUE) # all par settings which
+                                       # could be changed.
+    on.exit(par(old.par))
+    ## ...
+    ## ... do lots of par() settings and plots
+    ## ...
+    invisible() #-- now,  par(old.par)  will be executed
+ }
> ex()
> 
> ## Line types
> showLty <- function(ltys, xoff = 0, ...) {
+    stopifnot((n <- length(ltys)) >= 1)
+    op <- par(mar = rep(.5,4)); on.exit(par(op))
+    plot(0:1, 0:1, type = "n", axes = FALSE, ann = FALSE)
+    y <- (n:1)/(n+1)
+    clty <- as.character(ltys)
+    mytext <- function(x, y, txt)
+       text(x, y, txt, adj = c(0, -.3), cex = 0.8, ...)
+    abline(h = y, lty = ltys, ...); mytext(xoff, y, clty)
+    y <- y - 1/(3*(n+1))
+    abline(h = y, lty = ltys, lwd = 2, ...)
+    mytext(1/8+xoff, y, paste(clty," lwd = 2"))
+ }
> showLty(c("solid", "dashed", "dotted", "dotdash", "longdash", "twodash"))
> par(new = TRUE)  # the same:
> showLty(c("solid", "44", "13", "1343", "73", "2262"), xoff = .2, col = 2)
> showLty(c("11", "22", "33", "44",   "12", "13", "14",   "21", "31"))
> 
> 
> 
> graphics::par(get("par.postscript", pos = 'CheckExEnv'))
> cleanEx()
> nameEx("persp")
> ### * persp
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: persp
> ### Title: Perspective Plots
> ### Aliases: persp persp.default
> ### Keywords: hplot aplot
> 
> ### ** Examples
> 
> require(grDevices) # for trans3d
> ## More examples in  demo(persp) !!
> ##                   -----------
> 
> # (1) The Obligatory Mathematical surface.
> #     Rotated sinc function.
> 
> x <- seq(-10, 10, length= 30)
> y <- x
> f <- function(x, y) { r <- sqrt(x^2+y^2); 10 * sin(r)/r }
> z <- outer(x, y, f)
> z[is.na(z)] <- 1
> op <- par(bg = "white")
> persp(x, y, z, theta = 30, phi = 30, expand = 0.5, col = "lightblue")
> persp(x, y, z, theta = 30, phi = 30, expand = 0.5, col = "lightblue",
+       ltheta = 120, shade = 0.75, ticktype = "detailed",
+       xlab = "X", ylab = "Y", zlab = "Sinc( r )"
+ ) -> res
> round(res, 3)
      [,1]   [,2]   [,3]   [,4]
[1,] 0.087 -0.025  0.043 -0.043
[2,] 0.050  0.043 -0.075  0.075
[3,] 0.000  0.074  0.042 -0.042
[4,] 0.000 -0.273 -2.890  3.890
> 
> # (2) Add to existing persp plot - using trans3d() :
> 
> xE <- c(-10,10); xy <- expand.grid(xE, xE)
> points(trans3d(xy[,1], xy[,2], 6, pmat = res), col = 2, pch = 16)
> lines (trans3d(x, y = 10, z = 6 + sin(x), pmat = res), col = 3)
> 
> phi <- seq(0, 2*pi, len = 201)
> r1 <- 7.725 # radius of 2nd maximum
> xr <- r1 * cos(phi)
> yr <- r1 * sin(phi)
> lines(trans3d(xr,yr, f(xr,yr), res), col = "pink", lwd = 2)
> ## (no hidden lines)
> 
> # (3) Visualizing a simple DEM model
> 
> z <- 2 * volcano        # Exaggerate the relief
> x <- 10 * (1:nrow(z))   # 10 meter spacing (S to N)
> y <- 10 * (1:ncol(z))   # 10 meter spacing (E to W)
> ## Don't draw the grid lines :  border = NA
> par(bg = "slategray")
> persp(x, y, z, theta = 135, phi = 30, col = "green3", scale = FALSE,
+       ltheta = -120, shade = 0.75, border = NA, box = FALSE)
> 
> # (4) Surface colours corresponding to z-values
> 
> par(bg = "white")
> x <- seq(-1.95, 1.95, length = 30)
> y <- seq(-1.95, 1.95, length = 35)
> z <- outer(x, y, function(a, b) a*b^2)
> nrz <- nrow(z)
> ncz <- ncol(z)
> # Create a function interpolating colors in the range of specified colors
> jet.colors <- colorRampPalette( c("blue", "green") )
> # Generate the desired number of colors from this palette
> nbcol <- 100
> color <- jet.colors(nbcol)
> # Compute the z-value at the facet centres
> zfacet <- z[-1, -1] + z[-1, -ncz] + z[-nrz, -1] + z[-nrz, -ncz]
> # Recode facet z-values into color indices
> facetcol <- cut(zfacet, nbcol)
> persp(x, y, z, col = color[facetcol], phi = 30, theta = -30)
> 
> par(op)
> 
> 
> 
> graphics::par(get("par.postscript", pos = 'CheckExEnv'))
> cleanEx()
> nameEx("pie")
> ### * pie
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: pie
> ### Title: Pie Charts
> ### Aliases: pie
> ### Keywords: hplot
> 
> ### ** Examples
> 
> require(grDevices)
> pie(rep(1, 24), col = rainbow(24), radius = 0.9)
> 
> pie.sales <- c(0.12, 0.3, 0.26, 0.16, 0.04, 0.12)
> names(pie.sales) <- c("Blueberry", "Cherry",
+     "Apple", "Boston Cream", "Other", "Vanilla Cream")
> pie(pie.sales) # default colours
> pie(pie.sales, col = c("purple", "violetred1", "green3",
+                        "cornsilk", "cyan", "white"))
> pie(pie.sales, col = gray(seq(0.4, 1.0, length = 6)))
> pie(pie.sales, density = 10, angle = 15 + 10 * 1:6)
> pie(pie.sales, clockwise = TRUE, main = "pie(*, clockwise = TRUE)")
> segments(0, 0, 0, 1, col = "red", lwd = 2)
> text(0, 1, "init.angle = 90", col = "red")
> 
> n <- 200
> pie(rep(1, n), labels = "", col = rainbow(n), border = NA,
+     main = "pie(*, labels=\"\", col=rainbow(n), border=NA,..")
> 
> 
> 
> cleanEx()
> nameEx("plot")
> ### * plot
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: plot
> ### Title: Generic X-Y Plotting
> ### Aliases: plot
> ### Keywords: hplot
> 
> ### ** Examples
> 
> require(stats)
> plot(cars)
> lines(lowess(cars))
> 
> plot(sin, -pi, 2*pi) # see ?plot.function
> 
> ## Discrete Distribution Plot:
> plot(table(rpois(100, 5)), type = "h", col = "red", lwd = 10,
+      main = "rpois(100, lambda = 5)")
> 
> ## Simple quantiles/ECDF, see ecdf() {library(stats)} for a better one:
> plot(x <- sort(rnorm(47)), type = "s", main = "plot(x, type = \"s\")")
> points(x, cex = .5, col = "dark red")
> 
> 
> 
> cleanEx()
> nameEx("plot.dataframe")
> ### * plot.dataframe
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: plot.data.frame
> ### Title: Plot Method for Data Frames
> ### Aliases: plot.data.frame
> ### Keywords: hplot methods
> 
> ### ** Examples
> 
> plot(OrchardSprays[1], method = "jitter")
> plot(OrchardSprays[c(4,1)])
> plot(OrchardSprays)
> 
> plot(iris)
> plot(iris[5:4])
> plot(women)
> 
> 
> 
> cleanEx()
> nameEx("plot.default")
> ### * plot.default
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: plot.default
> ### Title: The Default Scatterplot Function
> ### Aliases: plot.default
> ### Keywords: hplot
> 
> ### ** Examples
> 
> Speed <- cars$speed
> Distance <- cars$dist
> plot(Speed, Distance, panel.first = grid(8, 8),
+      pch = 0, cex = 1.2, col = "blue")
> plot(Speed, Distance,
+      panel.first = lines(stats::lowess(Speed, Distance), lty = "dashed"),
+      pch = 0, cex = 1.2, col = "blue")
> 
> ## Show the different plot types
> x <- 0:12
> y <- sin(pi/5 * x)
> op <- par(mfrow = c(3,3), mar = .1+ c(2,2,3,1))
> for (tp in c("p","l","b",  "c","o","h",  "s","S","n")) {
+    plot(y ~ x, type = tp, main = paste0("plot(*, type = \"", tp, "\")"))
+    if(tp == "S") {
+       lines(x, y, type = "s", col = "red", lty = 2)
+       mtext("lines(*, type = \"s\", ...)", col = "red", cex = 0.8)
+    }
+ }
> par(op)
> 
> ##--- Log-Log Plot  with  custom axes
> lx <- seq(1, 5, length = 41)
> yl <- expression(e^{-frac(1,2) * {log[10](x)}^2})
> y <- exp(-.5*lx^2)
> op <- par(mfrow = c(2,1), mar = par("mar")+c(0,1,0,0))
> plot(10^lx, y, log = "xy", type = "l", col = "purple",
+      main = "Log-Log plot", ylab = yl, xlab = "x")
> plot(10^lx, y, log = "xy", type = "o", pch = ".", col = "forestgreen",
+      main = "Log-Log plot with custom axes", ylab = yl, xlab = "x",
+      axes = FALSE, frame.plot = TRUE)
> my.at <- 10^(1:5)
> axis(1, at = my.at, labels = formatC(my.at, format = "fg"))
> at.y <- 10^(-5:-1)
> axis(2, at = at.y, labels = formatC(at.y, format = "fg"), col.axis = "red")
> par(op)
> 
> 
> 
> graphics::par(get("par.postscript", pos = 'CheckExEnv'))
> cleanEx()
> nameEx("plot.design")
> ### * plot.design
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: plot.design
> ### Title: Plot Univariate Effects of a Design or Model
> ### Aliases: plot.design
> ### Keywords: hplot
> 
> ### ** Examples
> 
> require(stats)
> plot.design(warpbreaks)  # automatic for data frame with one numeric var.
> 
> Form <- breaks ~ wool + tension
> summary(fm1 <- aov(Form, data = warpbreaks))
            Df Sum Sq Mean Sq F value  Pr(>F)   
wool         1    451   450.7   3.339 0.07361 . 
tension      2   2034  1017.1   7.537 0.00138 **
Residuals   50   6748   135.0                   
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> plot.design(       Form, data = warpbreaks, col = 2)  # same as above
> 
> ## More than one y :
> utils::str(esoph)
'data.frame':	88 obs. of  5 variables:
 $ agegp    : Ord.factor w/ 6 levels "25-34"<"35-44"<..: 1 1 1 1 1 1 1 1 1 1 ...
 $ alcgp    : Ord.factor w/ 4 levels "0-39g/day"<"40-79"<..: 1 1 1 1 2 2 2 2 3 3 ...
 $ tobgp    : Ord.factor w/ 4 levels "0-9g/day"<"10-19"<..: 1 2 3 4 1 2 3 4 1 2 ...
 $ ncases   : num  0 0 0 0 0 0 0 0 0 0 ...
 $ ncontrols: num  40 10 6 5 27 7 4 7 2 1 ...
> plot.design(esoph) ## two plots; if interactive you are "ask"ed
> 
> ## or rather, compare mean and median:
> op <- par(mfcol = 1:2)
> plot.design(ncases/ncontrols ~ ., data = esoph, ylim = c(0, 0.8))
> plot.design(ncases/ncontrols ~ ., data = esoph, ylim = c(0, 0.8),
+             fun = median)
> par(op)
> 
> 
> 
> graphics::par(get("par.postscript", pos = 'CheckExEnv'))
> cleanEx()
> nameEx("plot.factor")
> ### * plot.factor
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: plot.factor
> ### Title: Plotting Factor Variables
> ### Aliases: plot.factor
> ### Keywords: hplot
> 
> ### ** Examples
> 
> require(grDevices)
> plot(weight ~ group, data = PlantGrowth)           # numeric vector ~ factor
> plot(cut(weight, 2) ~ group, data = PlantGrowth)   # factor ~ factor
> ## passing "..." to spineplot() eventually:
> plot(cut(weight, 3) ~ group, data = PlantGrowth,
+      col = hcl(c(0, 120, 240), 50, 70))
> 
> plot(PlantGrowth$group, axes = FALSE, main = "no axes")  # extremely silly
> 
> 
> 
> cleanEx()
> nameEx("plot.formula")
> ### * plot.formula
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: plot.formula
> ### Title: Formula Notation for Scatterplots
> ### Aliases: plot.formula lines.formula points.formula text.formula
> ### Keywords: hplot aplot
> 
> ### ** Examples
> 
> op <- par(mfrow = c(2,1))
> plot(Ozone ~ Wind, data = airquality, pch = as.character(Month))
> plot(Ozone ~ Wind, data = airquality, pch = as.character(Month),
+      subset = Month != 7)
> par(op)
> 
> ## text.formula() can be very natural:
> wb <- within(warpbreaks, {
+     time <- seq_along(breaks); W.T <- wool:tension })
> plot(breaks ~ time, data = wb, type = "b")
> text(breaks ~ time, data = wb, label = W.T, col = 1+as.integer(wool))
> 
> 
> 
> graphics::par(get("par.postscript", pos = 'CheckExEnv'))
> cleanEx()
> nameEx("plot.table")
> ### * plot.table
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: plot.table
> ### Title: Plot Methods for 'table' Objects
> ### Aliases: plot.table lines.table points.table
> ### Keywords: hplot category
> 
> ### ** Examples
> 
> ## 1-d tables
> (Poiss.tab <- table(N = stats::rpois(200, lambda = 5)))
N
 1  2  3  4  5  6  7  8  9 10 11 
 4 14 25 38 40 33 21 16  4  2  3 
> plot(Poiss.tab, main = "plot(table(rpois(200, lambda = 5)))")
> 
> plot(table(state.division))
> 
> ## 4-D :
> plot(Titanic, main ="plot(Titanic, main= *)")
> 
> 
> 
> 
> cleanEx()
> nameEx("plot.window")
> ### * plot.window
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: plot.window
> ### Title: Set up World Coordinates for Graphics Window
> ### Aliases: plot.window xlim ylim asp
> ### Keywords: aplot
> 
> ### ** Examples
> 
> ##--- An example for the use of 'asp' :
> require(stats)  # normally loaded
> loc <- cmdscale(eurodist)
> rx <- range(x <- loc[,1])
> ry <- range(y <- -loc[,2])
> plot(x, y, type = "n", asp = 1, xlab = "", ylab = "")
> abline(h = pretty(rx, 10), v = pretty(ry, 10), col = "lightgray")
> text(x, y, labels(eurodist), cex = 0.8)
> 
> 
> 
> cleanEx()
> nameEx("plot.xy")
> ### * plot.xy
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: plot.xy
> ### Title: Basic Internal Plot Function
> ### Aliases: plot.xy
> ### Keywords: aplot
> 
> ### ** Examples
> 
> points.default # to see how it calls "plot.xy(xy.coords(x, y), ...)"
function (x, y = NULL, type = "p", ...) 
plot.xy(xy.coords(x, y), type = type, ...)
<bytecode: 0x1f21288>
<environment: namespace:graphics>
> 
> 
> 
> cleanEx()
> nameEx("plothistogram")
> ### * plothistogram
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: plot.histogram
> ### Title: Plot Histograms
> ### Aliases: plot.histogram lines.histogram
> ### Keywords: hplot iplot
> 
> ### ** Examples
> 
> (wwt <- hist(women$weight, nclass = 7, plot = FALSE))
$breaks
 [1] 115 120 125 130 135 140 145 150 155 160 165

$counts
 [1] 3 1 2 2 1 1 2 1 1 1

$density
 [1] 0.04000000 0.01333333 0.02666667 0.02666667 0.01333333 0.01333333
 [7] 0.02666667 0.01333333 0.01333333 0.01333333

$mids
 [1] 117.5 122.5 127.5 132.5 137.5 142.5 147.5 152.5 157.5 162.5

$xname
[1] "women$weight"

$equidist
[1] TRUE

attr(,"class")
[1] "histogram"
> plot(wwt, labels = TRUE) # default main & xlab using wwt$xname
> plot(wwt, border = "dark blue", col = "light blue",
+      main = "Histogram of 15 women's weights", xlab = "weight [pounds]")
> 
> ## Fake "lines" example, using non-default labels:
> w2 <- wwt; w2$counts <- w2$counts - 1
> lines(w2, col = "Midnight Blue", labels = ifelse(w2$counts, "> 1", "1"))
> 
> 
> 
> cleanEx()
> nameEx("points")
> ### * points
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: points
> ### Title: Add Points to a Plot
> ### Aliases: points points.default pch
> ### Keywords: aplot
> 
> ### ** Examples
> 
> require(stats) # for rnorm
> plot(-4:4, -4:4, type = "n")  # setting up coord. system
> points(rnorm(200), rnorm(200), col = "red")
> points(rnorm(100)/2, rnorm(100)/2, col = "blue", cex = 1.5)
> 
> op <- par(bg = "light blue")
> x <- seq(0, 2*pi, len = 51)
> ## something "between type='b' and type='o'":
> plot(x, sin(x), type = "o", pch = 21, bg = par("bg"), col = "blue", cex = .6,
+  main = 'plot(..., type="o", pch=21, bg=par("bg"))')
> par(op)
> 
> ## Not run: 
> ##D ## The figure was produced by calls like
> ##D png("pch.png", height = 0.7, width = 7, res = 100, units = "in")
> ##D par(mar = rep(0,4))
> ##D plot(c(-1, 26), 0:1, type = "n", axes = FALSE)
> ##D text(0:25, 0.6, 0:25, cex = 0.5)
> ##D points(0:25, rep(0.3, 26), pch = 0:25, bg = "grey")
> ## End(Not run)
> 
> ##-------- Showing all the extra & some char graphics symbols ---------
> pchShow <-
+   function(extras = c("*",".", "o","O","0","+","-","|","%","#"),
+            cex = 3, ## good for both .Device=="postscript" and "x11"
+            col = "red3", bg = "gold", coltext = "brown", cextext = 1.2,
+            main = paste("plot symbols :  points (...  pch = *, cex =",
+                         cex,")"))
+   {
+     nex <- length(extras)
+     np  <- 26 + nex
+     ipch <- 0:(np-1)
+     k <- floor(sqrt(np))
+     dd <- c(-1,1)/2
+     rx <- dd + range(ix <- ipch %/% k)
+     ry <- dd + range(iy <- 3 + (k-1)- ipch %% k)
+     pch <- as.list(ipch) # list with integers & strings
+     if(nex > 0) pch[26+ 1:nex] <- as.list(extras)
+     plot(rx, ry, type = "n", axes  =  FALSE, xlab = "", ylab = "", main = main)
+     abline(v = ix, h = iy, col = "lightgray", lty = "dotted")
+     for(i in 1:np) {
+       pc <- pch[[i]]
+       ## 'col' symbols with a 'bg'-colored interior (where available) :
+       points(ix[i], iy[i], pch = pc, col = col, bg = bg, cex = cex)
+       if(cextext > 0)
+           text(ix[i] - 0.3, iy[i], pc, col = coltext, cex = cextext)
+     }
+   }
> 
> pchShow()
> pchShow(c("o","O","0"), cex = 2.5)
> pchShow(NULL, cex = 4, cextext = 0, main = NULL)
> 
> 
> 
> graphics::par(get("par.postscript", pos = 'CheckExEnv'))
> cleanEx()
> nameEx("polygon")
> ### * polygon
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: polygon
> ### Title: Polygon Drawing
> ### Aliases: polygon
> ### Keywords: aplot
> 
> ### ** Examples
> 
> x <- c(1:9, 8:1)
> y <- c(1, 2*(5:3), 2, -1, 17, 9, 8, 2:9)
> op <- par(mfcol = c(3, 1))
> for(xpd in c(FALSE, TRUE, NA)) {
+   plot(1:10, main = paste("xpd =", xpd))
+   box("figure", col = "pink", lwd = 3)
+   polygon(x, y, xpd = xpd, col = "orange", lty = 2, lwd = 2, border = "red")
+ }
> par(op)
> 
> n <- 100
> xx <- c(0:n, n:0)
> yy <- c(c(0, cumsum(stats::rnorm(n))), rev(c(0, cumsum(stats::rnorm(n)))))
> plot   (xx, yy, type = "n", xlab = "Time", ylab = "Distance")
> polygon(xx, yy, col = "gray", border = "red")
> title("Distance Between Brownian Motions")
> 
> # Multiple polygons from NA values
> # and recycling of col, border, and lty
> op <- par(mfrow = c(2, 1))
> plot(c(1, 9), 1:2, type = "n")
> polygon(1:9, c(2,1,2,1,1,2,1,2,1),
+         col = c("red", "blue"),
+         border = c("green", "yellow"),
+         lwd = 3, lty = c("dashed", "solid"))
> plot(c(1, 9), 1:2, type = "n")
> polygon(1:9, c(2,1,2,1,NA,2,1,2,1),
+         col = c("red", "blue"),
+         border = c("green", "yellow"),
+         lwd = 3, lty = c("dashed", "solid"))
> par(op)
> 
> # Line-shaded polygons
> plot(c(1, 9), 1:2, type = "n")
> polygon(1:9, c(2,1,2,1,NA,2,1,2,1),
+         density = c(10, 20), angle = c(-45, 45))
> 
> 
> 
> graphics::par(get("par.postscript", pos = 'CheckExEnv'))
> cleanEx()
> nameEx("polypath")
> ### * polypath
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: polypath
> ### Title: Path Drawing
> ### Aliases: polypath
> ### Keywords: aplot
> 
> ### ** Examples
> 
> plotPath <- function(x, y, col = "grey", rule = "winding") {
+     plot.new()
+     plot.window(range(x, na.rm = TRUE), range(y, na.rm = TRUE))
+     polypath(x, y, col = col, rule = rule)
+     if (!is.na(col))
+         mtext(paste("Rule:", rule), side = 1, line = 0)
+ }
> 
> plotRules <- function(x, y, title) {
+     plotPath(x, y)
+     plotPath(x, y, rule = "evenodd")
+     mtext(title, side = 3, line = 0)
+     plotPath(x, y, col = NA)
+ }
> 
> op <- par(mfrow = c(5, 3), mar = c(2, 1, 1, 1))
> 
> plotRules(c(.1, .1, .9, .9, NA, .2, .2, .8, .8),
+           c(.1, .9, .9, .1, NA, .2, .8, .8, .2),
+           "Nested rectangles, both clockwise")
> plotRules(c(.1, .1, .9, .9, NA, .2, .8, .8, .2),
+           c(.1, .9, .9, .1, NA, .2, .2, .8, .8),
+           "Nested rectangles, outer clockwise, inner anti-clockwise")
> plotRules(c(.1, .1, .4, .4, NA, .6, .9, .9, .6),
+           c(.1, .4, .4, .1, NA, .6, .6, .9, .9),
+           "Disjoint rectangles")
> plotRules(c(.1, .1, .6, .6, NA, .4, .4, .9, .9),
+           c(.1, .6, .6, .1, NA, .4, .9, .9, .4),
+           "Overlapping rectangles, both clockwise")
> plotRules(c(.1, .1, .6, .6, NA, .4, .9, .9, .4),
+           c(.1, .6, .6, .1, NA, .4, .4, .9, .9),
+           "Overlapping rectangles, one clockwise, other anti-clockwise")
> 
> par(op)
> 
> 
> 
> graphics::par(get("par.postscript", pos = 'CheckExEnv'))
> cleanEx()
> nameEx("rasterImage")
> ### * rasterImage
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: rasterImage
> ### Title: Draw One or More Raster Images
> ### Aliases: rasterImage
> ### Keywords: aplot
> 
> ### ** Examples
> 
> require(grDevices)
> ## set up the plot region:
> op <- par(bg = "thistle")
> plot(c(100, 250), c(300, 450), type = "n", xlab = "", ylab = "")
> image <- as.raster(matrix(0:1, ncol = 5, nrow = 3))
Warning in matrix(0:1, ncol = 5, nrow = 3) :
  data length [2] is not a sub-multiple or multiple of the number of rows [3]
> rasterImage(image, 100, 300, 150, 350, interpolate = FALSE)
> rasterImage(image, 100, 400, 150, 450)
> rasterImage(image, 200, 300, 200 + xinch(.5), 300 + yinch(.3),
+             interpolate = FALSE)
> rasterImage(image, 200, 400, 250, 450, angle = 15, interpolate = FALSE)
> par(op)
> 
> 
> 
> graphics::par(get("par.postscript", pos = 'CheckExEnv'))
> cleanEx()
> nameEx("rect")
> ### * rect
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: rect
> ### Title: Draw One or More Rectangles
> ### Aliases: rect
> ### Keywords: aplot
> 
> ### ** Examples
> 
> require(grDevices)
> ## set up the plot region:
> op <- par(bg = "thistle")
> plot(c(100, 250), c(300, 450), type = "n", xlab = "", ylab = "",
+      main = "2 x 11 rectangles; 'rect(100+i,300+i,  150+i,380+i)'")
> i <- 4*(0:10)
> ## draw rectangles with bottom left (100, 300)+i
> ## and top right (150, 380)+i
> rect(100+i, 300+i, 150+i, 380+i, col = rainbow(11, start = 0.7, end = 0.1))
> rect(240-i, 320+i, 250-i, 410+i, col = heat.colors(11), lwd = i/5)
> ## Background alternating  ( transparent / "bg" ) :
> j <- 10*(0:5)
> rect(125+j, 360+j,   141+j, 405+j/2, col = c(NA,0),
+      border = "gold", lwd = 2)
> rect(125+j, 296+j/2, 141+j, 331+j/5, col = c(NA,"midnightblue"))
> mtext("+  2 x 6 rect(*, col = c(NA,0)) and  col = c(NA,\"m..blue\"))")
> 
> ## an example showing colouring and shading
> plot(c(100, 200), c(300, 450), type= "n", xlab = "", ylab = "")
> rect(100, 300, 125, 350) # transparent
> rect(100, 400, 125, 450, col = "green", border = "blue") # coloured
> rect(115, 375, 150, 425, col = par("bg"), border = "transparent")
> rect(150, 300, 175, 350, density = 10, border = "red")
> rect(150, 400, 175, 450, density = 30, col = "blue",
+      angle = -30, border = "transparent")
> 
> legend(180, 450, legend = 1:4, fill = c(NA, "green", par("fg"), "blue"),
+        density = c(NA, NA, 10, 30), angle = c(NA, NA, 30, -30))
> 
> par(op)
> 
> 
> 
> graphics::par(get("par.postscript", pos = 'CheckExEnv'))
> cleanEx()
> nameEx("rug")
> ### * rug
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: rug
> ### Title: Add a Rug to a Plot
> ### Aliases: rug
> ### Keywords: aplot
> 
> ### ** Examples
> 
> require(stats)  # both 'density' and its default method
> with(faithful, {
+     plot(density(eruptions, bw = 0.15))
+     rug(eruptions)
+     rug(jitter(eruptions, amount = 0.01), side = 3, col = "light blue")
+ })
> 
> 
> 
> cleanEx()
> nameEx("screen")
> ### * screen
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: screen
> ### Title: Creating and Controlling Multiple Screens on a Single Device
> ### Aliases: screen split.screen erase.screen close.screen
> ### Keywords: aplot dplot device
> 
> ### ** Examples
> 
> if (interactive()) {
+ par(bg = "white")           # default is likely to be transparent
+ split.screen(c(2, 1))       # split display into two screens
+ split.screen(c(1, 3), screen = 2) # now split the bottom half into 3
+ screen(1) # prepare screen 1 for output
+ plot(10:1)
+ screen(4) # prepare screen 4 for output
+ plot(10:1)
+ close.screen(all = TRUE)    # exit split-screen mode
+ 
+ split.screen(c(2, 1))       # split display into two screens
+ split.screen(c(1, 2), 2)    # split bottom half in two
+ plot(1:10)                  # screen 3 is active, draw plot
+ erase.screen()              # forgot label, erase and redraw
+ plot(1:10, ylab = "ylab 3")
+ screen(1)                   # prepare screen 1 for output
+ plot(1:10)
+ screen(4)                   # prepare screen 4 for output
+ plot(1:10, ylab = "ylab 4")
+ screen(1, FALSE)            # return to screen 1, but do not clear
+ plot(10:1, axes = FALSE, lty = 2, ylab = "")  # overlay second plot
+ axis(4)                     # add tic marks to right-hand axis
+ title("Plot 1")
+ close.screen(all = TRUE)    # exit split-screen mode
+ }
> 
> 
> 
> graphics::par(get("par.postscript", pos = 'CheckExEnv'))
> cleanEx()
> nameEx("segments")
> ### * segments
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: segments
> ### Title: Add Line Segments to a Plot
> ### Aliases: segments
> ### Keywords: aplot
> 
> ### ** Examples
> 
> x <- stats::runif(12); y <- stats::rnorm(12)
> i <- order(x, y); x <- x[i]; y <- y[i]
> plot(x, y, main = "arrows(.) and segments(.)")
> ## draw arrows from point to point :
> s <- seq(length(x)-1)  # one shorter than data
> arrows(x[s], y[s], x[s+1], y[s+1], col= 1:3)
> s <- s[-length(s)]
> segments(x[s], y[s], x[s+2], y[s+2], col= 'pink')
> 
> 
> 
> cleanEx()
> nameEx("smoothScatter")
> ### * smoothScatter
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: smoothScatter
> ### Title: Scatterplots with Smoothed Densities Color Representation
> ### Aliases: smoothScatter
> ### Keywords: hplot
> 
> ### ** Examples
> 
> 
> graphics::par(get("par.postscript", pos = 'CheckExEnv'))
> cleanEx()
> nameEx("spineplot")
> ### * spineplot
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: spineplot
> ### Title: Spine Plots and Spinograms
> ### Aliases: spineplot spineplot.default spineplot.formula
> ### Keywords: hplot
> 
> ### ** Examples
> 
> ## treatment and improvement of patients with rheumatoid arthritis
> treatment <- factor(rep(c(1, 2), c(43, 41)), levels = c(1, 2),
+                     labels = c("placebo", "treated"))
> improved <- factor(rep(c(1, 2, 3, 1, 2, 3), c(29, 7, 7, 13, 7, 21)),
+                    levels = c(1, 2, 3),
+                    labels = c("none", "some", "marked"))
> 
> ## (dependence on a categorical variable)
> (spineplot(improved ~ treatment))
         improved
treatment none some marked
  placebo   29    7      7
  treated   13    7     21
> 
> ## applications and admissions by department at UC Berkeley
> ## (two-way tables)
> (spineplot(margin.table(UCBAdmissions, c(3, 2)),
+            main = "Applications at UCB"))
    Gender
Dept Male Female
   A  825    108
   B  560     25
   C  325    593
   D  417    375
   E  191    393
   F  373    341
> (spineplot(margin.table(UCBAdmissions, c(3, 1)),
+            main = "Admissions at UCB"))
    Admit
Dept Admitted Rejected
   A      601      332
   B      370      215
   C      322      596
   D      269      523
   E      147      437
   F       46      668
> 
> ## NASA space shuttle o-ring failures
> fail <- factor(c(2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1,
+                  1, 1, 1, 2, 1, 1, 1, 1, 1),
+                levels = c(1, 2), labels = c("no", "yes"))
> temperature <- c(53, 57, 58, 63, 66, 67, 67, 67, 68, 69, 70, 70,
+                  70, 70, 72, 73, 75, 75, 76, 76, 78, 79, 81)
> 
> ## (dependence on a numerical variable)
> (spineplot(fail ~ temperature))
           fail
temperature no yes
    [50,55]  0   1
    (55,60]  0   2
    (60,65]  0   1
    (65,70]  8   2
    (70,75]  3   1
    (75,80]  4   0
    (80,85]  1   0
> (spineplot(fail ~ temperature, breaks = 3))
           fail
temperature no yes
    [50,60]  0   3
    (60,70]  8   3
    (70,80]  7   1
    (80,90]  1   0
> (spineplot(fail ~ temperature, breaks = quantile(temperature)))
           fail
temperature no yes
    [53,67]  4   4
    (67,70]  4   2
    (70,75]  3   1
    (75,81]  5   0
> 
> ## highlighting for failures
> spineplot(fail ~ temperature, ylevels = 2:1)
> 
> 
> 
> cleanEx()
> nameEx("stars")
> ### * stars
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: stars
> ### Title: Star (Spider/Radar) Plots and Segment Diagrams
> ### Aliases: stars
> ### Keywords: hplot multivariate
> 
> ### ** Examples
> 
> require(grDevices)
> stars(mtcars[, 1:7], key.loc = c(14, 2),
+       main = "Motor Trend Cars : stars(*, full = F)", full = FALSE)
> stars(mtcars[, 1:7], key.loc = c(14, 1.5),
+       main = "Motor Trend Cars : full stars()", flip.labels = FALSE)
> 
> ## 'Spider' or 'Radar' plot:
> stars(mtcars[, 1:7], locations = c(0, 0), radius = FALSE,
+       key.loc = c(0, 0), main = "Motor Trend Cars", lty = 2)
> 
> ## Segment Diagrams:
> palette(rainbow(12, s = 0.6, v = 0.75))
> stars(mtcars[, 1:7], len = 0.8, key.loc = c(12, 1.5),
+       main = "Motor Trend Cars", draw.segments = TRUE)
> stars(mtcars[, 1:7], len = 0.6, key.loc = c(1.5, 0),
+       main = "Motor Trend Cars", draw.segments = TRUE,
+       frame.plot = TRUE, nrow = 4, cex = .7)
> 
> ## scale linearly (not affinely) to [0, 1]
> USJudge <- apply(USJudgeRatings, 2, function(x) x/max(x))
> Jnam <- row.names(USJudgeRatings)
> Snam <- abbreviate(substring(Jnam, 1, regexpr("[,.]",Jnam) - 1), 7)
> stars(USJudge, labels = Jnam, scale = FALSE,
+       key.loc = c(13, 1.5), main = "Judge not ...", len = 0.8)
> stars(USJudge, labels = Snam, scale = FALSE,
+       key.loc = c(13, 1.5), radius = FALSE)
> 
> loc <- stars(USJudge, labels = NULL, scale = FALSE,
+              radius = FALSE, frame.plot = TRUE,
+              key.loc = c(13, 1.5), main = "Judge not ...", len = 1.2)
> text(loc, Snam, col = "blue", cex = 0.8, xpd = TRUE)
> 
> ## 'Segments':
> stars(USJudge, draw.segments = TRUE, scale = FALSE, key.loc = c(13,1.5))
> 
> ## 'Spider':
> stars(USJudgeRatings, locations = c(0, 0), scale = FALSE, radius  =  FALSE,
+       col.stars = 1:10, key.loc = c(0, 0), main = "US Judges rated")
> ## Same as above, but with colored lines instead of filled polygons.
> stars(USJudgeRatings, locations = c(0, 0), scale = FALSE, radius  =  FALSE,
+       col.lines = 1:10, key.loc = c(0, 0), main = "US Judges rated")
> ## 'Radar-Segments'
> stars(USJudgeRatings[1:10,], locations = 0:1, scale = FALSE,
+       draw.segments = TRUE, col.segments = 0, col.stars = 1:10, key.loc =  0:1,
+       main = "US Judges 1-10 ")
> palette("default")
> stars(cbind(1:16, 10*(16:1)), draw.segments = TRUE,
+       main = "A Joke -- do *not* use symbols on 2D data!")
> 
> 
> 
> cleanEx()
> nameEx("stem")
> ### * stem
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: stem
> ### Title: Stem-and-Leaf Plots
> ### Aliases: stem
> ### Keywords: univar distribution
> 
> ### ** Examples
> 
> stem(islands)

  The decimal point is 3 digit(s) to the right of the |

   0 | 00000000000000000000000000000111111222338
   2 | 07
   4 | 5
   6 | 8
   8 | 4
  10 | 5
  12 | 
  14 | 
  16 | 0

> stem(log10(islands))

  The decimal point is at the |

  1 | 1111112222233444
  1 | 5555556666667899999
  2 | 3344
  2 | 59
  3 | 
  3 | 5678
  4 | 012

> 
> 
> 
> cleanEx()
> nameEx("stripchart")
> ### * stripchart
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: stripchart
> ### Title: 1-D Scatter Plots
> ### Aliases: stripchart stripchart.default stripchart.formula
> ### Keywords: hplot
> 
> ### ** Examples
> 
> x <- stats::rnorm(50)
> xr <- round(x, 1)
> stripchart(x) ; m <- mean(par("usr")[1:2])
> text(m, 1.04, "stripchart(x, \"overplot\")")
> stripchart(xr, method = "stack", add = TRUE, at = 1.2)
> text(m, 1.35, "stripchart(round(x,1), \"stack\")")
> stripchart(xr, method = "jitter", add = TRUE, at = 0.7)
> text(m, 0.85, "stripchart(round(x,1), \"jitter\")")
> 
> stripchart(decrease ~ treatment,
+     main = "stripchart(OrchardSprays)",
+     vertical = TRUE, log = "y", data = OrchardSprays)
> 
> stripchart(decrease ~ treatment, at = c(1:8)^2,
+     main = "stripchart(OrchardSprays)",
+     vertical = TRUE, log = "y", data = OrchardSprays)
> 
> 
> 
> graphics::par(get("par.postscript", pos = 'CheckExEnv'))
> cleanEx()
> nameEx("strwidth")
> ### * strwidth
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: strwidth
> ### Title: Plotting Dimensions of Character Strings and Math Expressions
> ### Aliases: strwidth strheight
> ### Keywords: dplot character
> 
> ### ** Examples
> 
> str.ex <- c("W","w","I",".","WwI.")
> op <- par(pty = "s"); plot(1:100, 1:100, type = "n")
> sw <- strwidth(str.ex); sw
[1] 3.2600930 2.4934186 0.9600698 0.9600698 7.6736512
> all.equal(sum(sw[1:4]), sw[5])
[1] TRUE
> #- since the last string contains the others
> 
> sw.i <- strwidth(str.ex, "inches"); 25.4 * sw.i  # width in [mm]
[1] 3.996267 3.056467 1.176867 1.176867 9.406467
> unique(sw / sw.i)
[1] 20.72093 20.72093
> # constant factor: 1 value
> mean(sw.i / strwidth(str.ex, "fig")) / par('fin')[1]  # = 1: are the same
[1] 1
> 
> ## See how letters fall in classes
> ##  -- depending on graphics device and font!
> all.lett <- c(letters, LETTERS)
> shL <- strheight(all.lett, units = "inches") * 72  # 'big points'
> table(shL)  # all have same heights ...
shL
8.616 
   52 
> mean(shL)/par("cin")[2] # around 0.6
[1] 43.08
> 
> (swL <- strwidth(all.lett, units = "inches") * 72)  # 'big points'
 [1]  6.672  6.672  6.000  6.672  6.672  3.336  6.672  6.672  2.664  2.664
[11]  6.000  2.664  9.996  6.672  6.672  6.672  6.672  3.996  6.000  3.336
[21]  6.672  6.000  8.664  6.000  6.000  6.000  8.004  8.004  8.664  8.664
[31]  8.004  7.332  9.336  8.664  3.336  6.000  8.004  6.672  9.996  8.664
[41]  9.336  8.004  9.336  8.664  8.004  7.332  8.664  8.004 11.328  8.004
[51]  8.004  7.332
> split(all.lett, factor(round(swL, 2)))
$`2.66`
[1] "i" "j" "l"

$`3.34`
[1] "f" "t" "I"

$`4`
[1] "r"

$`6`
[1] "c" "k" "s" "v" "x" "y" "z" "J"

$`6.67`
 [1] "a" "b" "d" "e" "g" "h" "n" "o" "p" "q" "u" "L"

$`7.33`
[1] "F" "T" "Z"

$`8`
[1] "A" "B" "E" "K" "P" "S" "V" "X" "Y"

$`8.66`
[1] "w" "C" "D" "H" "N" "R" "U"

$`9.34`
[1] "G" "O" "Q"

$`10`
[1] "m" "M"

$`11.33`
[1] "W"

> 
> sumex <- expression(sum(x[i], i=1,n), e^{i * pi} == -1)
> strwidth(sumex)
[1]  5.795241 11.484959
> strheight(sumex)
[1] 8.057449 3.420738
> 
> par(op)  #- reset to previous setting
> 
> 
> 
> graphics::par(get("par.postscript", pos = 'CheckExEnv'))
> cleanEx()
> nameEx("sunflowerplot")
> ### * sunflowerplot
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: sunflowerplot
> ### Title: Produce a Sunflower Scatter Plot
> ### Aliases: sunflowerplot sunflowerplot.default sunflowerplot.formula
> ### Keywords: hplot smooth nonparametric
> 
> ### ** Examples
> 
> require(stats)
> require(grDevices)
> 
> ## 'number' is computed automatically:
> sunflowerplot(iris[, 3:4])
> ## Imitating Chambers et al, p.109, closely:
> sunflowerplot(iris[, 3:4], cex = .2, cex.fact = 1, size = .035, seg.lwd = .8)
> ## or
> sunflowerplot(Petal.Width ~ Petal.Length, data = iris,
+               cex = .2, cex.fact = 1, size = .035, seg.lwd = .8)
> 
> 
> sunflowerplot(x = sort(2*round(rnorm(100))), y = round(rnorm(100), 0),
+               main = "Sunflower Plot of Rounded N(0,1)")
> ## Similarly using a "xyTable" argument:
> xyT <- xyTable(x = sort(2*round(rnorm(100))), y = round(rnorm(100), 0),
+                digits = 3)
> utils::str(xyT, vec.len = 20)
List of 3
 $ x     : num [1:25] -6 -4 -4 -4 -4 -2 -2 -2 -2 -2 0 0 0 0 0 0 2 2 2 2 2 4 4 4 4
 $ y     : num [1:25] 0 -2 0 1 2 -2 -1 0 1 2 -3 -2 -1 0 1 2 -2 -1 0 1 3 -1 0 1 2
 $ number: int [1:25] 1 1 1 1 3 1 4 8 4 1 1 3 5 17 12 2 1 8 12 6 1 1 3 2 1
> sunflowerplot(xyT, main = "2nd Sunflower Plot of Rounded N(0,1)")
> 
> ## A 'marked point process' {explicit 'number' argument}:
> sunflowerplot(rnorm(100), rnorm(100), number = rpois(n = 100, lambda = 2),
+               main = "Sunflower plot (marked point process)",
+               rotate = TRUE, col = "blue4")
> 
> 
> 
> cleanEx()
> nameEx("symbols")
> ### * symbols
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: symbols
> ### Title: Draw Symbols (Circles, Squares, Stars, Thermometers, Boxplots)
> ### Aliases: symbols
> ### Keywords: aplot hplot multivariate
> 
> ### ** Examples
> 
> require(stats); require(grDevices)
> x <- 1:10
> y <- sort(10*runif(10))
> z <- runif(10)
> z3 <- cbind(z, 2*runif(10), runif(10))
> symbols(x, y, thermometers = cbind(.5, 1, z), inches = .5, fg = 1:10)
> symbols(x, y, thermometers = z3, inches = FALSE)
> text(x, y, apply(format(round(z3, digits = 2)), 1, paste, collapse = ","),
+      adj = c(-.2,0), cex = .75, col = "purple", xpd = NA)
> 
> ## Note that  example(trees)  shows more sensible plots!
> N <- nrow(trees)
> with(trees, {
+ ## Girth is diameter in inches
+ symbols(Height, Volume, circles = Girth/24, inches = FALSE,
+         main = "Trees' Girth") # xlab and ylab automatically
+ ## Colours too:
+ op <- palette(rainbow(N, end = 0.9))
+ symbols(Height, Volume, circles = Girth/16, inches = FALSE, bg = 1:N,
+         fg = "gray30", main = "symbols(*, circles = Girth/16, bg = 1:N)")
+ palette(op)
+ })
> 
> 
> 
> cleanEx()
> nameEx("title")
> ### * title
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: title
> ### Title: Plot Annotation
> ### Aliases: title
> ### Keywords: aplot
> 
> ### ** Examples
> 
> plot(cars, main = "") # here, could use main directly
> title(main = "Stopping Distance versus Speed")
> 
> plot(cars, main = "")
> title(main = list("Stopping Distance versus Speed", cex = 1.5,
+                   col = "red", font = 3))
> 
> ## Specifying "..." :
> plot(1, col.axis = "sky blue", col.lab = "thistle")
> title("Main Title", sub = "sub title",
+       cex.main = 2,   font.main= 4, col.main= "blue",
+       cex.sub = 0.75, font.sub = 3, col.sub = "red")
> 
> 
> x <- seq(-4, 4, len = 101)
> y <- cbind(sin(x), cos(x))
> matplot(x, y, type = "l", xaxt = "n",
+         main = expression(paste(plain(sin) * phi, "  and  ",
+                                 plain(cos) * phi)),
+         ylab = expression("sin" * phi, "cos" * phi), # only 1st is taken
+         xlab = expression(paste("Phase Angle ", phi)),
+         col.main = "blue")
> axis(1, at = c(-pi, -pi/2, 0, pi/2, pi),
+      labels = expression(-pi, -pi/2, 0, pi/2, pi))
> abline(h = 0, v = pi/2 * c(-1,1), lty = 2, lwd = .1, col = "gray70")
> 
> 
> 
> cleanEx()
> nameEx("units")
> ### * units
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: units
> ### Title: Graphical Units
> ### Aliases: xinch yinch xyinch
> ### Keywords: dplot
> 
> ### ** Examples
> 
> all(c(xinch(), yinch()) == xyinch()) # TRUE
[1] TRUE
> xyinch()
[1] 1.5000000 0.4185559
> xyinch #- to see that is really   delta{"usr"} / "pin"
function (xy = 1, warn.log = TRUE) 
{
    if (warn.log && (par("xlog") || par("ylog"))) 
        warning("log scale:  xyinch() is nonsense")
    u <- par("usr")
    xy * c(u[2L] - u[1L], u[4L] - u[3L])/par("pin")
}
<bytecode: 0x24faea0>
<environment: namespace:graphics>
> 
> ## plot labels offset 0.12 inches to the right
> ## of plotted symbols in a plot
> with(mtcars, {
+     plot(mpg, disp, pch = 19, main = "Motor Trend Cars")
+     text(mpg + xinch(0.12), disp, row.names(mtcars),
+          adj = 0, cex = .7, col = "blue")
+     })
> 
> 
> 
> cleanEx()
> nameEx("xspline")
> ### * xspline
> 
> flush(stderr()); flush(stdout())
> 
> ### Name: xspline
> ### Title: Draw an X-spline
> ### Aliases: xspline
> ### Keywords: aplot
> 
> ### ** Examples
> 
> ## based on examples in ?grid.xspline
> 
> xsplineTest <- function(s, open = TRUE,
+                         x = c(1,1,3,3)/4,
+                         y = c(1,3,3,1)/4, ...) {
+     plot(c(0,1), c(0,1), type = "n", axes = FALSE, xlab = "", ylab = "")
+     points(x, y, pch = 19)
+     xspline(x, y, s, open, ...)
+     text(x+0.05*c(-1,-1,1,1), y+0.05*c(-1,1,1,-1), s)
+ }
> op <- par(mfrow = c(3,3), mar = rep(0,4), oma = c(0,0,2,0))
> xsplineTest(c(0, -1, -1, 0))
> xsplineTest(c(0, -1,  0, 0))
> xsplineTest(c(0, -1,  1, 0))
> xsplineTest(c(0,  0, -1, 0))
> xsplineTest(c(0,  0,  0, 0))
> xsplineTest(c(0,  0,  1, 0))
> xsplineTest(c(0,  1, -1, 0))
> xsplineTest(c(0,  1,  0, 0))
> xsplineTest(c(0,  1,  1, 0))
> title("Open X-splines", outer = TRUE)
> 
> par(mfrow = c(3,3), mar = rep(0,4), oma = c(0,0,2,0))
> xsplineTest(c(0, -1, -1, 0), FALSE, col = "grey80")
> xsplineTest(c(0, -1,  0, 0), FALSE, col = "grey80")
> xsplineTest(c(0, -1,  1, 0), FALSE, col = "grey80")
> xsplineTest(c(0,  0, -1, 0), FALSE, col = "grey80")
> xsplineTest(c(0,  0,  0, 0), FALSE, col = "grey80")
> xsplineTest(c(0,  0,  1, 0), FALSE, col = "grey80")
> xsplineTest(c(0,  1, -1, 0), FALSE, col = "grey80")
> xsplineTest(c(0,  1,  0, 0), FALSE, col = "grey80")
> xsplineTest(c(0,  1,  1, 0), FALSE, col = "grey80")
> title("Closed X-splines", outer = TRUE)
> 
> par(op)
> 
> x <- sort(stats::rnorm(5))
> y <- sort(stats::rnorm(5))
> plot(x, y, pch = 19)
> res <- xspline(x, y, 1, draw = FALSE)
> lines(res)
> ## the end points may be very close together,
> ## so use last few for direction
> nr <- length(res$x)
> arrows(res$x[1], res$y[1], res$x[4], res$y[4], code = 1, length = 0.1)
> arrows(res$x[nr-3], res$y[nr-3], res$x[nr], res$y[nr], code = 2, length = 0.1)
> 
> 
> 
> graphics::par(get("par.postscript", pos = 'CheckExEnv'))
> ### * <FOOTER>
> ###
> options(digits = 7L)
> base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n")
Time elapsed:  2.527 0.055 2.598 0 0 
> grDevices::dev.off()
null device 
          1 
> ###
> ### Local variables: ***
> ### mode: outline-minor ***
> ### outline-regexp: "\\(> \\)?### [*]+" ***
> ### End: ***
> quit('no')