gpt4 book ai didi

r - 如何设置 ggplot2 stat_smooth() 取值的范围以适合线条?

转载 作者:行者123 更新时间:2023-12-04 19:14:23 25 4
gpt4 key购买 nike

我想让 stat_smooth 只使用指定范围内的数据来拟合一条线,换句话说,我想让 stat_smooth 拟合 x(0,99)、x(100,199) 和 x(199,299) 之间的一条线。

我设法使用 facet_grid 获得了相当接近的结果,如下所示:

ggplot(avtimes3, aes(x=trial, y=ttime, colour=factor(id))) +
facet_grid(. ~ brk, scales = "free") +
geom_vline(xintercept = short_bks, colour="red") +
geom_vline(xintercept = long_bks, colour="green") +
geom_point() +
geom_point(shape=21, fill="white")+
opts(title=titl) +
ylab("Time taken (ms)") +
xlab("Trial No.")+
stat_smooth(method="loess")

但它在每个网格上绘制了大量空白区域。我一直无法找到删除它的方法。

我从另一篇文章中获取的另一个部分解决方案包括为范围创建一个组,但这似乎不尊重传递给 qqplot 的因素。
ggplot(avtimes3, aes(x=trial, y=ttime, colour=factor(id))) +
geom_vline(xintercept = short_bks, colour="red") +
geom_vline(xintercept = long_bks, colour="green") +
geom_point() +
geom_point(shape=21, fill="white")+
opts(title=titl) +
ylab("Time taken (ms)") +
xlab("Trial No.")+
stat_smooth(method="loess", aes(group=brk))

有关如何使其工作的任何帮助?
谢谢!

