Create an interactive level plot (heatmap)

276 views Asked by At

I have some test data that looks like this:

library(rbokeh)
library(lattice)

Date<-as.Date(c("2017-01-01","2017-01-01","2017-01-01","2017-01-02","2017-01-02","2017-01-02","2017-01-03","2017-01-03","2017-01-03","2017-01-4","2017-01-4","2017-01-4"))
Date<-as.POSIXct(Date)
Y<-c(1,2,3,1,2,3,1,2,3,1,2,3)
Temp<-c(20,23,25,19,20,21,18,19,20,13,17,19)
DF<-data.frame(Date,Y,Temp)

I visualize it using lattice levelplot like this:

dev.new(width=15, height=6)
levelplot(Temp ~ Date * Y, data = DF,ylim=c(3,1),
  xlab = "TimeStamp", ylab = "Temp",
  main = "Test", aspect=0.4,
  col.regions =colorRampPalette(c('blue','red')),at=seq(13, 25, length.out=120))

I have started using rbokeh to create interactive plots in order to zoom in on various aspects of the x (date) axis for basic data exploration. But I cant find a way to create a similar kind of rbokeh-ish plot for this kind of levelplot. Is there a way to have rbokeh create a levelplot, or if not someother library that can?

1

There are 1 answers

1
JohnCoene On
devtools::install_github("JohnCoene/echarts4r")

library(echarts4r)

DF %>% 
    dplyr::mutate(Date = as.Date(Date)) %>% 
    e_charts(Date) %>% 
    e_heatmap(Y, Temp) %>% 
    e_visual_map(Temp)