【问题标题】:make a Stacked Area Graph In ggplot2在ggplot2中制作堆积面积图
【发布时间】:2016-02-23 20:32:25
【问题描述】:

我知道关于这个主题已经有一些严重的问题,但我仍然无法让我的工作。

我有一些标准偏差的这个data.frame

df_sd_ <- data.frame(data = c("Oct","Nov","Dec","Jan"), 
                       Rent = c(2.84,0.87,1.03,1.31),
                       Ibov = c(3.64,2.42,1.62,2.03), 
                       NTNB = c(1.61,1.25,1.58,0.64))

我需要绘制一个堆积面积图,类似于:

【问题讨论】:

标签: r charts ggplot2 area stacked-area-chart


【解决方案1】:

这是 R 图形食谱中的一个示例。

Library(ggplot2)
library(gcookbook)

head(uspopage)

ggplot(uspopage, aes(x=Year, y=Thousands, fill=AgeGroup)) + geom_area()

然后你会得到这样的东西

【讨论】:

    【解决方案2】:

    我的谦虚建议 - 你应该先整理你的数据(df_sd_),然后把它放到 ggplot 中。阅读并使用 pivot_longer 函数。

    【讨论】:

    • 点评来源: 嗨,这篇文章似乎没有为问题提供quality answer。请编辑您的答案并改进它,或者将其作为对问题的评论发布。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-10
    • 2023-03-27
    • 1970-01-01
    相关资源
    最近更新 更多