数据:
> dput(avtimes3)
structure(list(trial = c(0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5,
6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14,
15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30,
31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38,
39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46,
47, 47, 48, 48, 49, 49, 50, 50, 51, 51, 52, 52, 53, 53, 54, 54,
55, 55, 56, 56, 57, 57, 58, 58, 59, 59, 60, 60, 61, 61, 62, 62,
63, 63, 64, 64, 65, 65, 66, 66, 67, 67, 68, 68, 69, 69, 70, 70,
71, 71, 72, 72, 73, 73, 74, 74, 75, 75, 76, 76, 77, 77, 78, 78,
79, 79, 80, 80, 81, 81, 82, 82, 83, 83, 84, 84, 85, 85, 86, 86,
87, 87, 88, 88, 89, 89, 90, 90, 91, 91, 92, 92, 93, 93, 94, 94,
95, 95, 96, 96, 97, 97, 98, 98, 99, 99, 100, 100, 101, 101, 102,
102, 103, 103, 104, 104, 105, 105, 106, 106, 107, 107, 108, 108,
109, 109, 110, 110, 111, 111, 112, 112, 113, 113, 114, 114, 115,
115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121,
122, 122, 123, 123, 124, 124, 125, 125, 126, 126, 127, 127, 128,
128, 129, 129, 130, 130, 131, 131, 132, 132, 133, 133, 134, 134,
135, 135, 136, 136, 137, 137, 138, 138, 139, 139, 140, 140, 141,
141, 142, 142, 143, 143, 144, 144, 145, 145, 146, 146, 147, 147,
148, 148, 149, 149, 150, 150, 151, 151, 152, 152, 153, 153, 154,
154, 155, 155, 156, 156, 157, 157, 158, 158, 159, 159, 160, 160,
161, 161, 162, 162, 163, 163, 164, 164, 165, 165, 166, 166, 167,
167, 168, 168, 169, 169, 170, 170, 171, 171, 172, 172, 173, 173,
174, 174, 175, 175, 176, 176, 177, 177, 178, 178, 179, 179, 180,
180, 181, 181, 182, 182, 183, 183, 184, 184, 185, 185, 186, 186,
187, 187, 188, 188, 189, 189, 190, 190, 191, 191, 192, 192, 193,
193, 194, 194, 195, 195, 196, 196, 197, 197, 198, 198, 199, 199,
200, 200, 201, 201, 202, 202, 203, 203, 204, 204, 205, 205, 206,
206, 207, 207, 208, 208, 209, 209, 210, 210, 211, 211, 212, 212,
213, 213, 214, 214, 215, 215, 216, 216, 217, 217, 218, 218, 219,
219, 220, 220, 221, 221, 222, 222, 223, 223, 224, 224, 225, 225,
226, 226, 227, 227, 228, 228, 229, 229, 230, 230, 231, 231, 232,
232, 233, 233, 234, 234, 235, 235, 236, 236, 237, 237, 238, 238,
239, 239, 240, 240, 241, 241, 242, 242, 243, 243, 244, 244, 245,
245, 246, 246, 247, 247, 248, 248, 249, 249, 250, 250, 251, 251,
252, 252, 253, 253, 254, 254, 255, 255, 256, 256, 257, 257, 258,
258, 259, 259, 260, 260, 261, 261, 262, 262, 263, 263, 264, 264,
265, 265, 266, 266, 267, 267, 268, 268, 269, 269, 270, 270, 271,
271, 272, 272, 273, 273, 274, 274, 275, 275, 276, 276, 277, 277,
278, 278, 279, 279, 280, 280, 281, 281, 282, 282, 283, 283, 284,
284, 285, 285, 286, 286, 287, 287, 288, 288, 289, 289, 290, 290,
291, 291, 292, 292, 293, 293, 294, 294, 295, 295, 296, 296, 297,
297, 298, 298, 299, 299), id = c(1.5, 2, 1.5, 2, 1.5, 2, 1.5,
2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5,
2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5,
2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5,
2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5,
2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5,
2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5,
2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5,
2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5,
2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1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.5, 2, 1.5,
2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5,
2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5,
2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5,
2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5,
2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5,
2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5,
2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5,
2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5,
2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5,
2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5,
2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5,
2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5, 2, 1.5,
2), ttime = c(2564, 2050.5, 2204.75, 2060.625, 2266.125, 1880.125,
2224.25, 2067, 2215.375, 2199.25, 2333.375, 2434.625, 2278.875,
2102, 2104.5, 2049, 2336.125, 2159.5, 2110.625, 2082.875, 2197.5,
2136.5, 2107.375, 2025, 2342, 2289.875, 2106.25, 2146.75, 2187.25,
2104.875, 2151.375, 2246.375, 2143.75, 2091.625, 2129.625, 2163.875,
2132.5, 2265.25, 1959, 2054.25, 2205.5, 2033, 1992.875, 1965.625,
1983.875, 1973.75, 1953.625, 1936.375, 2012.25, 2106.75, 2115,
2195.375, 2210.875, 2097.625, 2016.25, 2084.375, 2005.25, 2250.875,
2352.875, 2217.625, 2141.75, 2154.375, 2181.625, 2083.5, 2103.5,
1959.5, 2020.75, 2255.25, 2039.125, 2144.125, 2216.125, 2216.125,
2014.125, 2234.625, 1975.625, 2289, 2035.5, 2058.25, 2039.5,
2222.5, 2013.125, 2156.375, 1896.375, 1990.875, 2014.125, 2030.625,
1928.875, 2021, 2013, 2001.5, 1940.625, 2029.375, 2075.5, 2179.375,
1991, 2292.25, 2020.375, 2065.375, 2007.375, 2192.5, 1954.25,
2128.5, 1949.875, 2240.25, 2119.375, 2011.625, 1984.875, 2182,
1955.375, 2010.5, 1924.5, 2043.25, 2033, 2183.375, 2075.75, 2011.375,
1969.625, 2002.375, 1921.5, 2111.875, 1951, 2103, 1780.375, 1935.75,
1930.75, 2044.375, 1892.25, 2128.75, 1973.875, 1992.625, 1920.625,
2093, 2047.875, 2285.625, 1968, 2208.375, 2021.25, 2079.375,
1988.75, 2147.875, 1989, 2026.25, 1873.25, 2084.75, 2010.25,
2163.25, 1960.125, 1987.125, 2043.75, 2154.875, 2188.25, 2402.625,
2101.625, 2019.625, 2447.5, 1996.125, 2009.875, 2037.625, 2195.5,
2123.875, 1986.625, 2093, 1793.125, 1858.125, 1862.625, 1895.5,
1806, 1951.5, 1784.625, 2041.625, 1868.625, 2095.25, 1946.125,
1930.75, 2010.5, 2179.375, 1903.875, 2049.25, 1958.125, 2053.75,
2016.75, 2057.875, 1898.875, 2196.875, 1939.75, 2265.875, 2090.875,
2187.875, 2082.75, 2089.125, 1904, 2303.25, 1982.125, 2094.375,
2205.625, 2259.25, 2018.5, 1882.25, 1978.125, 1901.625, 1834.5,
2019.375, 1802.125, 1929.875, 1700.75, 2019, 1691.125, 1959.375,
1774.375, 2138.375, 1751.25, 2036.125, 1808.5, 2138, 1848, 2109.75,
1823.125, 2001, 1923, 2057.125, 1827.5, 1877.375, 1823.125, 1860.25,
1742.875, 2047.625, 2018.125, 2016.125, 1799, 2095.25, 1735.25,
1951, 1776.625, 2057.125, 1726.125, 2068.5, 1806, 2107.875, 1774.375,
1956, 1920.75, 1943.25, 1714.125, 1756.125, 1789.25, 1941.125,
1734.125, 2195.375, 1788.375, 2005.375, 1832.5, 1861, 1830.25,
2263.625, 1903.75, 2090.375, 2015.875, 2019.25, 1807.375, 2143.375,
1882.5, 1901.75, 1897.125, 1866.75, 1943.125, 1943.875, 1818.75,
2089.5, 1818, 1992.875, 1910.25, 1855.125, 1825.5, 1850.25, 1881.125,
1953.625, 1840.25, 2119.25, 1745.25, 2045.5, 1767.625, 2019.875,
1759.5, 1876.125, 1667.875, 1948, 1767.125, 2046.25, 1721, 1984.5,
1842.875, 2300.125, 1726.625, 2252.875, 1718.75, 1983.625, 1842.375,
2165.125, 1932, 2154.375, 1746.125, 1936.75, 1920.625, 2056.25,
1854.375, 2022.125, 1973.625, 2064.25, 1883.5, 2077.375, 2117.25,
2089, 1759, 2082.875, 1910.75, 1955.75, 1847.375, 1998.25, 1796.375,
2028.5, 1804.5, 1920.625, 1793.25, 1841.125, 1778.625, 1929.25,
1742.25, 1988.875, 1805.375, 1982.75, 1797.125, 1963.75, 1682.875,
2028.25, 1664.375, 2109.5, 1747.625, 1992, 1767.125, 2064.125,
1740.125, 2083.875, 1952.375, 2007.125, 1763.125, 2050, 1780.25,
2181.25, 1810.5, 1990.25, 1706.875, 2029, 1715.125, 2211.375,
1876.375, 2003.625, 1773.5, 1986.75, 1824, 2198.375, 1777.375,
2075, 1761.25, 1873, 1725.125, 1917.75, 1773.875, 1860.25, 1788,
1908.625, 1955.375, 1943.875, 1828.5, 1860.5, 1836.25, 2134.5,
1829.75, 1949.375, 1762, 2058.75, 1736.75, 1908.625, 1816.375,
2113.625, 1868.125, 2042.625, 1796.375, 2280.5, 1773, 1968.125,
1885.75, 2136.375, 1784.5, 2103.875, 1785.875, 2296.875, 1782.625,
1969.125, 1864.75, 2062.5, 1800.75, 2289.75, 1639.5, 2081.75,
1735.125, 1947.375, 1617.875, 1871.125, 1676.375, 1998, 1685,
1929.625, 1762.625, 2073.625, 1698.75, 1834.5, 1669, 1858.875,
1705.625, 2164.625, 1750.125, 1835.875, 1836.25, 1992, 1741.625,
1874.375, 1810.375, 2140.875, 1819.5, 2277.625, 1779.5, 2054.875,
1703.375, 1978.125, 1754.625, 1964.875, 1749.875, 1959.625, 1932.875,
1952.125, 1709.625, 2038.125, 1680.5, 1893, 1664.5, 1961.125,
1700.25, 1871, 1753, 1889.75, 1724, 1878.875, 1827.375, 1849.25,
1850.75, 1977.125, 1783.625, 1977.25, 1895.125, 2097.5, 1716.375,
1985.5, 1675.375, 1845.25, 1764.5, 2089.375, 1766.75, 1848.125,
1730.125, 1991.5, 1865.375, 2030.875, 1864.625, 1960.875, 1739.25,
2204.375, 1758.125, 2175.375, 1871.5, 1994.25, 1739.25, 2028.875,
1646.125, 1958.375, 1709.25, 1914.5, 1638.375, 1965.375, 1691.5,
2154.375, 1833.75, 1892.375, 1891.625, 1999.25, 1752.75, 1952.5,
1702.625, 1907.75, 1671.25, 1947.375, 1734.875, 2125.375, 1745.25,
2145.25, 1756.125, 2095.25, 1707.5, 1939.375, 1738.25, 2102.875,
1862.375, 2152.875, 1719, 2091.25, 1969.25, 2088.125, 1702.875,
2231.625, 2007.5, 2087, 1732.625, 1866.625, 1675.875, 1971.625,
1663.875, 2016.5, 1834, 1927.75, 1777.25, 1995, 2029.125, 2009.5,
1778.5, 1868, 1711.5, 1820.375, 1706.625, 1911.375, 1850, 2001.625,
1753.375, 2105.625, 1812.125, 2028.125, 1820.5, 2205.75, 1812.625,
2238, 1812.125, 2236.25, 1713.375, 2482, 1844.25, 1951.25, 1995.125,
2108.5, 1873.125, 1977, 1849, 2064.25, 1709.75, 1962, 1844, 1828.5,
1735.75, 1974.125, 1675, 2147, 1789.75, 2099.875, 1790.5, 2083,
1713.5, 2250.125, 1930.25, 2321.75, 1742.5, 2189.875, 1840, 2070,
1823.125, 2027.25, 1782.875, 2344, 1788.875, 2106.25, 1824.75,
2251.625, 1902.5, 1961.375, 1873.5, 2158.75, 1855.125, 1933.75,
1825.75, 2001.875, 1887.75, 2002.75, 1945.375, 2230.875), se = c(259.899705930686,
137.567905310172, 228.087917729734, 172.114158284968, 234.074502600897,
109.939827292024, 271.704918063696, 195.301781134443, 227.085803284951,
169.989784356926, 257.363066052332, 353.735067201228, 231.204411529526,
151.548082893092, 230.22527787241, 188.563933833745, 289.179037319443,
130.584537478874, 250.616449800715, 90.5208021672367, 192.562883977454,
178.968373103821, 225.736567192507, 157.087555204096, 222.259179466547,
189.375330032716, 195.44269803266, 156.734278090568, 222.104443738912,
155.254449844211, 229.124571350234, 234.785535687055, 214.213407443538,
136.267454648675, 218.906693878922, 219.006069509826, 181.324098154185,
198.187568984535, 160.006249877934, 152.706271505603, 280.670689090054,
147.26276321111, 197.418648480474, 131.188242273133, 184.134989060821,
117.833531184585, 177.697770857873, 95.0770246957697, 179.782482660098,
149.204886697071, 143.619164061466, 171.956798717003, 225.56939362264,
150.268680500248, 233.734415064864, 134.100833264163, 177.509833731623,
179.588959004802, 302.633231433458, 256.399655776179, 261.114900132927,
194.266379848099, 233.925960318034, 180.624314136117, 204.312523215923,
147.377552080169, 190.48347791119, 143.664757334567, 184.82012853235,
203.166050796949, 199.973965939498, 181.057847652148, 226.143478278409,
219.701090567226, 192.715458040753, 161.770339856053, 161.292214850651,
121.259130731316, 209.589053694537, 141.678080772675, 203.257616049542,
158.180608516702, 146.132393189483, 151.949173539331, 171.350459324492,
194.983967976491, 127.888265615509, 167.346091336829, 133.506152881217,
141.716391833428, 110.950912167112, 128.343141825231, 135.5180536207,
175.427125437561, 133.723194910767, 194.496120967562, 173.14114158892,
142.659927487414, 199.71273454461, 219.278280469622, 135.405970273523,
223.876480612477, 155.919786783828, 219.316531687487, 142.123178151409,
132.259071725048, 131.867823095163, 192.080526268096, 97.3238220544472,
154.800909004345, 143.230957348114, 172.257049409969, 113.881987789365,
301.963629402852, 147.572228078321, 145.94690050788, 116.268306930258,
103.901556687775, 123.388903182464, 217.304134920557, 106.773123959169,
137.984730004032, 172.231876249516, 166.958479654588, 130.019607037884,
182.871142914114, 142.971994010815, 203.262387603525, 68.1171358501557,
215.99462108878, 142.521168540476, 236.726032125143, 124.067728839073,
132.166282913933, 131.916369611313, 236.530271205249, 124.9966785273,
159.275585240084, 89.4242995898925, 208.220816639794, 86.0348766489497,
106.74431232757, 117.217708011326, 186.83259791283, 92.4279159283446,
153.374745313562, 121.694646774505, 171.894115820093, 107.795731097559,
127.720179284358, 272.201064734981, 364.814039590231, 155.784528103495,
143.156624703255, 489.334059134015, 173.340544006382, 83.3367603462002,
166.637431215627, 219.917679403648, 209.582530411224, 228.411747375843,
189.848059548381, 139.321242034884, 107.117331780889, 112.04876768303,
153.452994198782, 110.70181957467, 212.323287868826, 88.1538706507791,
223.663885064493, 109.954525908928, 174.492810944831, 91.7725132947146,
157.710715054042, 91.0863013065866, 274.394589277923, 98.7716409379303,
171.341946119448, 134.708208136274, 186.973140737227, 120.51344767879,
161.766303826141, 86.3732426945488, 199.796095834514, 104.603801829297,
242.194169263011, 161.9110687891, 212.630332930518, 146.398032529715,
205.110722494322, 115.358911972281, 240.223909687846, 120.004380500404,
183.283731791138, 236.191503528992, 204.437359424767, 129.357340064534,
146.524589598957, 121.586893898385, 142.473924619309, 127.924224222221,
188.175823699539, 152.876518506651, 145.462002586341, 87.0048746581806,
133.546273414338, 98.8791537866877, 174.15909572859, 106.353174695714,
186.087147163058, 126.108053158506, 209.25995773371, 98.74281167327,
160.608886073325, 96.4942633379977, 180.464554295692, 109.188473603477,
150.810548134311, 167.763332448678, 179.1967631145, 107.239551605606,
88.4372128970605, 102.662838856827, 97.9408987239608, 106.765670897264,
250.209122357108, 133.851255063757, 171.96443127868, 79.5145988392787,
134.235367651642, 91.3258979854956, 180.483774498271, 100.323216494773,
155.563886451378, 109.931543227722, 157.58716408932, 101.749692874229,
194.113501177238, 76.3331367615477, 161.404881321123, 150.197697100474,
146.905551533727, 100.562780231342, 141.682925362535, 145.424839448326,
138.486517845601, 108.039251713043, 131.377990315295, 112.028525943172,
96.5617747314418, 125.319448952325, 154.683432486205, 95.5564063038909,
200.194721057489, 93.4435945217373, 122.469812242504, 203.591190300212,
211.888510947216, 101.610414521769, 196.474547379189, 103.015775490941,
119.9206210672, 145.295442547246, 128.463967988804, 150.725085301969,
165.399455593766, 104.018499384896, 215.797110400355, 121.178587217379,
119.188841385065, 143.195265035445, 174.310318264787, 134.187901306872,
127.609721696384, 138.859697626777, 122.751482024804, 115.77236747786,
181.758252907537, 103.840494096887, 162.714583594359, 124.458819566382,
205.661861654721, 129.944493644677, 188.241243156222, 100.24442227091,
158.948217084325, 111.493984062562, 148.115875246376, 115.076216979382,
139.682931772538, 136.821630169147, 191.964509136083, 79.2329155762571,
165.804471495365, 81.7984784175633, 230.305537547407, 124.336946798953,
170.654667750402, 154.3081332918, 162.600182030736, 81.7580134779285,
245.344491771992, 129.797636108235, 219.264496995882, 75.4214202000996,
235.570692870072, 162.076253823845, 207.486811112693, 67.3856173717465,
167.51779622945, 132.19219638736, 189.748047232564, 104.87049837095,
158.695737351611, 122.825187912391, 148.869519810374, 78.1129990782584,
197.096672255738, 78.5845626197847, 133.345550035559, 103.367582649771,
175.46753235489, 104.227215735623, 124.734781135816, 156.960975302325,
160.870483619588, 113.155984312427, 166.304737229581, 79.420431317856,
206.602599036342, 114.308392002262, 208.96263763786, 94.5465564644515,
168.996380984074, 108.669048277656, 137.826236357855, 109.913104882903,
151.036892371178, 120.993718476268, 173.60406898416, 89.1802823939078,
119.126199214471, 112.281523969886, 173.941845526026, 109.368550830274,
183.11822878754, 122.79741592209, 194.953634597709, 113.22401941032,
205.555584244957, 113.743200346218, 159.083199256597, 92.3830220757967,
192.970014093604, 106.811405473787, 128.241393125287, 95.926683312979,
236.008152855544, 137.267595801569, 215.379145553337, 126.974538716007,
158.024523413298, 116.186080737509, 152.477633020153, 99.9564972339753,
192.186456152798, 119.916702860777, 201.098123703686, 97.9207040707648,
159.467074243736, 175.587985423263, 175.71460601742, 74.9249624624531,
183.511385400003, 104.460476121012, 195.090363677963, 99.0178104469811,
190.719121962489, 105.451241271567, 249.549934167207, 101.510511419121,
163.787529777802, 122.226799945838, 260.121464587769, 81.4819080488774,
207.000080874725, 100.300074330552, 318.607292984415, 92.1772361114329,
164.345502513542, 89.5695559726789, 220.035868626328, 121.088220495873,
215.86027536845, 110.382361022946, 266.694209422113, 97.2656409566826,
199.965929017563, 114.208416940259, 155.021887855508, 84.6120875356639,
199.733013760155, 111.110948412579, 199.452800539018, 123.88609940183,
133.35290685942, 111.102500534416, 187.941616836947, 98.1187213641864,
234.046011959798, 123.069956877031, 120.168919427731, 127.988132471614,
232.385450852365, 98.7424047712025, 146.951765653127, 105.750717660517,
145.651300506675, 79.970069735942, 258.883932728549, 87.6153194163473,
115.796841416953, 106.095938726634, 166.706649965912, 101.298698606081,
146.769977649674, 108.152494439895, 195.816006705639, 174.924881837074,
249.006880104317, 86.1696831009276, 159.538333671611, 80.2393601090779,
174.212353742289, 63.3733093603744, 186.199723559331, 107.657764218047,
160.516124857554, 126.626480741589, 168.920145705005, 109.61880989202,
105.320503617021, 129.726085051763, 115.527671391502, 106.433077565201,
190.60022087193, 77.0231296429845, 112.304592197165, 119.858845552353,
206.728492576271, 107.217902289816, 139.122047844433, 119.25886272846,
122.684227359743, 103.792504202237, 210.152362882267, 120.954970591184,
104.686393917398, 214.792876769027, 191.32610530565, 79.7480267333126,
222.855494499398, 91.1213746094421, 140.845628513733, 111.331069979845,
177.763178886566, 99.5254364471716, 140.033980251223, 91.6609508499355,
130.849559200087, 135.593791669404, 217.92957885355, 135.812625320434,
250.986371108359, 85.4232633921898, 196.743119093691, 78.9173250714225,
225.198796106589, 134.913331968554, 156.164833932428, 107.713865336429,
166.808641166629, 97.9876882754738, 152.573043104419, 95.9305459322376,
171.318833924186, 111.86454460322, 182.048554894802, 97.4309279145268,
152.878913044185, 133.997168147049, 205.307168608753, 211.624746856654,
175.627827887756, 100.98775562272, 214.86931244031, 81.6376877034831,
119.379609110721, 92.9686487094286, 209.254282896944, 93.4634071823987,
161.94630255339, 119.06507074465, 223.306623758199, 95.2261288985329,
196.493161458612, 131.601943103327, 154.470748213283, 96.1410329374805,
199.033866240683, 123.609976698023, 240.952161634687, 120.094010793925,
249.304657999003, 98.3497312800454, 210.566280496529, 93.4448724993971,
208.160904238936, 144.170162357839, 238.586686851671, 117.022424209453,
141.61642579013, 106.825030089261, 227.534764808432, 76.6747391583434,
202.614782284018, 145.926106545157, 164.683001768332, 104.052141805374,
186.763888372458, 290.37355482083, 247.792756149166, 121.924889056454,
139.544795675081, 90.5098652870819, 128.81228555815, 97.8303811816291,
158.302258072064, 92.8779921648365, 203.965152617164, 89.5191395137694,
128.750026005545, 119.657761598295, 179.974247909845, 133.466823057803,
238.607474287195, 116.294720660791, 201.864700091069, 112.108435629464,
271.062377507466, 83.4109742479969, 239.645348081583, 130.262886667144,
152.792196650035, 176.884388948181, 162.02645286672, 98.7427099479103,
137.316891063804, 122.648306726416, 125.046669859126, 100.13272442114,
180.137447522718, 217.650850807303, 149.685622937828, 100.501021672135,
139.485974397326, 97.2504131463864, 168.918196600772, 149.435096996274,
196.609242398287, 118.348909102341, 97.2902505760102, 79.5321139091445,
234.000338636812, 162.735625873905, 258.4290279748, 82.6042631207027,
234.984151251283, 134.304026107081, 246.673584201586, 132.418632361268,
137.06069432398, 103.267931251672, 181.858657832316, 108.533312446982,
177.572294130749, 130.488060482833, 183.539693789732, 143.39418697124,
155.657584081672, 144.60809105994, 205.197357091028, 124.319639509842,
153.618817439234, 120.377345697365, 157.628795128211, 158.939875199937,
149.213503553992, 103.583978611559, 143.635257000402), brk = c(0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,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1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2)), .Names = c("trial", "id",
"ttime", "se", "brk"), row.names = c(NA, -600L), class = "data.frame")

