我有这样的“子示例”数据
structure(list(monthyr = structure(c(17287, 17287, 17287, 17287,
17287, 17287, 17287, 17287, 17287, 17287, 17287, 17287, 17287,
17287, 17287, 17287, 17287, 17287), class = "Date"), Location = c("TAI",
"NAM", "LUI", "HEE", "BRA", "KEI", "TAI", "NAM", "LUI", "HEE",
"BRA", "KEI", "TAI", "NAM", "LUI", "HEE", "BRA", "KEI"), ID = structure(c(-719050,
-718685, -718320, -717954, -717589, -717224, -719050, -718685,
-718320, -717954, -717589, -717224, -719050, -718685, -718320,
-717954, -717589, -717224), class = "Date"), Type = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L,
3L), .Label = c("Industrial.compound", "Pesticide", "Pharmaceutical"
), class = "factor"), value = c(0.885230769230769, 1.9203125,
3.26635, 0.950052631578947, 2.87133333333333, 3.194775, 0.0823076923076923,
0.190833333333333, 0.467142857142857, 0.58173125, 0.1375, 0.3777475,
0.0215555555555556, 0.240236363636364, 0.340790909090909, 0.150083333333333,
0.103333333333333, 0.2665)), row.names = c(29L, 65L, 107L, 149L,
194L, 237L, 279L, 315L, 357L, 399L, 444L, 487L, 529L, 565L, 607L,
649L, 694L, 737L), class = "data.frame")
>
我想使用streamgraph
来自https://github.com/hrbrmstr/streamgraph的包
所以我这样做了:
sg<-streamgraph(subexample,"Type","value", "ID" )%>%
sg_legend(show=TRUE, label="Parameter: ")%>%
sg_axis_x(1, "ID")%>% sg_axis_y(0)
我有一个不错的流图,但是当我添加sg_title
sg<-streamgraph(subexample,"Type","value", "ID" )%>%
sg_legend(show=TRUE, label="Parameter: ")%>%
sg_axis_x(1, "ID")%>% sg_axis_y(0)%>%sg_title("Title example")
我在控制台中得到一个巨大的代码,而不是带有标题的流图。
我试着像这样分开它:
sg<-streamgraph(subexample,"Type","value", "ID" )%>%
sg_legend(show=TRUE, label="Parameter: ")%>%
sg_axis_x(1, "ID")%>% sg_axis_y(0)
sg_title(sg, "Title example")
但没有结果。
你知道我需要做什么才能获得带有标题的流图吗?