【问题标题】:What is this plot called as ? Is it possible to make a similar plot using ggplot in R?这个情节叫什么?是否可以在 R 中使用 ggplot 制作类似的图?
【发布时间】:2020-06-24 17:28:42
【问题描述】:

你好,谁能指导我找到一个制作类似图表的好教程?

【问题讨论】:

  • 这看起来像area plot
  • 您有什么数据可以帮助您吗?

标签: r ggplot2 plot graph visualization


【解决方案1】:

我想这会让你接近:

library(ggplot2)

types <- c("BEV", "PHEV_diesel", "Hybrid_diesel", "ICE_CNG", 
           "ICE_diesel", "ICE_gasoline")

pal <- c("#db843d", "#29909f", "#725990", "#82a136", "#d9d9d9", "#9c9e9d")

years <- c(2000, 2001, 2020, 2026, 2045, 2049, 2050)
ICE_diesel <- spline(years, c(1500, 1600, 3500, 3900, 1000, 900, 900), n = 101)$y
BEV <-  2500/(1 + exp(-0.09 * seq(-110, 60, length.out = 101)))
vals <- c(BEV, rep(0, 101), BEV * 0.5, BEV * 0.2, ICE_diesel, ICE_diesel * 0)

df <- data.frame(types = factor(rep(types, each = 101), levels = types),
           vehicles = vals, years = seq(2020, 2050, length.out = 101))

ggplot(df, aes(years, vehicles, fill = types)) +
  geom_area(position = "stack") +
  coord_cartesian(ylim = c(0, 7000), expand = 0) +
  scale_y_continuous(breaks = 0:7 * 1000) +
  theme_minimal() +
  scale_fill_manual(values = pal) +
  theme(panel.grid.major.y = element_line(size = 1, color = "black", linetype = 1),
        panel.grid.minor.y = element_blank(),
        panel.grid.major.x = element_blank(),
        panel.grid.minor.x = element_blank(),
        axis.line = element_line(),
        text = element_text(size = 14, face = "bold")) +
  labs(title = "Global bus stock by technology - eMob",
       y = "Thousand vehicles", x = "", fill = "")

【讨论】:

  • 令人印象深刻,几乎没有来自 OP 的数据的精确复制!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-12-19
  • 1970-01-01
  • 2022-08-20
  • 2015-11-03
相关资源
最近更新 更多