4

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

enter image description here

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)
)

enter image description here

The expected out should be a like the original ggplot but with interactive options coming from plotly.

expected plot

plotly options

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’
Alanq
  • 121
  • 3
  • 10
  • Hi Alanq. Your question says that the output is not as expected. Could you explain what _is_ expected, and what is wrong with the output you have? This is not apparent from your question. – Allan Cameron Feb 06 '23 at 14:06
  • @AllanCameron Hello Allan, thank you for pointing that. I will update my question with the expected result. – Alanq Feb 06 '23 at 14:09
  • You need to provide a [minimal, reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) of your data. – M-- Feb 06 '23 at 14:11
  • @M Thank you M, I have updated my question pointing that the dataset is inside the library I am using. – Alanq Feb 06 '23 at 14:25

0 Answers0