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

orca() does not support file paths #101

Closed
emallickhossain opened this issue Jul 25, 2018 · 12 comments · Fixed by #176
Closed

orca() does not support file paths #101

emallickhossain opened this issue Jul 25, 2018 · 12 comments · Fixed by #176

Comments

@emallickhossain
Copy link

I'm trying to export a static image in R using orca(), but it ignores the file path and just exports it to the current location of the script that I'm running.

For example, if I run orca(image, "/images/plot1.png") from a script located in /code/script.R, it saves it to /code/plot1.png instead of where I specified.

@etpinard
Copy link
Contributor

I think this has to do with the R wrapper.

Probably best to post on https://github.com/ropensci/plotly/issues/new

@debarundhar
Copy link

I'm having the same issue on Python 2.7. The filename is correct, but the figure is saved to the current directory instead of in the specified directory.

@etpinard
Copy link
Contributor

I'm having the same issue on Python 2.7. The filename is correct, but the figure is saved to the current directory instead of in the specified directory.

Can you share a code snippet of your attempt?

@debarundhar
Copy link

Here it is: I am saving two figures to disk, a 2D figure from matplotlib and a 3D figure from Plotly (using Orca). The 2D figure gets successfully saved to ./results/2d/test.png, while my Plotly figure gets saved to ./test.png instead of ./results/3d/test.png

save_dir = 'results'
save_fname = 'test'

if save_dir:

        plt.savefig('{}/2d/{}.png'.format(save_dir, save_fname))
        plt.close()

        call(['orca', 'graph', json.dumps(fig, cls=plotly.utils.PlotlyJSONEncoder),
              '-o', '{}/3d/{}.png'.format(save_dir, save_fname)])

@etpinard
Copy link
Contributor

what about:

call(['orca', 'graph', json.dumps(fig, cls=plotly.utils.PlotlyJSONEncoder),
              '-d', '{}/3d'.format(save_dir), '-o', '{}.png'.format(save_fname)])

?

@debarundhar
Copy link

@etpinard Yup, that works. Thanks!

@etpinard
Copy link
Contributor

Ok great. But yeah

call(['orca', 'graph', json.dumps(fig, cls=plotly.utils.PlotlyJSONEncoder),
              '-o', '{}/3d/{}.png'.format(save_dir, save_fname)])

should work too.

Bug confirmed. Thanks for reporting.

The logic here

orca/bin/graph.js

Lines 116 to 117 in be699d6

const itemName = getItemName(info)
const outPath = path.resolve(opts.outputDir, `${itemName}.${info.format}`)

doesn't seem quite right.

@ghtmtt

This comment has been minimized.

@etpinard

This comment has been minimized.

@ghtmtt

This comment has been minimized.

@etpinard

This comment has been minimized.

@ghtmtt

This comment has been minimized.

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

Successfully merging a pull request may close this issue.

4 participants