I am using Python which calls a plot from R. Python issues the Rscript command. Everything works, except that the plot instantly disappears.
I tried several things on the R side:
par(ask=TRUE)
Sys.sleep(5)
par
does not work this way; it will just ignore it.
With sleep
the problem is that R will hang the python script for 5 seconds while sleeping, but also that sometimes I want to be able to close the plot immediately: when I do python just keeps waiting until the 5 seconds are over.
Could it be Python related, or is there a solution in R?
Minimum Working Example:
R:
foo.R
plot(1:10)
Sys.sleep(5)
Python:
foo.py
import os
os.system("Rscript foo.R")