簡體   English   中英

這個 plot 叫什么? 是否可以在 R 中使用 ggplot 制作類似的 plot?

[英]What is this plot called as ? Is it possible to make a similar plot using ggplot in R?

在此處輸入圖像描述

嗨,誰能指導我找到一個制作類似圖表的好教程?

我想這會讓你接近:

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 = "")

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM