0

I have differences between hourly temperature and average temperature data from 1991 to 2021. I would like to plot 3D plot with ksdensity. Suppose that x= axis of year, y = axis of temperatrue differences from mean temperature, z= densities. How to generate a 3D kernel density plot? Here is the code of plot 2D kernel density.

Here is the temperature data.

https://docs.google.com/spreadsheets/d/1W8jzfqXxxHsWf1J6uZ_C7BqvOBcx8rXL/edit?usp=sharing&ouid=111186166036061320361&rtpof=true&sd=true

Tsyvarev
  • 60,011
  • 17
  • 110
  • 153
Jimin Eom
  • 9
  • 3
  • Does this answer your question? [Plot 3d density](https://stackoverflow.com/questions/13613157/plot-3d-density) – harre Jul 24 '22 at 11:54

1 Answers1

1

Try persp:

x <- rnorm(1000)
y <- 2 + x*rnorm(1000,1,.1) + rnorm(1000)
library(MASS)
den3d <- kde2d(x, y)
persp(den3d, box=FALSE)