contour plot with date-time strings as x values

三世轮回 提交于 2019-12-08 02:53:30

问题


I am trying to produce a color contour plot showing time along the x axis, depth along the y and temperature as the z values. Time is given as:

"2011-01-01 00:01"

i.e. "%Y-%m-%d %H:%M"

Is there a method for producing the color contour plot from these, and using

filled.contour(Time,Depth,temp)

example:

time <- c("2011-01-01 01:00", "2011-01-01 02:00", "2011-01-01 03:00",
    "2011-01-01 04:00")
depth <- seq(1,10,by = 1)
seq1 <-  seq(1:40)
temp <- matrix(seq1, 10)

Every column of temp represents a different time and every row represents a different depth.


回答1:


This works for me:

time2 <- as.POSIXct(time)

Result:

> time2
## [1] "2011-01-01 01:00:00 EST" "2011-01-01 02:00:00 EST"
## [3] "2011-01-01 03:00:00 EST" "2011-01-01 04:00:00 EST"

Now plot it:

filled.contour(time2,depth,t(temp))



来源:https://stackoverflow.com/questions/10782600/contour-plot-with-date-time-strings-as-x-values

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!