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

Problem saving plots from plot.___ #231

Closed
diegozea opened this issue Feb 28, 2018 · 5 comments
Closed

Problem saving plots from plot.___ #231

diegozea opened this issue Feb 28, 2018 · 5 comments

Comments

@diegozea
Copy link
Contributor

Saving figures from R plot(... works fine. However, I get empty files when I try to use plot.euler from the eulerr package.

using RCall

R"""
library(eulerr)
fit <- euler(c("A" = 25, "B" = 5, "C" = 5,
               "A&B" = 5, "A&C" = 5, "B&C" = 3,
               "A&B&C" = 3))
svg("example.svg")

plot(fit)

dev.off()
"""

However, I tried this and It worked fine:

using RCall

R"""
library(eulerr)
fit <- euler(c("A" = 25, "B" = 5, "C" = 5,
               "A&B" = 5, "A&C" = 5, "B&C" = 3,
               "A&B&C" = 3))

svg("example.svg")
"""

rprint(R"plot(fit)")

R"dev.off()"
@diegozea
Copy link
Contributor Author

Trying that inside of a function in IJulia is a little more tricky. dev.off() gives an error that I solved using:

R"""
if(names(dev.cur()) == c("svg")){dev.off()}
"""

@randy3k
Copy link
Member

randy3k commented Feb 28, 2018

Due to the implementation of plot.euler. You will need to print the plot.

using RCall

R"""
library(eulerr)
fit <- euler(c("A" = 25, "B" = 5, "C" = 5,
               "A&B" = 5, "A&C" = 5, "B&C" = 3,
               "A&B&C" = 3))
svg("example.svg")
print(plot(fit))
dev.off()
"""

Did you put dev.off() in a different cell in IJulia? In IJulia/juptyer, Each cell is designated with a device to capture plots so the svg device should be opened and closed in the same cell.

@diegozea
Copy link
Contributor Author

The plot command and the dev.off are used in a function definition, then the function is called in the other cells. That function with the R macro in its body works fine in a script but It throws the error in IJulia.

@randy3k
Copy link
Member

randy3k commented Feb 28, 2018

is it possible for you to share your notebook or make a minimal example out of it?

@palday
Copy link
Collaborator

palday commented Jul 17, 2024

closing as stale

@palday palday closed this as not planned Won't fix, can't repro, duplicate, stale Jul 17, 2024
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

3 participants