如何创建一个堆叠线图 [英] How to create a stacked line plot

查看:525
本文介绍了如何创建一个堆叠线图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有多种解决方案可以在R中创建堆叠棒图,但是如何绘制堆叠线图?

There are multiple solutions to create a stacked bar plot in R, but how to draw a stacked line plot?

推荐答案

堆叠线图使用 ggplot2 包创建。

一些示例数据:

set.seed(11)
df <- data.frame(a = rlnorm(30), b = 1:10, c = rep(LETTERS[1:3], each = 10))

$ c> geom_area :

The function for this kind of plot is geom_area:

library(ggplot2)
ggplot(df, aes(x = b, y = a, fill = c)) + geom_area(position = 'stack')

这篇关于如何创建一个堆叠线图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