Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

running from within R produces no PNG #119

Closed
mschilli87 opened this issue Aug 14, 2018 · 9 comments
Closed

running from within R produces no PNG #119

mschilli87 opened this issue Aug 14, 2018 · 9 comments

Comments

@mschilli87
Copy link

I am trying to render a 3D plotly plot I made in R statically from different angles as PNG files.
I managed to dump the plotly object to a JSON file but running

system("orca graph /tmp/test.json -o /tmp/model.png")

does not produce the PNG file.
It runs for ~3sec and finishes but all it leaves behind is an empty /tmp/orca-build directory.

Surprinsingly, running

orca graph /tmp/test.json -o /tmp/model.png

(copy/paste-ed from R, just to be sure) from shell works produces the correct PNG file.

Any clues what is going on?
I want to generate many PNGs to use them as frames for a video, so being able to do this from an R loop would be much more convenient than looping in R to create many JSONs and looping again in shell to convert them all.

@etpinard
Copy link
Contributor

Does

library(plotly)

p <- plot_ly(x = 1:10, y = 1:10, color = 1:10)
b <- plotly_build(p)$x[c("data", "layout")]
json <- plotly:::to_JSON(b)

cmd <- sprintf("orca graph '%s' -o r-export-test.png", json)
system(cmd)

as in our quick start instructions work for you though?

@mschilli87
Copy link
Author

@etpinard: Yes it does, but this is a much more basic plot and orca finishes basically immediately.
I guess this only occurs when some more heavy lifting is involved.
My JSON is > 3 MB, but it worked 10/10 time from the shell and 0/10 times via system from R.

@etpinard
Copy link
Contributor

Have you tried the new orca function in R

https://github.com/plotly/orca/pull/94/files

@mschilli87
Copy link
Author

It throws

Error: No mapbox access token found. Obtain a token here
https://www.mapbox.com/help/create-api-access-token/
Once you have a token, assign it to an environment variable 
named 'MAPBOX_TOKEN', for example,
Sys.setenv('MAPBOX_TOKEN' = 'secret token')

instead of using my local installation of orca

@etpinard
Copy link
Contributor

Are you trying to export a scattermapbox graph? If so, then yes you'll need to add the access token to your shell environment.

Now, maybe the R api wants you to have MAPBOX_TOKEN set no matter what graph you're trying to export. I don't know., but that would be a question for https://github.com/ropensci/plotly

@mschilli87
Copy link
Author

mschilli87 commented Aug 17, 2018

Are you trying to export a scattermapbox graph? If so, then yes you'll need to add the access token to your shell environment.

I honestly don't even know what a scattermapbox graph is. So unless add_lines on a 3D plot somehow does this in the background, the answer is no. 😄

Now, maybe the R api wants you to have MAPBOX_TOKEN set no matter what graph you're trying to export. I don't know., but that would be a question for https://github.com/ropensci/plotly

But shouldn't command line orca run fine when called from within R just like when called from shell? Or is this something I'd have to take up to the base-R devs? 😉

@mschilli87
Copy link
Author

This is very weird: Now, I am also not able to get the PNG when running

orca graph /tmp/test.json -o /tmp/model.png

but

cd /tmp && orca graph test.json -o model.png && cd -

works.

So I went ahead and tried

system("cd /tmp && orca graph test.json -o model.png")

and I got the PNG!


Should I close this issue and open a new one or just change this issues title to further investigate?

@etpinard
Copy link
Contributor

Should I close this issue and open a new one or just change this issues title to further investigate?

This appears like a duplicate of #101

@mschilli87
Copy link
Author

I can confirm that I indeed had a ~/model.png from the 'unsuccessful' runs. 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants