下面是我在R中的 Dataframe 示例:
structure(list(Series = c("A", "B", "A", "B", "A", "B", "A",
"B", "A", "B", "A", "B", "A", "B", "A", "B", "A", "B", "A", "B"
), date = structure(c(19415, 19415, 19415, 19415, 19415, 19415,
19415, 19415, 19415, 19415, 19416, 19416, 19416, 19416, 19416,
19416, 19416, 19416, 19416, 19416), class = "Date"), ccy = c("CHF",
"CHF", "EUR", "EUR", "GBP", "GBP", "JPY", "JPY", "USD", "USD",
"CHF", "CHF", "EUR", "EUR", "GBP", "GBP", "JPY", "JPY", "USD",
"USD"), exp = c(-25.0260386883321, -13.4876728854438, 29.9242170197296,
28.1863060040971, -21.1816468152161, -17.6427844100702, -125.811601419233,
-116.187338952966, -1574.53746806177, -944.410592575117, 13.687475030189,
5.55257290367663, 22.1373554559174, 9.839306286417, 9.60824459042358,
8.43043547492962, 75.9856738242059, 19.8785641759769, -2531.47779912341,
-313.689149325403)), row.names = c(NA, 20L), class = "data.frame")
对于列ccy
中的每个唯一值,我想创建一个简单的折线图,其中包含两个系列(列series
中的A和B),值来自列date
和exp
。
每个图表的格式都是一样的,线条有两种不同的颜色,标题标识ccy
所指的内容,输出将是一个方形折线图网格。
最好的解决办法是什么?
1条答案
按热度按时间8hhllhi21#
您可以使用ggplot来完成此操作。
请注意,您为A和B指定的值相同,因此这两条线彼此重叠。