1

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?

3
  • 1
    Are you trying to download the file from a computer with internet access? You'll need to download that from somewhere and then copy into your VM. Those CDN files should be static and don't really change based on your document contents. Commented Aug 4 at 14:44
  • @MrFlick, That could be indeed an option. I'm trying to download the file, but I'm not sure which destfile = you should use so can copy these to the VM? Commented Aug 4 at 14:49
  • 1
    Not sure if it'd work for you, but what about toWebGL()? Commented Aug 4 at 18:36

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.