I'm creating a document with a lot of ggplotly objects. This returns in a big file size. Apparently we could use the partial_bundle function to reduce the file size of plotly object. Unfortunately when I want to use this function it returns an error:
Error in curl::curl_download(paste0("https://cdn.plot.ly/", bundle_script), : HTTP response code said error [cdn.plot.ly]: The requested URL returned error: 403 This probably happens because I'm working on a VM. Luckily we have this wonder answer, but I'm stuck at the part where we want to download the files:
library(plotly) library(ggplot2) p <- ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width)) + geom_point() plt <- ggplotly(p) %>% partial_bundle(local = FALSE) plt$dependencies[[5]] plt$dependencies[[5]]$src$href link <- paste0(plt$dependencies[[5]]$src$href, "/", plt$dependencies[[5]]$script) download.file(url = link, destfile = paste0("~/", "file.txt")) Output:
Error in download.file(url = link, destfile = paste0("~/", "file.txt")) : cannot open URL 'https://cdn.plot.ly/plotly-basic-2.11.1.min.js' In addition: Warning message: In download.file(url = link, destfile = paste0("~/", "file.txt")) : URL 'https://cdn.plot.ly/plotly-basic-2.11.1.min.js': status was 'HTTP response code said error' This probably happens because I'm working on a VM without internet connection. So I was wondering if anyone knows how to reduce the file sizes of ggplotly object without using internet?
destfile =you should use so can copy these to the VM?toWebGL()?