R时间序列图不显示不同的y轴值,但是正确的趋势(R time

编程入门 行业动态 更新时间:2024-10-17 04:57:48
R时间序列图不显示不同的y轴值,但是正确的趋势(R time-series plot not showing different y-axis values, but correct trend)

我有一个很大的时间序列数据,头是:

date_time V1 V2 V3 V4 V5 13 2012-10-13 17:40:00 10/13/2012 17:40:00 0 15.8604 25.706 14 2012-10-13 18:00:00 10/13/2012 18:00:00 0 15.8508 25.688 15 2012-10-13 18:20:00 10/13/2012 18:20:00 0 15.8615 25.688 16 2012-10-13 18:40:00 10/13/2012 18:40:00 0 15.8637 25.686 17 2012-10-13 19:00:00 10/13/2012 19:00:00 0 15.868 25.686 18 2012-10-13 19:20:00 10/13/2012 19:20:00 0 15.8701 25.686

当我尝试在R中绘制数据时,它会显示正确的趋势,但是y轴刻度完全不同,最大值为12000(请参阅此处: https : //docs.google.com/file/d/0B6GUNg-8d30vcG5KdDkxOXR0QkU / edit?usp = sharing )?!? 但是,我的任何其他数据图都没有出现过如此奇怪的问题。

plot(date_time, data$V4, type='l', ylab = '??')

我的第二个问题 - 我的date_time(类:“POSIXlt”“POSIXt”)默认显示“月”。 是否可以在不使用strftime()和/或aggregate()的情况下显示为“月 - 年”?

I have a big time-series data, the head is:

date_time V1 V2 V3 V4 V5 13 2012-10-13 17:40:00 10/13/2012 17:40:00 0 15.8604 25.706 14 2012-10-13 18:00:00 10/13/2012 18:00:00 0 15.8508 25.688 15 2012-10-13 18:20:00 10/13/2012 18:20:00 0 15.8615 25.688 16 2012-10-13 18:40:00 10/13/2012 18:40:00 0 15.8637 25.686 17 2012-10-13 19:00:00 10/13/2012 19:00:00 0 15.868 25.686 18 2012-10-13 19:20:00 10/13/2012 19:20:00 0 15.8701 25.686

When I try to plot the data in R, it shows the correct trend, but a completely different y-axis scale with a maximum of 12000 (see here: https://docs.google.com/file/d/0B6GUNg-8d30vcG5KdDkxOXR0QkU/edit?usp=sharing)?!? However, I never had such a weird problem with any of my other data plots.

plot(date_time, data$V4, type='l', ylab = '??')

My second question -- my date_time (class: "POSIXlt" "POSIXt") shows "month" by default. Is it possible to show as "month-year" without using strftime() and/or aggregate()?

最满意答案

目前尚不清楚您是否已解决了第一个问题。 否则,对于第二个问题,可以使用带有xaxt =“n”的axis.POSIXct手动绘制轴:

plot(x=data$date_time, y=data$V4, type='l', ylab = '??',xaxt="n") ## note here axis.POSIXct(1, at=data$date_time,format='%b %Y')

在此处输入图像描述

在这里我的数据:

structure(list(date_time = structure(c(1350142800, 1350144000, 1350145200, 1350146400, 1350147600, 1350148800), class = c("POSIXct", "POSIXt"), tzone = ""), V1 = structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Names = c("13", "14", "15", "16", "17", "18"), .Label = "10/13/2012", class = "factor"), V2 = structure(1:6, .Names = c("13", "14", "15", "16", "17", "18"), .Label = c("17:40:00", "18:00:00", "18:20:00", "18:40:00", "19:00:00", "19:20:00"), class = "factor"), V3 = structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Names = c("13", "14", "15", "16", "17", "18"), .Label = "0", class = "factor"), V4 = structure(c(2L, 1L, 3L, 4L, 5L, 6L), .Names = c("13", "14", "15", "16", "17", "18"), .Label = c("15.8508", "15.8604", "15.8615", "15.8637", "15.8680", "15.8701"), class = "factor"), V5 = structure(c(3L, 2L, 2L, 1L, 1L, 1L), .Names = c("13", "14", "15", "16", "17", "18"), .Label = c("25.686", "25.688", "25.706"), class = "factor")), .Names = c("date_time", "V1", "V2", "V3", "V4", "V5"), row.names = c("13", "14", "15", "16", "17", "18"), class = "data.frame")

It is not clear if you have resolved your first problem or not. Otherwise, for your second question, you can use axis.POSIXct with xaxt="n" to plot the axis manually:

plot(x=data$date_time, y=data$V4, type='l', ylab = '??',xaxt="n") ## note here axis.POSIXct(1, at=data$date_time,format='%b %Y')

enter image description here

Here my data:

structure(list(date_time = structure(c(1350142800, 1350144000, 1350145200, 1350146400, 1350147600, 1350148800), class = c("POSIXct", "POSIXt"), tzone = ""), V1 = structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Names = c("13", "14", "15", "16", "17", "18"), .Label = "10/13/2012", class = "factor"), V2 = structure(1:6, .Names = c("13", "14", "15", "16", "17", "18"), .Label = c("17:40:00", "18:00:00", "18:20:00", "18:40:00", "19:00:00", "19:20:00"), class = "factor"), V3 = structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Names = c("13", "14", "15", "16", "17", "18"), .Label = "0", class = "factor"), V4 = structure(c(2L, 1L, 3L, 4L, 5L, 6L), .Names = c("13", "14", "15", "16", "17", "18"), .Label = c("15.8508", "15.8604", "15.8615", "15.8637", "15.8680", "15.8701"), class = "factor"), V5 = structure(c(3L, 2L, 2L, 1L, 1L, 1L), .Names = c("13", "14", "15", "16", "17", "18"), .Label = c("25.686", "25.688", "25.706"), class = "factor")), .Names = c("date_time", "V1", "V2", "V3", "V4", "V5"), row.names = c("13", "14", "15", "16", "17", "18"), class = "data.frame")

更多推荐

本文发布于:2023-07-26 00:27:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1268413.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:正确   趋势   时间   序列图   轴值

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!