我已经在 Excel 中制作了一些图表,但是图片质量不太好。因此,我正在尝试在 R 中设计相同的图表。
我正试图在 R 中绘制这个图表:
我已经完成了这个任务。
c <- ggplot(crises_df, aes(x = as.numeric(Year), y = Number, fill = Crises)) +
geom_area()
plot(c)
然而,结果是这样的:
![enter image description here](https://istack.dev59.com/wGWnS.webp)
我的数据在这里。
structure(list(Year = c("1980", "1980", "1980", "1980", "1980",
"1981", "1981", "1981", "1981", "1981", "1981", "1981", "1981",
"1981", "1981", "1981", "1981", "1982", "1982", "1982", "1982",
"1982", "1982", "1982", "1982", "1983", "1983", "1983", "1983",
"1983", "1983", "1983", "1983", "1983", "1983", "1983", "1983",
"1983", "1983", "1984", "1984", "1984", "1984", "1984", "1985",
"1985", "1985", "1985", "1985", "1985", "1986", "1986", "1987",
"1987", "1987", "1987", "1987", "1987", "1987", "1988", "1988",
"1988", "1988", "1988", "1988", "1988", "1988", "1988", "1989",
"1989", "1989", "1989", "1989", "1989", "1990", "1990", "1990",
"1990", "1990", "1990", "1990", "1990", "1991", "1991", "1991",
"1991", "1991", "1992", "1992", "1992", "1992", "1992", "1992",
"1992", "1992", "1993", "1993", "1993", "1993", "1993", "1993",
"1993", "1994", "1994", "1994", "1994", "1994", "1994", "1994",
"1994", "1994", "1994", "1994", "1994", "1994", "1995", "1995",
"1995", "1995", "1995", "1995", "1995", "1996", "1996", "1996",
"1996", "1997", "1997", "1997", "1997", "1997", "1997", "1997",
"1997", "1997", "1997", "1997", "1998", "1998", "1998", "1998",
"1998", "1998", "1998", "1998", "1998", "1998", "1998", "1998",
"1998", "1998", "1998", "1999", "1999", "1999", "2000", "2001",
"2001", "2002", "2002", "2002", "2002", "2002", "2004", "2005",
"2007", "2007", "2008", "2008", "2008", "2008", "2008", "2008",
"2008", "2008", "2008", "2008", "2008", "2008", "2008", "2008",
"2008", "2008", "2008", "2008", "2009", "2009", "2012", "2012",
"2013", "2014", "2014", "2014", "2014", "2014", "2015", "2015",
"2015", "2015", "2015", "2016"), Crises = c("Banking Crisis",
"Banking Crisis", "Banking Crisis", "Currency Crisis", "Currency Crisis",
"Banking Crisis", "Banking Crisis", "Banking Crisis", "Currency Crisis",
"Currency Crisis", "Currency Crisis", "Currency Crisis", "Currency Crisis",
"Sovereign Debt Crisis", "Sovereign Debt Crisis", "Sovereign Debt Crisis",
"Sovereign Debt Crisis", "Banking Crisis", "Currency Crisis",
"Currency Crisis", "Currency Crisis", "Sovereign Debt Crisis",
"Sovereign Debt Crisis", "Sovereign Debt Crisis", "Sovereign Debt Crisis",
"Banking Crisis", "Banking Crisis", "Banking Crisis", "Banking Crisis",
"Currency Crisis", "Currency Crisis", "Currency Crisis", "Currency Crisis",
"Currency Crisis", "Sovereign Debt Crisis", "Sovereign Debt Crisis",
"Sovereign Debt Crisis", "Sovereign Debt Crisis", "Sovereign Debt Crisis",
"Banking Crisis", "Currency Crisis", "Currency Crisis", "Sovereign Debt Crisis",
"Sovereign Debt Crisis", "Banking Crisis", "Currency Crisis",
"Currency Crisis", "Currency Crisis", "Sovereign Debt Crisis",
"Sovereign Debt Crisis", "Currency Crisis", "Currency Crisis",
"Banking Crisis", "Banking Crisis", "Banking Crisis", "Banking Crisis",
"Currency Crisis", "Currency Crisis", "Currency Crisis", "Banking Crisis",
"Banking Crisis", "Banking Crisis", "Banking Crisis", "Banking Crisis",
"Banking Crisis", "Currency Crisis", "Currency Crisis", "Currency Crisis",
"Banking Crisis", "Banking Crisis", "Banking Crisis", "Currency Crisis",
"Sovereign Debt Crisis", "Sovereign Debt Crisis", "Banking Crisis",
"Banking Crisis", "Currency Crisis", "Currency Crisis", "Currency Crisis",
"Currency Crisis", "Sovereign Debt Crisis", "Sovereign Debt Crisis",
"Banking Crisis", "Banking Crisis", "Banking Crisis", "Banking Crisis",
"Banking Crisis", "Banking Crisis", "Banking Crisis", "Banking Crisis",
"Currency Crisis", "Currency Crisis", "Currency Crisis", "Currency Crisis",
"Currency Crisis", "Banking Crisis", "Banking Crisis", "Banking Crisis",
"Currency Crisis", "Currency Crisis", "Currency Crisis", "Currency Crisis",
"Banking Crisis", "Banking Crisis", "Banking Crisis", "Banking Crisis",
"Banking Crisis", "Currency Crisis", "Currency Crisis", "Currency Crisis",
"Currency Crisis", "Currency Crisis", "Currency Crisis", "Currency Crisis",
"Currency Crisis", "Banking Crisis", "Banking Crisis", "Banking Crisis",
"Banking Crisis", "Banking Crisis", "Banking Crisis", "Currency Crisis",
"Banking Crisis", "Banking Crisis", "Currency Crisis", "Currency Crisis",
"Banking Crisis", "Banking Crisis", "Banking Crisis", "Banking Crisis",
"Banking Crisis", "Banking Crisis", "Currency Crisis", "Currency Crisis",
"Currency Crisis", "Currency Crisis", "Currency Crisis", "Banking Crisis",
"Banking Crisis", "Banking Crisis", "Banking Crisis", "Banking Crisis",
"Banking Crisis", "Currency Crisis", "Currency Crisis", "Currency Crisis",
"Currency Crisis", "Currency Crisis", "Currency Crisis", "Sovereign Debt Crisis",
"Sovereign Debt Crisis", "Sovereign Debt Crisis", "Currency Crisis",
"Currency Crisis", "Sovereign Debt Crisis", "Currency Crisis",
"Banking Crisis", "Sovereign Debt Crisis", "Banking Crisis",
"Currency Crisis", "Currency Crisis", "Sovereign Debt Crisis",
"Sovereign Debt Crisis", "Currency Crisis", "Currency Crisis",
"Banking Crisis", "Banking Crisis", "Banking Crisis", "Banking Crisis",
"Banking Crisis", "Banking Crisis", "Banking Crisis", "Banking Crisis",
"Banking Crisis", "Banking Crisis", "Banking Crisis", "Banking Crisis",
"Banking Crisis", "Banking Crisis", "Banking Crisis", "Banking Crisis",
"Banking Crisis", "Banking Crisis", "Banking Crisis", "Banking Crisis",
"Currency Crisis", "Currency Crisis", "Currency Crisis", "Sovereign Debt Crisis",
"Currency Crisis", "Banking Crisis", "Banking Crisis", "Currency Crisis",
"Currency Crisis", "Sovereign Debt Crisis", "Currency Crisis",
"Currency Crisis", "Currency Crisis", "Currency Crisis", "Sovereign Debt Crisis",
"Currency Crisis"), Number = c(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, 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, 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, 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, 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, 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, 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, 1, 1, 1,
1, 1)), row.names = c(NA, -201L), class = "data.frame")