r - R中的几个返回绘图
问题描述
尝试在 R 中绘制非常基本的数据。
Year X1 X2 X3 X4 X5 X6 X7
2004 0.91 0.23 0.28 1.02 0.90 0.95 0.94
2005 0.57 -0.03 0.88 0.52 0.47 0.55 0.56
2006 1.30 -0.43 1.95 1.27 1.00 1.19 1.26
2007 0.44 0.63 0.60 0.34 0.60 0.50 0.46
2008 1.69 0.34 -2.81 -2.41 -1.80 -1.87 -1.83
我正在寻找的是随着时间推移的基本折线图,x = year
并且y = value
图表本身应该包括所有X1
- X7
。
我正在查看ggplot2
功能,但我不知道从哪里开始。
# Libraries
library(tidyverse)
library(streamgraph)
library(viridis)
library(plotly)
# Plot
p <- data %>%
ggplot(aes(x = year, y = n) +
geom_area() +
scale_fill_viridis(discrete = TRUE) +
theme(legend.position = "none") +
ggtitle("multiple X over time") +
theme_ipsum() +
theme(legend.position = "none")
ggplotly(p, tooltip = "text")
请有人帮我解决一下吗?有没有一种简单的方法可以在基本 R 中做到这一点?
谢谢。
解决方案
推荐阅读
- powershell - 使用 Powershell 从 Artifactory 存储库下载文件夹
- python - 在 AWS SAM 中运行 pytest 不使用 template.yaml 中的环境变量
- mysql - 连接本地环境中已有的数据库
- javascript - 如何在 React 中动态加载 JSON 文件?
- css - 固定位置的“clearfix”
- asp.net-core-webapi - Asp.net core 3.1 webapi iis 8无法连接到sql server
- javascript - 元素类型无效:应为字符串(用于内置组件)或类/函数(用于复合组件)但得到:对象。反应原生
- flutter - 如何在 Listtile 的前导和尾随之间对齐小部件?- 颤振
- flutter - Flutter如何让Container展开全高
- javascript - Jasmine Rails,未从子目录加载 src_files