如何在基础R

时间:2015-08-21 11:34:30

标签: r

我有代码来生成以下图:

plot(x_den, axes=F,
     xlim=c(0,1),lwd=2,col="black",
     ylim=c(0,ceiling(max(x_den)))

axis(2, at=seq(0,ceiling(max(x_den)),by = 0.5),las=1 )
axis(1, at=seq(0,1,by = 0.1),las=1 )
abline(v=0.05,col="red",lty=2,lwd=2)

我现在想要遮蔽(红色)x = 0.05左边的曲线部分。我试图用以下内容绘制:

polygon(c(x_den$x[x_den$x<0.05],rev(x_den$x[x_den$x<0.05]) ),
        c(rev(x_den$y[x_den$x<0.05]),x_den$y[x_den$x<0.05] ),
        col=makeTransparent("red"), border="black" )

但这不起作用。

如何使用使用任何完整的绘图软件包(例如lattice或ggplot2)

要从x_denx功能重新创建makeTransparent的数据:

> dput(x)
structure(c(0.002, 0.037, 0.545, 0.545, 0.383, 0.605, 0.14, 0.002, 
0.158, 0.034, 0.306, 0.849, 0.409, 0.162, 0.002, 0.002, 0.027, 
0.566, 0.045, 0.031, 0.127, 0.00899, 0.68, 0.68, 0.18, 0.019, 
0.366, 0.015, 0.005, 0.418, 0.003, 0.522, 0.133, 0.653, 0.141, 
0.844, 0.575, 0.21, 0.248, 0.248, 0.021, 0.211, 0.211, 0.0929, 
0.421, 0.76, 0.153, 0.788, 0.487, 0.476, 0.355, 0.391, 0.5, 0.5, 
0.035, 0.000999, 0.62, 0.026, 0.022, 0.139, 0.374, 0.848, 0.624, 
0.002, 0.002, 0.002, 0.39, 0.39, 0.762, 0.03, 0.037, 0.00899, 
0.0689, 0.516, 0.224, 0.36, 0.000999, 0.125, 0.03, 0.023, 0.206, 
0.353, 0.968, 0.0699, 0.306, 0.409, 0.139, 0.102, 0.00799, 0.0579, 
0.347, 0.577, 0.00799, 0.355, 0.35, 0.000999, 0.002, 0.5, 0.138, 
0.299, 0.245, 0.049, 0.00799, 0.0669, 0.017, 0.569, 0.711, 0.317, 
0.135, 0.04, 0.017, 0.882, 0.12, 0.116, 0.169, 0.328, 0.176, 
0.52, 0.02, 0.131, 0.24, 0.21, 0.125, 0.504, 0.004, 0.0529, 0.132, 
0.032, 0.401, 0.0639, 0.213, 0.123, 0.024, 0.024, 0.639, 0.262, 
0.213, 0.371, 0.0839, 0.24, 0.0679, 0.0679, 0.152, 0.143, 0.000999, 
0.000999, 0.362, 0.000999, 0.005, 0.118, 0.005, 0.045, 0.012, 
0.139, 0.265, 0.0769, 0.002, 0.003, 0.239, 0.164, 0.153, 0.047, 
0.559, 0.016, 0.486, 0.27, 0.439, 0.0679, 0.00799, 0.885, 0.245, 
0.000999, 0.027, 0.217, 0.0569, 0.022, 0.218, 0.513, 0.00799, 
0.017, 0.208, 0.035, 0.035, 0.183, 0.296, 0.793, 0.516, 0.411, 
0.743, 0.146, 0.00599, 0.37, 0.37, 0.012, 0.101, 0.163, 0.72, 
0.312, 0.682, 0.323, 0.205, 0.00999, 0.923, 0.693, 0.149, 0.0659, 
0.183, 0.196, 0.0619, 0.17, 0.17, 0.208, 0.02, 0.036, 0.000999, 
0.139, 0.24, 0.427, 0.258, 0.132, 0.161, 0.0639, 0.05, 0.73, 
0.73, 0.0719, 0.959, 0.02, 0.135, 0.628, 0.027, 0.522, 0.031, 
0.534, 0.205, 0.00599, 0.027, 0.0899, 0.306, 0.0519, 0.015, 0.205, 
0.532, 0.046, 0.0619, 0.02, 0.0869, 0.0519, 0.0519, 0.378, 0.293, 
0.379, 0.456, 0.153, 0.114, 0.289, 0.764, 0.00799, 0.238, 0.304, 
0.385, 0.183, 0.47, 0.578, 0.146, 0.428, 0.206, 0.58, 0.794, 
0.232, 0.147, 0.043, 0.508, 0.0839, 0.243, 0.0759, 0.022, 0.39, 
0.406, 0.24, 0.144, 0.901, 0.675, 0.897, 0.777, 0.428, 0.428, 
0.017, 0.02, 0.015, 0.042, 0.812, 0.0929, 0.465, 0.000999, 0.124, 
0.124, 0.437, 0.042, 0.364, 0.222, 0.498, 0.66, 0.134, 0.03, 
0.283, 0.02, 0.026, 0.615, 0.8, 0.504, 0.746, 0.115, 0.00799, 
0.123, 0.465, 0.427, 0.567, 0.000999, 0.0849, 0.385, 0.000999, 
0.559, 0.0699, 0.66, 0.309, 0.033, 0.148, 0.174, 0.000999, 0.611, 
0.029, 0.18, 0.00799, 0.493, 0.0849, 0.18, 0.123, 0.147, 0.128, 
0.0639, 0.004, 0.13), na.action = structure(c(2L, 4L, 5L, 6L, 
7L, 8L, 9L, 10L, 11L, 12L, 13L, 17L, 18L, 19L, 20L, 21L, 22L, 
23L, 24L, 26L, 27L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 
38L, 39L, 41L, 42L, 43L, 44L, 45L, 46L, 50L, 51L, 52L, 53L, 54L, 
55L, 56L, 58L, 59L, 60L, 61L, 63L, 65L, 66L, 67L, 68L, 69L, 70L, 
72L, 73L, 74L, 75L, 76L, 77L, 78L, 79L, 80L, 81L, 82L, 83L, 84L, 
85L, 86L, 87L, 88L, 89L, 90L, 91L, 92L, 93L, 94L, 95L, 96L, 97L, 
98L, 99L, 100L, 101L, 102L, 103L, 104L, 106L, 107L, 108L, 109L, 
110L, 111L, 112L, 113L, 114L, 115L, 116L, 117L, 118L, 119L, 120L, 
121L, 122L, 123L, 124L, 125L, 126L, 127L, 128L, 129L, 130L, 131L, 
132L, 133L, 134L, 136L, 137L, 138L, 139L, 140L, 141L, 142L, 146L, 
147L, 153L, 154L, 158L, 160L, 161L, 162L, 163L, 164L, 165L, 166L, 
167L, 168L, 169L, 170L, 171L, 172L, 173L, 174L, 175L, 176L, 177L, 
178L, 179L, 180L, 181L, 182L, 183L, 184L, 185L, 186L, 187L, 189L, 
190L, 191L, 192L, 194L, 195L, 196L, 197L, 198L, 199L, 201L, 202L, 
203L, 204L, 205L, 206L, 207L, 208L, 209L, 210L, 212L, 213L, 214L, 
215L, 216L, 217L, 218L, 220L, 222L, 223L, 225L, 226L, 227L, 228L, 
229L, 230L, 231L, 232L, 233L, 234L, 235L, 236L, 237L, 238L, 239L, 
240L, 242L, 243L, 245L, 246L, 248L, 249L, 250L, 252L, 253L, 254L, 
256L, 257L, 258L, 259L, 262L, 263L, 265L, 266L, 267L, 268L, 269L, 
270L, 271L, 272L, 273L, 274L, 275L, 276L, 277L, 278L, 280L, 281L, 
282L, 283L, 284L, 285L, 286L, 287L, 289L, 290L, 291L, 292L, 293L, 
294L, 295L, 296L, 297L, 298L, 299L, 300L, 301L, 302L, 303L, 305L, 
306L, 307L, 308L, 309L, 310L, 311L, 312L, 313L, 314L, 316L, 317L, 
318L, 319L, 320L, 321L, 322L, 323L, 325L, 326L, 327L, 328L, 329L, 
331L, 332L, 333L, 334L, 335L, 336L, 338L, 339L, 340L, 341L, 342L, 
343L, 345L, 346L, 347L, 350L, 352L, 353L, 354L, 356L, 357L, 358L, 
359L, 360L, 362L, 363L, 364L, 365L, 366L, 367L, 370L, 371L, 372L, 
373L, 374L, 375L, 376L, 377L, 378L, 379L, 380L, 383L, 384L, 385L, 
386L, 387L, 388L, 389L, 390L, 391L, 392L, 393L, 394L, 395L, 396L, 
397L, 398L, 399L, 400L, 401L, 402L, 403L, 404L, 405L, 406L, 408L, 
409L, 410L, 412L, 413L, 414L, 415L, 416L, 417L, 421L, 422L, 423L, 
424L, 425L, 428L, 429L, 430L, 431L, 432L, 433L, 435L, 436L, 437L, 
438L, 439L, 440L, 441L, 442L, 443L, 444L, 445L, 446L, 447L, 448L, 
449L, 450L, 451L, 453L, 454L, 455L, 456L, 457L, 459L, 460L, 461L, 
462L, 463L, 464L, 466L, 467L, 469L, 470L, 471L, 472L, 473L, 474L, 
475L, 476L, 477L, 478L, 479L, 480L, 481L, 482L, 483L, 487L, 488L, 
489L, 490L, 491L, 492L, 493L, 495L, 496L, 497L, 498L, 499L, 500L, 
501L, 502L, 503L, 504L, 505L, 506L, 508L, 509L, 510L, 511L, 512L, 
513L, 514L, 515L, 516L, 517L, 518L, 519L, 520L, 521L, 522L, 523L, 
524L, 525L, 526L, 527L, 528L, 529L, 531L, 532L, 533L, 534L, 535L, 
536L, 537L, 538L, 539L, 541L, 542L, 543L, 544L, 545L, 546L, 547L, 
548L, 549L, 550L, 551L, 552L, 553L, 554L, 555L, 556L, 557L, 558L, 
559L, 560L, 561L, 562L, 563L, 564L, 565L, 566L, 567L, 568L, 569L, 
570L, 571L, 572L, 573L, 574L, 575L, 576L, 577L, 578L, 579L, 580L, 
581L, 583L, 584L, 585L, 586L, 587L, 588L, 589L, 590L, 591L, 593L, 
594L, 595L, 596L, 597L, 598L, 599L, 600L, 601L, 602L, 603L, 604L, 
606L, 607L, 608L, 610L, 611L, 612L, 613L, 614L, 615L, 616L, 617L, 
618L, 619L, 620L, 622L, 623L, 624L, 627L, 628L, 629L, 630L, 631L, 
632L, 633L, 634L, 635L, 636L, 637L, 639L, 640L, 641L, 642L, 643L, 
644L, 645L, 646L, 647L, 648L, 649L, 650L, 651L, 652L, 653L, 654L, 
655L, 656L, 658L, 659L, 660L, 661L, 662L, 663L, 664L, 665L, 666L, 
667L, 668L, 669L, 671L, 672L, 674L, 675L, 676L, 677L, 678L, 679L, 
681L, 682L, 683L, 684L, 685L, 686L, 687L, 688L, 689L, 690L, 691L, 
692L, 693L, 694L, 695L, 696L, 697L, 698L, 699L, 700L, 701L, 702L, 
703L, 704L, 705L, 706L, 707L, 708L, 709L, 710L, 711L, 712L, 714L, 
715L, 718L, 719L, 721L, 725L, 729L, 730L, 731L, 732L, 733L, 734L, 
735L, 736L, 737L, 738L, 739L, 741L, 742L, 743L, 744L, 745L, 747L, 
748L, 749L, 750L, 751L, 752L, 753L, 754L, 755L, 756L, 757L, 758L, 
759L, 761L, 762L, 763L, 764L, 765L, 766L, 768L, 769L, 770L, 771L, 
772L, 773L, 774L, 775L, 776L, 777L, 778L, 779L, 781L, 782L, 783L, 
784L, 786L, 787L, 788L, 790L, 791L, 792L, 793L, 794L, 795L, 796L, 
797L, 798L, 799L, 800L, 801L, 802L, 803L, 804L, 805L, 806L, 807L, 
808L, 809L, 811L, 812L, 813L, 814L, 815L, 817L, 818L, 819L, 820L, 
821L, 822L, 824L, 826L, 827L, 830L, 831L, 832L, 833L, 834L, 835L, 
836L, 837L, 839L, 842L, 843L, 844L, 845L, 846L, 847L, 849L, 851L, 
852L, 853L, 854L, 855L, 856L, 857L, 859L, 860L, 861L, 862L, 863L, 
864L, 865L, 866L, 867L, 870L, 871L, 872L, 873L, 875L, 876L, 877L, 
878L, 879L, 881L, 882L, 883L, 884L, 885L, 886L, 888L, 889L, 890L, 
892L, 893L, 894L, 895L, 897L, 898L, 899L, 900L, 901L, 902L, 904L, 
905L, 906L, 907L, 908L, 909L, 910L, 911L, 912L, 913L, 914L, 915L, 
916L, 917L, 918L, 920L, 921L, 922L, 923L, 924L, 925L, 926L, 927L, 
928L, 929L, 931L, 932L, 933L, 934L, 935L, 936L, 938L, 939L, 940L, 
941L, 942L, 943L, 944L, 945L, 946L, 947L, 948L, 949L, 950L, 951L, 
952L, 953L, 954L, 955L, 956L, 957L, 958L, 959L, 960L, 961L, 962L, 
963L, 964L, 965L, 966L, 967L, 970L, 971L, 972L, 973L, 974L, 975L, 
976L, 978L, 979L, 980L, 981L, 982L, 983L, 984L, 986L, 987L, 988L, 
990L, 992L, 993L, 994L, 995L, 996L, 997L, 998L, 999L, 1000L, 
1001L, 1002L, 1003L, 1004L, 1005L, 1006L, 1007L, 1008L, 1009L, 
1010L, 1011L, 1014L, 1015L, 1016L, 1017L, 1018L, 1019L, 1020L, 
1021L, 1022L, 1023L, 1024L, 1025L, 1026L, 1027L, 1028L, 1029L, 
1030L, 1031L, 1032L, 1033L, 1034L, 1035L, 1036L, 1037L, 1038L, 
1039L, 1042L, 1043L, 1044L, 1045L, 1047L, 1049L, 1050L, 1051L, 
1052L, 1053L, 1054L, 1055L, 1056L, 1059L, 1060L, 1061L, 1062L, 
1063L, 1064L, 1065L, 1066L, 1067L, 1068L, 1069L, 1071L, 1072L, 
1073L, 1074L, 1075L, 1078L, 1080L, 1081L, 1082L, 1083L, 1084L, 
1085L, 1086L, 1087L, 1088L, 1089L, 1090L, 1091L, 1092L, 1093L, 
1094L, 1095L, 1096L, 1097L, 1098L, 1099L, 1100L, 1105L, 1106L, 
1107L, 1109L, 1110L, 1111L, 1112L, 1113L, 1114L, 1115L, 1116L, 
1118L, 1119L, 1120L, 1121L, 1122L, 1123L, 1126L, 1127L, 1128L, 
1129L, 1130L, 1131L, 1132L, 1134L, 1136L, 1137L, 1138L, 1140L, 
1142L, 1143L, 1144L, 1145L, 1146L, 1147L, 1148L, 1149L, 1150L, 
1151L, 1152L, 1153L, 1155L, 1156L, 1157L, 1158L, 1159L, 1160L, 
1161L, 1162L, 1163L, 1164L, 1165L, 1166L, 1167L, 1168L, 1169L, 
1170L, 1171L, 1172L, 1173L, 1174L, 1175L, 1176L, 1177L, 1178L, 
1180L, 1181L, 1182L, 1183L, 1184L, 1185L, 1186L, 1187L, 1188L, 
1190L, 1191L, 1192L, 1193L, 1194L, 1195L, 1196L, 1197L, 1199L, 
1201L, 1203L, 1204L, 1205L, 1206L, 1207L, 1208L, 1209L, 1211L, 
1213L, 1214L, 1215L, 1216L, 1217L, 1218L, 1219L, 1220L, 1221L, 
1222L, 1223L, 1225L, 1226L, 1227L, 1228L, 1229L, 1230L, 1231L, 
1232L, 1233L, 1234L, 1235L, 1237L, 1238L, 1239L, 1240L, 1242L, 
1244L, 1245L, 1246L, 1247L, 1248L, 1250L, 1251L, 1252L, 1253L, 
1254L, 1255L, 1256L, 1257L, 1258L, 1259L, 1260L, 1261L, 1262L, 
1263L, 1264L, 1265L, 1266L, 1267L, 1268L, 1269L, 1270L, 1273L, 
1274L, 1275L, 1276L, 1277L, 1278L, 1279L, 1280L, 1281L, 1282L, 
1283L, 1284L, 1285L, 1286L, 1287L, 1288L, 1289L, 1290L, 1291L, 
1292L, 1293L, 1294L, 1295L, 1297L, 1298L, 1299L, 1300L, 1301L, 
1303L, 1304L, 1306L, 1307L, 1308L, 1309L, 1310L, 1311L, 1312L, 
1313L, 1314L, 1315L, 1316L, 1317L, 1318L, 1319L, 1321L, 1322L, 
1323L, 1324L, 1325L, 1326L, 1327L, 1328L, 1329L, 1330L, 1331L, 
1332L, 1333L, 1334L, 1335L, 1336L, 1337L, 1338L, 1339L, 1340L, 
1341L, 1342L, 1345L, 1346L, 1347L, 1348L, 1349L, 1350L, 1351L, 
1352L, 1353L, 1355L, 1356L, 1357L, 1358L, 1359L, 1360L, 1361L, 
1362L, 1363L, 1364L, 1365L, 1366L, 1367L, 1368L, 1369L, 1370L, 
1371L, 1372L, 1374L, 1375L, 1378L, 1379L, 1380L, 1381L, 1382L, 
1383L, 1386L, 1388L, 1389L, 1390L, 1392L, 1393L, 1394L, 1395L, 
1396L, 1397L, 1398L, 1399L, 1400L, 1401L, 1402L, 1403L, 1404L, 
1405L, 1406L, 1407L, 1408L, 1409L, 1410L, 1411L, 1412L, 1413L, 
1414L, 1415L, 1416L, 1417L, 1420L, 1421L, 1422L, 1423L, 1424L, 
1425L, 1427L, 1428L, 1429L, 1430L, 1431L, 1432L, 1433L, 1434L, 
1436L, 1437L, 1438L, 1439L, 1440L, 1441L, 1443L, 1444L, 1445L, 
1446L, 1447L, 1448L, 1449L, 1450L, 1451L, 1453L, 1454L, 1455L, 
1456L, 1457L, 1458L, 1459L, 1460L, 1461L, 1462L, 1463L, 1464L, 
1465L, 1466L, 1467L, 1468L, 1469L, 1470L, 1472L, 1473L, 1474L, 
1475L, 1476L, 1477L, 1478L, 1480L, 1481L, 1482L, 1483L, 1484L, 
1485L, 1486L, 1487L, 1488L, 1489L, 1490L, 1491L, 1492L, 1493L, 
1494L, 1495L, 1496L, 1499L, 1500L, 1501L, 1503L, 1504L, 1505L, 
1506L, 1507L, 1508L, 1510L, 1511L, 1512L, 1513L, 1514L, 1515L, 
1516L, 1518L, 1520L, 1523L, 1524L, 1526L, 1527L, 1528L, 1529L, 
1530L, 1531L, 1532L, 1533L, 1534L, 1535L, 1536L, 1537L, 1538L, 
1539L, 1540L, 1541L, 1542L, 1543L, 1545L, 1546L, 1547L, 1552L, 
1553L, 1554L, 1555L, 1556L, 1557L, 1558L, 1559L, 1562L, 1563L, 
1564L, 1565L, 1566L, 1567L, 1568L, 1569L, 1570L, 1571L, 1572L, 
1573L, 1574L, 1575L, 1576L, 1577L, 1578L, 1579L, 1580L, 1581L, 
1582L, 1583L, 1584L, 1585L, 1586L, 1587L, 1588L, 1590L, 1591L, 
1593L, 1595L, 1596L, 1597L, 1598L, 1599L, 1600L, 1601L, 1602L, 
1604L, 1605L, 1606L, 1607L, 1608L, 1610L, 1611L, 1612L, 1614L, 
1615L, 1616L, 1617L, 1618L, 1620L, 1621L, 1622L, 1623L, 1624L, 
1625L, 1626L, 1627L, 1628L, 1629L, 1630L, 1631L, 1632L, 1633L, 
1634L, 1635L, 1636L, 1637L, 1639L, 1643L, 1644L, 1645L, 1646L, 
1647L, 1648L, 1649L, 1650L, 1651L, 1652L, 1654L, 1655L, 1656L, 
1657L, 1658L, 1659L, 1660L, 1663L, 1664L, 1665L, 1666L, 1667L, 
1668L, 1669L, 1670L, 1672L, 1673L, 1674L, 1675L, 1676L, 1677L, 
1678L, 1679L, 1680L, 1682L, 1683L, 1684L, 1685L, 1686L, 1687L, 
1688L, 1689L, 1690L, 1692L, 1694L, 1695L, 1696L, 1701L, 1702L, 
1703L, 1707L, 1708L, 1709L, 1710L, 1711L, 1712L, 1713L, 1714L, 
1715L, 1716L, 1717L, 1718L, 1719L, 1720L, 1721L, 1722L, 1723L, 
1724L, 1725L, 1726L, 1727L, 1728L, 1729L, 1730L, 1732L, 1733L, 
1734L, 1735L, 1736L, 1737L, 1738L, 1739L, 1740L, 1741L, 1742L, 
1743L, 1744L, 1745L, 1747L, 1750L, 1751L, 1752L, 1753L, 1754L, 
1755L, 1756L, 1757L, 1758L, 1759L, 1760L, 1761L, 1762L, 1763L, 
1764L, 1765L, 1766L, 1767L, 1768L, 1769L, 1770L, 1771L, 1772L, 
1773L, 1774L, 1775L, 1776L, 1777L, 1778L, 1779L, 1780L, 1781L, 
1782L, 1783L, 1784L, 1785L, 1786L, 1787L, 1788L, 1789L, 1790L, 
1791L, 1792L, 1793L, 1794L, 1795L, 1796L, 1797L, 1798L, 1799L, 
1800L, 1801L, 1802L, 1803L, 1804L, 1805L, 1806L, 1807L, 1808L, 
1809L, 1810L, 1811L, 1812L, 1813L, 1814L, 1815L, 1816L, 1817L, 
1818L, 1820L, 1823L, 1824L, 1825L, 1826L, 1827L, 1828L, 1829L, 
1830L, 1833L, 1834L, 1835L, 1836L, 1837L, 1838L, 1839L, 1840L, 
1841L, 1842L, 1843L, 1844L, 1845L, 1848L, 1849L, 1850L, 1851L, 
1852L, 1854L, 1855L, 1856L, 1857L, 1858L, 1860L, 1861L, 1862L, 
1863L, 1865L, 1866L, 1867L, 1868L, 1870L, 1871L, 1872L, 1873L, 
1874L, 1875L, 1876L, 1877L, 1878L, 1879L, 1881L, 1882L, 1883L, 
1884L, 1885L, 1886L, 1887L, 1888L, 1889L, 1891L, 1892L, 1893L, 
1894L, 1895L, 1896L, 1897L, 1898L, 1899L, 1900L, 1902L, 1903L, 
1904L, 1905L, 1906L, 1908L, 1909L, 1910L, 1911L, 1912L, 1913L, 
1914L, 1915L, 1916L, 1917L, 1918L, 1919L, 1920L, 1921L, 1922L, 
1923L, 1924L, 1925L, 1926L, 1927L, 1928L, 1929L, 1930L, 1931L, 
1932L, 1936L, 1937L, 1938L, 1939L, 1940L, 1941L, 1942L, 1943L, 
1944L, 1945L, 1946L, 1947L, 1948L, 1949L, 1950L, 1951L, 1952L, 
1953L, 1954L, 1955L, 1956L, 1958L, 1959L, 1960L, 1961L, 1962L, 
1963L, 1964L, 1965L, 1966L, 1967L, 1970L, 1972L, 1973L, 1974L, 
1975L, 1976L, 1977L, 1978L, 1979L, 1980L, 1981L, 1982L, 1983L, 
1984L, 1985L, 1986L, 1987L, 1988L, 1989L, 1990L, 1991L, 1992L, 
1994L, 1995L, 1996L, 1997L, 1998L, 1999L, 2000L, 2001L, 2003L, 
2004L, 2005L, 2006L, 2007L, 2008L, 2009L, 2010L, 2011L, 2012L, 
2013L, 2014L, 2015L, 2016L, 2019L, 2020L, 2021L, 2022L, 2023L, 
2024L, 2025L, 2026L, 2027L, 2028L, 2029L, 2032L, 2033L, 2034L, 
2035L, 2036L, 2037L, 2038L, 2039L, 2040L, 2041L, 2042L, 2043L, 
2044L, 2045L, 2046L, 2047L, 2048L, 2050L, 2051L, 2052L, 2053L, 
2054L, 2055L, 2057L, 2058L, 2059L, 2060L, 2061L, 2062L, 2063L, 
2065L, 2066L, 2067L, 2068L, 2069L, 2071L, 2072L, 2073L, 2074L, 
2075L, 2076L, 2077L, 2078L, 2079L, 2080L, 2082L, 2083L, 2085L, 
2086L, 2087L, 2088L, 2089L, 2090L, 2091L, 2092L, 2093L, 2094L, 
2095L, 2096L, 2097L, 2098L, 2100L, 2102L, 2103L, 2104L, 2105L, 
2106L, 2107L, 2108L, 2109L, 2110L, 2111L, 2112L, 2113L, 2114L, 
2117L, 2118L, 2119L, 2120L, 2121L, 2122L, 2123L, 2124L, 2125L, 
2127L, 2129L, 2130L, 2131L, 2132L, 2137L, 2138L, 2140L, 2141L, 
2142L, 2143L, 2144L, 2147L, 2148L, 2149L, 2150L, 2151L, 2152L, 
2153L, 2154L, 2155L, 2156L, 2157L, 2158L, 2159L, 2160L, 2161L, 
2162L, 2163L, 2164L, 2165L, 2166L, 2167L, 2169L, 2170L, 2171L, 
2172L, 2173L, 2174L, 2175L, 2176L, 2177L, 2178L, 2179L, 2182L, 
2183L, 2184L, 2185L, 2186L, 2188L, 2191L, 2192L, 2193L, 2195L, 
2198L, 2199L, 2200L, 2201L, 2202L, 2203L, 2204L, 2205L, 2206L, 
2207L, 2208L, 2209L, 2210L, 2211L, 2212L, 2213L, 2215L, 2216L, 
2218L, 2220L, 2221L, 2222L, 2223L, 2224L, 2225L, 2226L, 2227L, 
2228L, 2229L, 2230L, 2231L, 2232L, 2233L, 2234L, 2237L, 2238L, 
2240L, 2241L, 2242L, 2243L, 2244L, 2245L, 2246L, 2248L, 2249L, 
2250L, 2251L, 2252L, 2253L, 2254L, 2255L, 2256L, 2259L, 2260L, 
2261L, 2262L, 2263L, 2264L, 2265L, 2266L, 2268L, 2269L, 2271L, 
2272L, 2273L, 2274L, 2275L, 2276L, 2277L, 2278L, 2279L, 2280L, 
2281L, 2282L, 2283L, 2284L, 2285L, 2286L, 2287L, 2288L, 2289L, 
2290L, 2291L, 2292L, 2293L, 2294L, 2295L, 2296L, 2297L, 2299L, 
2300L, 2301L, 2302L, 2303L, 2304L, 2305L, 2306L, 2307L, 2308L, 
2309L, 2310L, 2311L, 2312L, 2313L, 2314L, 2315L, 2317L, 2318L, 
2320L, 2321L, 2322L, 2323L, 2324L, 2325L, 2326L, 2327L, 2328L, 
2329L, 2330L, 2331L, 2332L, 2333L, 2334L, 2335L, 2336L, 2337L, 
2338L, 2339L, 2340L, 2341L, 2342L, 2343L, 2344L, 2345L, 2346L, 
2347L, 2349L, 2350L, 2351L, 2352L, 2353L, 2354L, 2355L, 2356L, 
2357L, 2358L, 2360L, 2361L, 2362L, 2364L, 2365L, 2366L, 2367L, 
2368L, 2369L, 2371L, 2372L, 2373L, 2374L, 2375L, 2376L, 2378L, 
2379L, 2381L, 2382L, 2383L, 2384L, 2385L, 2386L, 2387L, 2388L, 
2389L, 2390L, 2392L, 2393L, 2394L, 2398L, 2399L, 2400L, 2401L, 
2402L, 2403L, 2404L, 2405L, 2406L, 2407L, 2408L, 2409L, 2410L, 
2411L, 2412L, 2413L, 2414L, 2415L, 2416L, 2419L, 2420L, 2423L, 
2424L, 2425L, 2426L, 2427L, 2428L, 2429L, 2430L, 2431L, 2432L, 
2433L, 2434L, 2435L, 2436L, 2437L, 2438L, 2439L, 2440L, 2441L, 
2444L, 2445L, 2446L, 2447L, 2448L, 2449L, 2450L, 2451L, 2452L, 
2453L, 2454L, 2455L, 2456L, 2457L, 2462L, 2463L, 2464L, 2465L, 
2466L, 2467L, 2468L, 2470L, 2471L, 2472L, 2473L, 2474L, 2475L, 
2476L, 2477L, 2478L, 2479L, 2480L, 2481L, 2482L, 2483L, 2484L, 
2485L, 2487L, 2491L, 2492L, 2493L, 2494L, 2495L, 2496L, 2497L, 
2498L, 2500L, 2501L, 2502L, 2503L, 2504L, 2506L, 2508L, 2509L, 
2510L, 2511L, 2512L, 2513L, 2515L), class = "omit"))

x_den = density(x)

makeTransparent <- function(..., alpha=0.5) {

    if(alpha<0 | alpha>1) stop("alpha must be between 0 and 1")

    alpha = floor(255*alpha)  
    newColor = col2rgb(col=unlist(list(...)), alpha=FALSE)

    .makeTransparent = function(col, alpha) {
        rgb(red=col[1], green=col[2], blue=col[3], alpha=alpha, maxColorValue=255)
    }

    newColor = apply(newColor, 2, .makeTransparent, alpha=alpha)

    return(newColor)

}

0 个答案:

没有答案