R:两组地毯()线的垂直偏移

R:两组地毯()线的垂直偏移,r,graphics,R,Graphics,我试图在R中重现一张我多年前在SAS中做的图,结果由两个密度图和底部的地毯线组成,显示了观察结果。像这样: 但是我不知道如何抵消对rug()的两个调用的结果。我想这样做是为了使这两个系列在视觉上更加清晰,特别是在黑白印刷的情况下 以下是数据: # North America sub1 <- c(1666, 1798, 1872, 1872, 1872, 1873, 1874, 1877, 1884, 1905, 1910, 1910, 1913, 1913, 1913, 1914, 19

我试图在R中重现一张我多年前在SAS中做的图,结果由两个密度图和底部的地毯线组成,显示了观察结果。像这样:

但是我不知道如何抵消对
rug()
的两个调用的结果。我想这样做是为了使这两个系列在视觉上更加清晰,特别是在黑白印刷的情况下

以下是数据:

# North America
sub1 <-
c(1666, 1798, 1872, 1872, 1872, 1873, 1874, 1877, 1884, 1905,
1910, 1910, 1913, 1913, 1913, 1914, 1914, 1915, 1916, 1917, 1925,
1919, 1920, 1923, 1925, 1926, 1929, 1928, 1928, 1931, 1937, 1939,
1944, 1944, 1957, 1957, 1962, 1965, 1966, 1965, 1969, 1969, 1971,
1971, 1971, 1972, 1973, 1973, 1974, 1974, 1974, 1974, 1975, 1975,
1975, 1975, 1976, 1977, 1977, 1978, 1978, 1979, 1981, 1981, 1981,
1982, 1982, 1983, 1985, 1985, 1987, 1988, 1989, 1990, 1990, 1990,
1990, 1991, 1991, 1993, 1992, 1994, 1999)
# Europe
sub2 <-
c(1530, 1533, 1545, 1550, 1556, 1562, 1569, 1570, 1572, 1581,
1605, 1603, 1603, 1614, 1617, 1624, 1623, 1626, 1632, 1637, 1644,
1646, 1654, 1654, 1657, 1663, 1662, 1669, 1671, 1686, 1686, 1687,
1693, 1693, 1701, 1710, 1711, 1712, 1724, 1727, 1745, 1741, 1748,
1752, 1752, 1752, 1753, 1765, 1760, 1763, 1765, 1765, 1781, 1776,
1778, 1779, 1782, 1782, 1782, 1785, 1786, 1787, 1794, 1795, 1796,
1798, 1800, 1800, 1801, 1801, 1809, 1811, 1817, 1819, 1825, 1821,
1822, 1825, 1827, 1828, 1832, 1830, 1832, 1833, 1833, 1833, 1833,
1836, 1836, 1837, 1838, 1839, 1839, 1843, 1843, 1843, 1844, 1846,
1846, 1851, 1852, 1853, 1855, 1857, 1857, 1857, 1861, 1861, 1863,
1868, 1869, 1869, 1869, 1872, 1874, 1874, 1874, 1875, 1875, 1877,
1877, 1878, 1878, 1879, 1879, 1889, 1880, 1882, 1882, 1883, 1884,
1884, 1884, 1884, 1885, 1885, 1885, 1888, 1889, 1892, 1895, 1896,
1899, 1901, 1904, 1911, 1912, 1913, 1920, 1923, 1924, 1929, 1930,
1933, 1967, 1969, 1975, 1983, 1988, 1989, 1990, 1996)
北美 sub1来自:

那么从,看,

我将在这里使用
line
。只需将最后两行替换为:

rug(sub1, quiet=TRUE, col="red", line = -1)
rug(sub2, quiet=TRUE)
您可能还需要调整您的
ylim
,以便红色地毯不会侵犯线条。

来自:

那么从,看,

我将在这里使用
line
。只需将最后两行替换为:

rug(sub1, quiet=TRUE, col="red", line = -1)
rug(sub2, quiet=TRUE)
您可能还需要调整
ylim
,以便红色地毯不会侵犯线条

line: the number of lines into the margin at which the axis line
      will be drawn, if not 'NA'.
 pos: the coordinate at which the axis line is to be drawn: if not
      'NA' this overrides the value of 'line'.
rug(sub1, quiet=TRUE, col="red", line = -1)
rug(sub2, quiet=TRUE)