Search code examples
pythonx11graphingrpy2

Plots made with rpy sent to X11 suddenly close?


I'm using RPy2 to make some plots. The plot shows up but the X11 window immediately disappears.

All I'm typing is the following, where CCFS is a data matrix

 import rpy2.robjects as robjects
 r = robjects.r

 pca = r.princomp(CCFS)
 r.plot(pca,main="Eigenvalues")
 r.biplot(pca,main="biplot")
 r['dev.off']() #*EDIT* the problem persists even if I remove this line.

Am I failing to include something? I know that there is something to plot because princomp returns a ListVector that isn't null.


Solution

  • Add

    input()         # for Python3
    # raw_input()   # for Python2
    

    to the end of the script to prevent the program from ending until the user presses Enter.