基本上,我希望这个情节只能展示" LGA"和" MLS"当观众第一次看到情节时。
以下是情节的代码:
# interactive plot with ribbon
test <- ggplot(data = wide.data, aes(x = x, y = pred)) +
geom_ribbon(aes(ymin = lwr, ymax = upr, fill = model), alpha = .5) +
geom_point(aes( group = model, fill = model)) +
labs(x = "Number of Games Played", y = "Total Number of Goals") + scale_y_continuous(breaks=seq(0,70,5)) +
scale_x_continuous(breaks=seq(0,50,5))
p <- ggplotly(test)
如果您更喜欢在本地进行绘图,请输入以下数据:
> dput(wide.data)
structure(list(x = c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L,
5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L,
8L, 8L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 10L, 10L, 10L,
10L, 10L, 10L, 11L, 11L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L,
12L, 12L, 13L, 13L, 13L, 13L, 13L, 13L, 14L, 14L, 14L, 14L, 14L,
14L, 15L, 15L, 15L, 15L, 15L, 15L, 16L, 16L, 16L, 16L, 16L, 16L,
17L, 17L, 17L, 17L, 17L, 17L, 18L, 18L, 18L, 18L, 18L, 18L, 19L,
19L, 19L, 19L, 19L, 19L, 20L, 20L, 20L, 20L, 20L, 20L, 21L, 21L,
21L, 21L, 21L, 21L, 22L, 22L, 22L, 22L, 22L, 22L, 23L, 23L, 23L,
23L, 23L, 23L, 24L, 24L, 24L, 24L, 24L, 24L, 25L, 25L, 25L, 25L,
25L, 25L, 26L, 26L, 26L, 26L, 26L, 26L, 27L, 27L, 27L, 27L, 27L,
27L, 28L, 28L, 28L, 28L, 28L, 28L, 29L, 29L, 29L, 29L, 29L, 29L,
30L, 30L, 30L, 30L, 30L, 30L, 31L, 31L, 31L, 31L, 31L, 31L, 32L,
32L, 32L, 32L, 32L, 32L, 33L, 33L, 33L, 33L, 33L, 33L, 34L, 34L,
34L, 34L, 34L, 34L, 35L, 35L, 35L, 35L, 35L, 35L, 36L, 36L, 36L,
36L, 36L, 36L, 37L, 37L, 37L, 37L, 37L, 37L, 38L, 38L, 38L, 38L,
38L, 38L), model = c("BLI", "BPL", "LG1", "LGA", "MLS", "SRA",
"BLI", "BPL", "LG1", "LGA", "MLS", "SRA", "BLI", "BPL", "LG1",
"LGA", "MLS", "SRA", "BLI", "BPL", "LG1", "LGA", "MLS", "SRA",
"BLI", "BPL", "LG1", "LGA", "MLS", "SRA", "BLI", "BPL", "LG1",
"LGA", "MLS", "SRA", "BLI", "BPL", "LG1", "LGA", "MLS", "SRA",
"BLI", "BPL", "LG1", "LGA", "MLS", "SRA", "BLI", "BPL", "LG1",
"LGA", "MLS", "SRA", "BLI", "BPL", "LG1", "LGA", "MLS", "SRA",
"BLI", "BPL", "LG1", "LGA", "MLS", "SRA", "BLI", "BPL", "LG1",
"LGA", "MLS", "SRA", "BLI", "BPL", "LG1", "LGA", "MLS", "SRA",
"BLI", "BPL", "LG1", "LGA", "MLS", "SRA", "BLI", "BPL", "LG1",
"LGA", "MLS", "SRA", "BLI", "BPL", "LG1", "LGA", "MLS", "SRA",
"BLI", "BPL", "LG1", "LGA", "MLS", "SRA", "BLI", "BPL", "LG1",
"LGA", "MLS", "SRA", "BLI", "BPL", "LG1", "LGA", "MLS", "SRA",
"BLI", "BPL", "LG1", "LGA", "MLS", "SRA", "BLI", "BPL", "LG1",
"LGA", "MLS", "SRA", "BLI", "BPL", "LG1", "LGA", "MLS", "SRA",
"BLI", "BPL", "LG1", "LGA", "MLS", "SRA", "BLI", "BPL", "LG1",
"LGA", "MLS", "SRA", "BLI", "BPL", "LG1", "LGA", "MLS", "SRA",
"BLI", "BPL", "LG1", "LGA", "MLS", "SRA", "BLI", "BPL", "LG1",
"LGA", "MLS", "SRA", "BLI", "BPL", "LG1", "LGA", "MLS", "SRA",
"BLI", "BPL", "LG1", "LGA", "MLS", "SRA", "BLI", "BPL", "LG1",
"LGA", "MLS", "SRA", "BLI", "BPL", "LG1", "LGA", "MLS", "SRA",
"BLI", "BPL", "LG1", "LGA", "MLS", "SRA", "BLI", "BPL", "LG1",
"LGA", "MLS", "SRA", "BLI", "BPL", "LG1", "LGA", "MLS", "SRA",
"BLI", "BPL", "LG1", "LGA", "MLS", "SRA", "BLI", "BPL", "LG1",
"LGA", "MLS", "SRA", "BLI", "BPL", "LG1", "LGA", "MLS", "SRA",
"BLI", "BPL", "LG1", "LGA", "MLS", "SRA"), lwr = c(0.991908465191337,
1.024356375271, 0.991908465191337, 0.713669169484484, 1.12586982342001,
1.12084858138188, 2.06420487168374, 1.97777465268675, 2.06420487168374,
1.62334863906913, 2.23910774286228, 2.21022346166219, 2.97388434126839,
2.96968311787809, 3.11511279055919, 2.71272351934943, 3.36497756628229,
3.11990293124683, 3.96579280645972, 3.96159158306943, 3.9773593493607,
3.73707989462043, 4.47821548572456, 4.23314085068911, 4.95770127165106,
4.91500986048518, 5.066734229641, 4.76143626989143, 5.60408530914457,
5.18655912810486, 5.98205764692206, 5.7772564192867, 6.11764214851645,
5.67111573947608, 6.72995513256457, 6.09623859768951, 6.9739661121134,
6.49092558877118, 7.23849072989833, 6.4341005009485, 7.83280914918269,
7.08814706288085, 7.92738438952915, 7.48283405396252, 8.10073728869984,
7.38751877836426, 8.9356631658008, 8.08005552807218, 8.69036915100158,
8.196503223447, 9.15164520757529, 8.43842669723971, 10.0615329892208,
9.15235193456459, 9.68227761619292, 9.24741114232245, 10.0613246771599,
9.43033516243104, 11.1747709086631, 10.0145984933661, 10.4951374013193,
10.0103959037949, 11.0532331423513, 10.0959286392011, 12.2880088281053,
11.0655064122415, 11.448555678735, 11.0023043689862, 12.0451416075426,
10.8589134006735, 13.4163944903645, 12.0574148774329, 12.3582351483197,
11.9119838385709, 13.0960495264181, 11.4335539927294, 14.5296324098068,
13.1083227963083, 13.3825915235907, 12.8216633081555, 14.0057289960027,
12.3869722701452, 15.6504809911887, 13.9705693551098, 14.0481850003607,
13.4408352207955, 14.997637461194, 13.3788807353365, 16.7637189106309,
15.0214772739853, 15.0990929192361, 14.2038199822679, 16.0699338676864,
14.3707892005279, 17.8895887340509, 16.0937736804777, 16.0525111966519,
15.1572382596836, 17.1593087479667, 15.3626976657192, 19.0104373154328,
17.183148560758, 17.0059294740676, 16.1815946349546, 18.1127270253825,
16.3546061309105, 20.1236752348751, 18.2340564796334, 18.0568373929431,
17.0912741045393, 19.2259649448248, 17.1674659160369, 21.244523816257,
19.2259649448248, 19.0487458581344, 17.8542588660117, 20.339202864267,
17.9304506775093, 22.3729094785161, 20.1793832222405, 19.8616056432607,
18.5679280354962, 21.3901107831425, 18.9548070527803, 23.4861473979584,
21.230291141116, 20.8150239206765, 19.521346312912, 22.4410187020179,
19.8644865223649, 24.5993853174007, 22.2221996063073, 21.7247033902612,
20.5132547781033, 23.4919266208934, 20.9538614026453, 25.7252551408207,
23.2141080714986, 22.7166118554525, 21.2762395395757, 24.4453448983091,
21.9782177779162, 26.8461037222026, 24.0763546303002, 23.3822053322225,
22.2681480047671, 25.3550243678938, 22.9701262431076, 27.9489577388207,
24.9860340998848, 24.4065617074935, 23.2600564699584, 26.4059322867692,
23.9620347082989, 29.062195658263, 26.0369420187603, 25.3162411770782,
24.2844128452294, 27.3978407519606, 24.7748944934253, 30.1830442396449,
27.1263168990406, 26.0792259385506, 25.2378311226451, 28.5186893333425,
25.728312770841, 31.285898256263, 28.0359963686252, 27.0326442159663,
25.8570030352851, 29.380935892144, 26.7202212360324, 32.3991361757052,
28.8982429274267, 28.0245526811577, 26.5706722047696, 30.4532322986364,
27.629900705617, 33.5250059991252, 30.011480846869, 29.0489090564287,
27.4803516743542, 31.5426071789167, 28.295494182387, 34.6382439185675,
31.0033893120603, 30.1212054629211, 28.4722601395456, 32.534515644108,
29.3464021012625, 35.7514818380098, 31.9952977772517, 31.1131139281124,
29.523168058421, 33.6238905243883, 30.0600712707469, 36.8773516614298,
33.0462056961271, 32.1050223933037, 30.4328475280057, 34.6157989895797,
30.6347118628029, 37.9982002428117, 34.167054277509, NA, 31.3425269975903,
35.5254784591643, 31.5881301402187, 39.1240700662317, 35.2179621963844,
NA, 32.2959452750061, 36.3877250179658, 32.58003860541, 40.2499398896517,
36.2902586028768, NA, 33.1581918338076, 37.3796334831571, 33.3430233668824,
41.3758097130717, 37.3625550093693, NA, 34.1825482090786, 38.4519298896496,
34.3349318320738, 42.4890476325139, 38.4519298896496), pred = c(1.14244921317105,
1.18853138677409, 1.14244921317105, 0.901144403312629, 1.56756991682395,
1.50679152271014, 2.42879627669905, 2.28668514123042, 2.42879627669905,
1.95672013877945, 3.01593956754501, 2.84502506662769, 3.48437201216587,
3.42913435440147, 3.66526862143132, 3.294953682697, 4.58350948436895,
3.90060080209451, 4.62682122533692, 4.57158356757252, 4.67991718843272,
4.48348506947109, 6.03187913509002, 5.34897045281557, 5.76927043850797,
5.66973732202884, 6.01815073235027, 5.67201645624518, 7.59944905191396,
6.4471242072719, 6.95780182528206, 6.68438588903025, 7.25462307708254,
6.72759219171201, 9.16701896873791, 7.50269994273873, 8.10025103845311,
7.58553029234288, 8.76141459979268, 7.66508542555129, 10.559231901657,
8.64514915590978, 9.19840479290944, 8.72797950551393, 9.77606316679409,
8.76323918000761, 11.951444834576, 9.78759836908083, 10.1358980267487,
9.62912390882656, 11.0125355115264, 9.99971152473988, 13.5190147514,
11.0739454326088, 11.2783472399198, 10.8655962535588, 12.0681112469932,
11.1421607379109, 14.967384402121, 12.0885939996102, 12.2536554815996,
11.8030894873981, 13.2105604601642, 12.0083656408477, 16.4157540528421,
13.3250663443425, 13.3518092360559, 12.9455387005692, 14.3530096733353,
12.945858874687, 18.0465539392867, 14.4675155575135, 14.4073849715227,
14.001114436036, 15.5894820180675, 13.7461963137094, 19.4949235900078,
15.7039879022458, 15.5959163582968, 15.0566901715028, 16.6450577535344,
14.8443500681658, 21.0017151127179, 16.7186364692472, 16.4621212612336,
15.8893102611506, 17.7875069667054, 15.9867992813368, 22.450084763439,
17.9551088139795, 17.6985936059659, 16.8268034949899, 19.0738540302334,
17.1292484945079, 24.0176546802629, 19.2414558775075, 18.7967473604222,
17.9249572494462, 20.412087574151, 18.2716977076789, 25.5244462029731,
20.579689421425, 19.8949011148785, 19.1134886362203, 21.5102413286073,
19.41414692085, 26.9728158536941, 21.8161617661573, 21.1313734596108,
20.1690643716871, 22.9586109793284, 20.3894551625298, 28.4796073764043,
22.9586109793284, 22.2738226727819, 21.1065576055264, 24.4069806300494,
21.3269483963691, 30.1104072628489, 24.0567647337847, 23.2491309144617,
22.007702008839, 25.6434529747817, 22.5154797831431, 31.55877691357,
25.2932370785169, 24.347284668918, 23.1058557632954, 26.879925319514,
23.57105551861, 33.007146564291, 26.435686291688, 25.4028604043848,
24.2483049764664, 28.1163976642462, 24.9092890625275, 34.574716481115,
27.5781355048591, 26.5453096175559, 25.1857982103057, 29.2145514187025,
26.0978204493016, 36.0815080038251, 28.5927840718605, 27.4115145204927,
26.3282474234767, 30.2701271541694, 27.2402696624727, 37.4737209367442,
29.6483598073273, 28.6000459072668, 27.4706966366478, 31.5065994989016,
28.3827188756437, 38.9220905874652, 30.8848321520595, 29.6556216427336,
28.6592280234219, 32.6490487120727, 29.3580271173235, 40.4288821101754,
32.2230656959771, 30.5931148765729, 29.7573817778782, 34.1558402347828,
30.4561808717798, 41.8210950430944, 33.2786414314439, 31.6912686310292,
30.590001867526, 35.1704888017842, 31.5986300849509, 43.2694646938155,
34.2932899984453, 32.8337178442003, 31.4911462708386, 36.4568358653122,
32.6542058204177, 44.8370346106394, 35.7416596491664, 34.0222492309743,
32.5467220063055, 37.7950694092298, 33.5204107233545, 46.2854042613605,
36.8841088623374, 35.3085962945023, 33.6891712194765, 38.9375186224008,
34.7568830680868, 47.7337739120815, 38.0265580755085, 36.4510455076734,
34.9256435642088, 40.2757521663184, 35.6580274713994, 49.3013438289055,
39.2630304202408, 37.5934947208444, 35.9812192996756, 41.4182013794894,
36.4583649104218, 50.8081353516156, 40.7698219429509, NA, 37.0367950351424,
42.4737771149563, 37.5565186648782, 52.3757052684396, 42.0062942876832,
NA, 38.1349487895988, 43.4884256819577, 38.6989678780492, 53.9432751852635,
43.2926413512112, NA, 39.1495973566002, 44.6308748951287, 39.6364611118885,
55.5108451020875, 44.5789884147392, NA, 40.3381287433743, 45.9172219586567,
40.7789103250595, 56.9592147528085, 45.9172219586567), upr = c(1.29298996115076,
1.35270639827718, 1.29298996115076, 1.08861963714077, 2.00927001022789,
1.8927344640384, 2.79338768171436, 2.59559562977408, 2.79338768171436,
2.29009163848977, 3.79277139222773, 3.47982667159319, 3.99485968306336,
3.88858559092484, 4.21542445230345, 3.87718384604457, 5.80204140245562,
4.68129867294219, 5.28784964421412, 5.18157555207561, 5.38247502750475,
5.22989024432175, 7.58554278445547, 6.46480005494204, 6.58083960536488,
6.4244647835725, 6.96956723505955, 6.58259664259894, 9.59481279468335,
7.70768928643894, 7.93354600364207, 7.5915153587738, 8.39160400564863,
7.78406864394794, 11.6040828049112, 8.90916128778794, 9.22653596479283,
8.68013499591458, 10.284338469687, 8.89607035015407, 13.2856546541312,
10.2021512489387, 10.4694251962897, 9.97312495706534, 11.4513890448883,
10.138959581651, 14.9672265033512, 11.4951412100895, 11.5814269024959,
11.0617445942061, 12.8734258154774, 11.5609963522401, 16.9764965135791,
12.9955389306531, 12.8744168636466, 12.4837813647952, 14.0748978168264,
12.8539863133908, 18.759997895579, 14.1625895058544, 14.0121735618799,
13.5957830710013, 15.3678877779772, 13.9208026424944, 20.5434992775788,
15.5846262764435, 15.2550627933768, 14.8887730321521, 16.6608777391279,
15.0328043487006, 22.6767133882089, 16.8776162375942, 16.4565347947258,
16.0902450335011, 18.082914509717, 16.0588386346895, 24.4602147702088,
18.2996530081833, 17.809241193003, 17.2917170348501, 19.284386511066,
17.3017278661863, 26.3529492342472, 19.4667035833846, 18.8760575221066,
18.3377853015058, 20.5773764722168, 18.5947178273371, 28.136450616247,
20.8887403539737, 20.2980942926957, 19.4497870077119, 22.0777741927804,
19.8877077884879, 30.1457206264749, 22.3891380745373, 21.5409835241926,
20.6926762392088, 23.6648664003352, 21.1806977496386, 32.0384550905133,
23.9762302820921, 22.7838727556895, 22.045382637486, 24.9077556318321,
22.4736877107894, 33.8219564725131, 25.3982670526812, 24.2059095262785,
23.246854638835, 26.6912570138319, 23.6114444090227, 35.7146909365515,
26.6912570138319, 25.4988994874293, 24.3588563450411, 28.4747583958318,
24.7234461152288, 37.8479050471816, 27.9341462453288, 26.6366561856626,
25.4474759821819, 29.8967951664209, 26.076152513506, 39.6314064291815,
29.3561830159179, 27.8795454171595, 26.6903652136788, 31.31883193701,
27.277624514855, 41.4149078111813, 30.6491729770687, 29.0810174185085,
27.9833551748295, 32.740868707599, 28.8647167224098, 43.4241778214092,
31.9421629382194, 30.3740073796592, 29.0953568810357, 33.9837579390959,
30.217423120687, 45.3169122854476, 33.1092135134207, 31.4408237087628,
30.3883468421864, 35.1852299404449, 31.5104130818377, 46.9984841346676,
34.3106855147697, 32.79353010704, 31.6813368033372, 36.607266711034,
32.8034030429885, 48.7819855166675, 35.7327222853588, 33.995002108389,
33.0340432016144, 37.9002566721848, 33.9411597412217, 50.6747199807059,
37.3198144929136, 35.1070038145952, 34.2769324331113, 39.7929911362232,
35.1840489727186, 52.3562918299259, 38.5212864942626, 36.349893046092,
35.3230006997669, 40.9600417114245, 36.4770389338694, 54.1397932119257,
39.6883370694639, 37.6428830072428, 36.4116203369077, 42.4604394319881,
37.6785109352184, 56.1490632221536, 41.4718384514638, 38.99558940552,
37.6130923382567, 44.0475316395429, 38.745327264322, 57.9325646041534,
42.7648284126145, 40.4959871260836, 38.9060822994075, 45.3405216006936,
40.1673640349111, 59.7160659861533, 44.0578183737653, 41.7889770872344,
40.3281190699966, 46.9276138082484, 41.2559836720519, 61.7253359963812,
45.4798551443544, 43.0819670483851, 41.5295910713456, 48.2206037693992,
42.2820179580408, 63.6180704604196, 47.3725896083928, NA, 42.7310630726946,
49.4220757707482, 43.5249071895377, 65.6273404706475, 48.7946263789819,
NA, 43.9739523041915, 50.5891263459495, 44.8178971506884, 67.6366104808753,
50.2950240995455, NA, 45.1410028793928, 51.8821163071003, 45.9298988568945,
69.6458804911032, 51.7954218201091, NA, 46.4937092776699, 53.3825140276639,
47.2228888180453, 71.4293818731031, 53.3825140276639)), .Names = c("x",
"model", "lwr", "pred", "upr"), class = "data.frame", row.names = c(NA,
228L))
我发布了关于here的帖子,但我仍然无法弄明白。有没有办法让我修改我的命令,以便只显示某些被激活的项目。