我发现了我打算用于降水数据分析的 nsRFA 包,我发现函数consistencyplot()
我觉得很棒。
> library(nsRFA)
> data(hydroSIMN)
> head(annualflows)
cod anno dato
1 1 1956 1494
2 1 1957 1309
3 1 1958 1699
4 1 1959 1467
5 1 1960 1918
6 1 1961 1469
> y <- annualflows["anno"][,]
> cod <- annualflows["cod"][,]
> consistencyplot(y,cod)
但我无法使用其他数据,但包示例手册(vignette("nsRFA_ex01", package="nsRFA")
)中给出的示例。所以我试图用ggplot复制情节,但遗憾的是我迷失了。
我发现很难给出一个有意义的例子但是使用上面例子中的数据可以有人提出任何想法吗?
答案 0 :(得分:2)
你可以这样做:
library(ggplot2)
library(dplyr)
annualflows %>% ggplot(aes(x = anno, y = cod)) +
geom_point(
shape = 45,
size = 5,
col = "blue"
) +
scale_y_reverse(
breaks = seq(10, 50, by = 10)
) +
scale_x_continuous(breaks = seq(1920, 1980, by = 10)) +
labs(
x = "Year",
y = "Code"
) +
theme(
panel.background = element_blank(),
panel.border = element_rect(fill = NA),
text = element_text(size = 10),
panel.grid.major.x = element_line(color = "grey80"),
panel.grid.major.y = element_line(color = "grey80")
)