R 中时间序列的曲面图

问题描述 投票:0回答:1

可以直接根据 R 中的每日数据时间序列创建曲面图吗?

该表面的 x 轴为月份,y 轴为年份,z 轴为值。

dt <- seq(as.Date('2006-01-01'),as.Date('2020-01-31'),by = 1)
temp <- rnorm(5144, mean=21, sd=5)

df <- data. Frame(dt, temp)
r ggplot2 charts surface
1个回答
0
投票

我认为

temp
temperature
的缩写。根据您的玩具数据,
heatmap
似乎合适

dt <- seq(as.Date('2006-01-01'),as.Date('2020-01-31'),by = 1)
temp <- rnorm(5144, mean = 21, sd = 5)
df <- data.frame(dt, temp)

library(dplyr)
library(lubridate)
library(plotly)

df |>
  mutate(month = month(dt), 
         year = year(dt)) |>
  plot_ly(x = ~ month, y = ~ year, z = ~ temp, type = 'heatmap')

给予

曲面图需要将矩阵传递给

z
,请参阅
?add_surface

© www.soinside.com 2019 - 2024. All rights reserved.