【发布时间】:2018-11-12 04:16:35
【问题描述】:
我有3列数据:(如下图
- 日期时间 LTP
- 20180102 09:16 1800
- ………… 我想在 R 中绘制它,以便在 x 轴上获得时间,在 y 轴上获得 LTP。由于每天大约有 360 行(每分钟 LTP 更改),x 变量应为 date:time 我是 R 新手,我需要这方面的帮助。感谢期待
【问题讨论】:
我有3列数据:(如下图
【问题讨论】:
试试这个:
library(zoo)
z <- read.zoo("myfile.dat", header = TRUE, index = 1:2, format = "%Y%m%d %H:%M", tz = "")
# classic graphics
plot(z)
# ggplot2 graphics
autoplot(z)
要为问题中提供的示例数据生成文件,试试这个;但是,只有一个点,您不会在折线图上看到任何东西。
cat("Date Time LTP\n20180102 09:16 1800", file = "myfile.dat")
【讨论】:
plot(z, xaxt = "n") 将省略 X 轴。现在在 plotrix 包中使用axis.break。
plot(z, xaxt = "n", type = "n")。现在使用lines 两次将每个子集分别覆盖在那个空图表上。