简体   繁体   中英

The ggplotly() causes error object 'tickvals' not found

I use the code below to create an activity frequency plot but when I include it in ggplotly( ) I get object 'tickvals' not found

library(bupaR)
library(eventdataR)
library(plotly)

sip<-bupaR::simple_eventlog(eventlog = eventdataR::sepsis,
                case_id = "case_id",
                activity_id = "activity",
                #activity_instance_id = "activity_instance_id",
                timestamp = "timestamp",
                #lifecycle_id = "lifecycle",
                resource_id = "resource"
                )

sip %>% activity_frequency(level="trace") %>% plot()
ggplotly( sip %>% activity_frequency(level="trace") %>% plot()

Try this:

library(bupaR)
library(eventdataR)
library(plotly)
library(edeaR)

#to avoid the axis overlapping
layout_ggplotly <- function(gg, x = -0.02, y = -0.08){
    gg[['x']][['layout']][['annotations']][[1]][['y']] <- x
    gg[['x']][['layout']][['annotations']][[2]][['x']] <- y
    gg
}

#making a plot
sip <- simple_eventlog(sepsis,
                       case_id = "case_id",
                       activity_id = "activity",
                       timestamp = "timestamp",
                       resource_id = "resource"
)

k <- sip %>% 
     activity_frequency(level="trace") %>%
     plot()

graph <- ggplotly(k) %>%
         layout_ggplotly

graph

Output:

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM