I found this example here which provides a perfect way of getting rid of the extra terms added by ggplotly to the legends.
My problem is that the code in the solution removes everything after a comma ,
and I have an actual comma is my legends which are in the format of DIC, Spliced
The code is:
for (i in 1:length(myplot$x$data)){
if (!is.null(myplot$x$data[[i]]$name)){
myplot$x$data[[i]]$name = gsub("\\(","",str_split(myplot$x$data[[i]]$name,",")[[1]][1])
}
}
My original plot has this kind of legend:
After applying the code, I loose my Spliced/Uspliced
terms in my legends