最佳答案

如果您正在谈论方面之间的空间,您可以尝试这个(另请注意,我们没有 short_brkslong_brks 所以我从您的示例代码中删除了它们)。 grid unit 需要功能。

require(ggplot2)
require(grid)

avtimes3$id <- factor(avtimes3$id)
## create and store plot
p <- ggplot(avtimes3, aes(x=trial, y=ttime, colour=id)) +
facet_grid(. ~ brk, scales = "free") +
geom_point(shape=21, fill="white") +
## remove space between panels
opts(panel.margin = unit(0, "lines")) +
ylab("Time taken (ms)") +
xlab("Trial No.")


## as you had
p + stat_smooth(method="loess")

scatterplot with loess lines by ID and facet
## only one line per facet
p + stat_smooth(method="loess", aes(colour=NULL))

scatterplot with loess lines by facet only

编辑:重读你写的和试过的,我想你可能想要这个:
## setup plot
p <- ggplot(avtimes3, aes(x=trial, y=ttime, colour=id)) +
geom_point(shape=21, fill="white") +
ylab("Time taken (ms)") +
xlab("Trial No.")

p + stat_smooth(aes(group = brk), method="loess")

three loess lines on scatterplot no facetting

这里与您之前的不同之处在于 stat_smooth 的第一个参数。是映射,第五是方法。在 R你有两个选择(也许更多)。按顺序给出参数或明确命名参数。在您的第二个示例中,您乱序提供了参数,并且没有明确命名,例如:
p + stat_smooth(method = "loess", mapping = aes(group = brk))

为每个 id 获取单独的行并按 brk 分组有点棘手(概念上)。我们需要 brk 和 id 的交互。单独着色是行不通的,就像大多数几何图形一样。
p + stat_smooth(method = "loess", mapping = aes(group = interaction(brk, id)))

scatterplot with loess lines broken down by id and position

关于r - 如何设置 ggplot2 stat_smooth() 取值的范围以适合线条?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11559094/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com