如何在ggplot 2中平滑geom_ribbon / geom_area图形?

sg24os4d  于 2023-03-10  发布在  其他
关注(0)|答案(1)|浏览(162)

我在geom_ribbon图中平滑线时遇到困难。目前它看起来如下所示:

geom_ribbon(aes(ymin=0, ymax=normalized_gfp_mean),fill = "#90d850", color = "#266825", alpha = 0.4, size = 0.5)

有没有可能用同样的填充在下面的图上做一个轻微的平滑?
(This是我需要在一个巨大的数据集中对大量的图进行处理的事情,所以一个容易应用的方法将会很感激)
先谢谢你了。
示例数据如下所示:

structure(list(time = c(0.24, 0.573203883495146, 1.23961165048544, 
1.57281553398058, 2.23922330097087, 2.57242718446602, 3.23883495145631, 
3.57203883495146, 4.23844660194175, 4.57165048543689, 5.23805825242718, 
5.57126213592233, 6.23766990291262, 6.57087378640777, 7.23728155339806, 
7.5704854368932, 8.2368932038835, 8.57009708737864, 9.23650485436893, 
9.56970873786408, 10.2361165048544, 10.5693203883495, 11.2357281553398, 
11.568932038835, 12.2353398058252, 12.5685436893204, 13.2349514563107, 
13.5681553398058, 14.2345631067961, 14.5677669902913, 15.2341747572816, 
15.5673786407767, 16.233786407767, 16.5669902912621, 17.2333980582524, 
17.5666019417476, 18.2330097087379, 18.566213592233, 19.2326213592233, 
19.5658252427184, 20.2322330097087, 20.5654368932039, 21.2318446601942, 
21.5650485436893, 22.2314563106796, 22.5646601941748, 23.231067961165, 
23.5642718446602, 24.2306796116505, 24.5638834951456, 25.2302912621359, 
25.5634951456311, 26.2299029126214, 26.5631067961165, 27.2295145631068, 
27.5627184466019, 28.2291262135922, 28.5623300970874, 29.2287378640777, 
29.5619417475728, 30.2283495145631, 30.5615533980583, 31.2279611650485, 
31.5611650485437, 32.227572815534, 32.5607766990291, 33.2271844660194, 
33.5603883495146, 34.2267961165049, 34.56, 35.2264077669903, 
35.5596116504854, 36.2260194174757, 36.5592233009709, 37.2256310679612, 
37.5588349514563, 38.2252427184466, 38.5584466019417, 39.224854368932, 
39.5580582524272, 40.2244660194175, 40.5576699029126, 41.2240776699029, 
41.5572815533981, 42.2236893203884, 42.5568932038835, 43.2233009708738, 
43.5565048543689, 44.2229126213592, 44.5561165048544, 45.2225242718447, 
45.5557281553398, 46.2221359223301, 46.5553398058252, 47.2217475728155, 
47.5549514563107, 48.221359223301, 48.5545631067961, 49.2209708737864, 
49.5541747572816, 50.2205825242718, 50.553786407767, 51.2201941747573, 
51.5533980582524, 52.2198058252427, 52.5530097087379, 53.2194174757282, 
53.5526213592233, 54.2190291262136, 54.5522330097087, 55.218640776699, 
55.5518446601942, 56.2182524271845, 56.5514563106796, 57.2178640776699, 
57.551067961165, 58.2174757281553, 58.5506796116505, 59.2170873786408, 
59.5502912621359, 60.2166990291262, 60.5499029126214, 61.2163106796117, 
61.5495145631068, 62.2159223300971, 62.5491262135922, 63.2155339805825, 
63.5487378640777, 64.215145631068, 64.5483495145631, 65.2147572815534, 
65.5479611650485, 66.2143689320388, 66.547572815534, 67.2139805825243, 
67.5471844660194, 68.2135922330097, 68.5467961165049), media = c("IO+CasA_gfp", 
"IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
"IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
"IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
"IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
"IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
"IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
"IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
"IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
"IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
"IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
"IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
"IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
"IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
"IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
"IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
"IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
"IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
"IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
"IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
"IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
"IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
"IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
"IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
"IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
"IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
"IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
"IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
"IO+CasA_gfp", "IO+CasA_gfp"), normalized_gfp_mean = c(0.01, 
3.34, 15.6733333333333, 7.34, 4.67333333333333, 11.6733333333333, 
2.34, 2.67, 11.6733333333333, 21.6733333333333, 0.01, 0.01, 0.01, 
1.00666666666667, 0.34, 13.34, 0.01, 5.67333333333333, 7.00666666666667, 
2.00666666666667, 3.67333333333333, 0.01, 8.34, 17.0066666666667, 
4.95634920634921, 417.571428571429, 1895.9, 2943.01851851852, 
6063.85714285714, 6513.67803030303, 8173.11396011396, 9653.1746031746, 
12560, 12808.630952381, 15653.2642602496, 16654.5584045584, 21034.9927849928, 
23528.8269636096, 27264.2424242424, 29032.1118991332, 31983.9065255732, 
32258.6287557975, 34054.5821948998, 34156.2796489564, 35913.4142545907, 
35433.0431848853, 36809.6685727623, 37888.7567656224, 39448.3815921047, 
40682.937658155, 44082.8089375285, 45490.0974444378, 47397.7816588534, 
47858.6657209403, 49342.2057787174, 50080.5019184089, 51467.8505990134, 
52058.0852050619, 51856.3506261181, 51847.9508505599, 52104.601521164, 
51921.4285714286, 51838.5304659498, 53033.189033189, 52503.1676641513, 
53081.4808891258, 53543.3707998282, 53579.1846224473, 54759.1960252936, 
54839.1237579042, 55064.7515808491, 56604.8148148148, 58071.0841170324, 
59219.1379310345, 60460.8256291731, 60794.0631872835, 62072.5866087935, 
63787.9954626145, 65563.4920634921, 65414.6062831497, 66029.7478861548, 
66949.9256863088, 68580.6657306657, 70035.9234234234, 70968.0263319798, 
72474.0404040404, 72290.3367003367, 72955.467372134, 74873.2575757576, 
74219.8951781971, 74353.3003893381, 75652.2898239971, 74656.7445342917, 
76759.4516793584, 76437.7217553688, 75893.5322847088, 77219.089749721, 
77551.6227824463, 79290.2352941177, 78527.3524629364, 79712.4582560297, 
79484.3015521064, 80950.0886415172, 80822.4873737374, 82151.4665889666, 
81321.0858585859, 83283.7932516656, 83364.4117112202, 86108.1396976484, 
86087.8382792087, 83562.2340425532, 83659.3132635686, 84602.7293096873, 
83974.4493707094, 85312.7986682334, 84300.7895123384, 85057.4476650564, 
86167.4404761905, 85112.3644179894, 84155.625, 82211.1086086086, 
84469.0079365079, 84529.8311546841, 85429.3513247593, 84075.1664106503, 
85069.5621617823, 81865.358422939, 84023.2117187051, 81369.9685022266, 
85665.2126099707, 81839.8345203184, 82705.3239770982, 86429.9413489736, 
81816.8736702892, 86021.8295861844, 83260.0119726901, 82876.7744966545, 
81110.6991033473)), class = c("grouped_df", "tbl_df", "tbl", 
"data.frame"), row.names = c(NA, -138L), groups = structure(list(
    time = c(0.24, 0.573203883495146, 1.23961165048544, 1.57281553398058, 
    2.23922330097087, 2.57242718446602, 3.23883495145631, 3.57203883495146, 
    4.23844660194175, 4.57165048543689, 5.23805825242718, 5.57126213592233, 
    6.23766990291262, 6.57087378640777, 7.23728155339806, 7.5704854368932, 
    8.2368932038835, 8.57009708737864, 9.23650485436893, 9.56970873786408, 
    10.2361165048544, 10.5693203883495, 11.2357281553398, 11.568932038835, 
    12.2353398058252, 12.5685436893204, 13.2349514563107, 13.5681553398058, 
    14.2345631067961, 14.5677669902913, 15.2341747572816, 15.5673786407767, 
    16.233786407767, 16.5669902912621, 17.2333980582524, 17.5666019417476, 
    18.2330097087379, 18.566213592233, 19.2326213592233, 19.5658252427184, 
    20.2322330097087, 20.5654368932039, 21.2318446601942, 21.5650485436893, 
    22.2314563106796, 22.5646601941748, 23.231067961165, 23.5642718446602, 
    24.2306796116505, 24.5638834951456, 25.2302912621359, 25.5634951456311, 
    26.2299029126214, 26.5631067961165, 27.2295145631068, 27.5627184466019, 
    28.2291262135922, 28.5623300970874, 29.2287378640777, 29.5619417475728, 
    30.2283495145631, 30.5615533980583, 31.2279611650485, 31.5611650485437, 
    32.227572815534, 32.5607766990291, 33.2271844660194, 33.5603883495146, 
    34.2267961165049, 34.56, 35.2264077669903, 35.5596116504854, 
    36.2260194174757, 36.5592233009709, 37.2256310679612, 37.5588349514563, 
    38.2252427184466, 38.5584466019417, 39.224854368932, 39.5580582524272, 
    40.2244660194175, 40.5576699029126, 41.2240776699029, 41.5572815533981, 
    42.2236893203884, 42.5568932038835, 43.2233009708738, 43.5565048543689, 
    44.2229126213592, 44.5561165048544, 45.2225242718447, 45.5557281553398, 
    46.2221359223301, 46.5553398058252, 47.2217475728155, 47.5549514563107, 
    48.221359223301, 48.5545631067961, 49.2209708737864, 49.5541747572816, 
    50.2205825242718, 50.553786407767, 51.2201941747573, 51.5533980582524, 
    52.2198058252427, 52.5530097087379, 53.2194174757282, 53.5526213592233, 
    54.2190291262136, 54.5522330097087, 55.218640776699, 55.5518446601942, 
    56.2182524271845, 56.5514563106796, 57.2178640776699, 57.551067961165, 
    58.2174757281553, 58.5506796116505, 59.2170873786408, 59.5502912621359, 
    60.2166990291262, 60.5499029126214, 61.2163106796117, 61.5495145631068, 
    62.2159223300971, 62.5491262135922, 63.2155339805825, 63.5487378640777, 
    64.215145631068, 64.5483495145631, 65.2147572815534, 65.5479611650485, 
    66.2143689320388, 66.547572815534, 67.2139805825243, 67.5471844660194, 
    68.2135922330097, 68.5467961165049), media = c("IO+CasA_gfp", 
    "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
    "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
    "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
    "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
    "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
    "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
    "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
    "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
    "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
    "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
    "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
    "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
    "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
    "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
    "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
    "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
    "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
    "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
    "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
    "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
    "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
    "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
    "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
    "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
    "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
    "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
    "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
    "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
    "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
    "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
    "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
    "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
    "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
    "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", "IO+CasA_gfp", 
    "IO+CasA_gfp"), .rows = structure(list(1L, 2L, 3L, 4L, 5L, 
        6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 
        18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 
        29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 
        40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 
        51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L, 60L, 61L, 
        62L, 63L, 64L, 65L, 66L, 67L, 68L, 69L, 70L, 71L, 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, 
        105L, 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, 135L, 136L, 137L, 138L), ptype = integer(0), class = c("vctrs_list_of", 
    "vctrs_vctr", "list"))), class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -138L), .drop = TRUE))
0sgqnhkj

0sgqnhkj1#

用途:geom_area(stat = "smooth", method = "loess")

相关问题