I am trying to make a plot created with the trace_explorer function from buraR package interactive using the ggplotly function but the resulting plot is not the expected.
Here is the code :
library(ggplot2)
library(bupaR)
patients <- eventdataR::patients # dataset from bupaR
df <- eventlog(patients,
case_id = "patient",
activity_id = "handling",
activity_instance_id = "handling_id",
lifecycle_id = "registration_type",
timestamp = "time",
resource_id = "employee")
tr <- df %>% processmapR::trace_explorer(type = "frequent", coverage = 1.0)
# tr # print the ggplot to see the expected output!
ggplotly(tr)
and the resulting plot
I tried to use the theme option in ggplot2 and then the layout function but the result is still the same without the legend.
ggtrace <- trace_explorer(df,
type = "frequent",
coverage = 1.0)
ggtrace <- ggtrace +
theme (legend.position="none") +
theme(axis.text.x=element_blank(),
axis.ticks.x=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()
)
plotly_trace <- ggplotly(ggtrace)
layout(plotly_trace,
margin=list(l=50, b=50),
legend=list(x=1.05)
)
The expected out should be a like the original ggplot but with interactive options coming from plotly.
Note I am using previous version of the packages and want to keep these versions.
> packageVersion('ggplot2')
[1] ‘3.3.0’
> packageVersion('bupaR')
[1] ‘0.5.2’