Question

See my pic, why 2 plots come in reversed order in cell magic?

enter image description here

Update

It was fixed last time I checked. Still not sure it was the problem of rpy2 or ipython notebook.

Was it helpful?

Solution

Check the source code of %rmagic (rmagic.py), especially the r() function at line 403. Within it, especially line 601~623.

When R draws plots, the plots are named by Rplots1.png Rplots2.png ... and so one. Then when IPython displays the pngs, the second one gets plotted after the 1st one and end up on top of the 1st plot, and so on. Give you an impression that the sequence is reversed.

Therefore if you want to reverse the sequence, such that the older ones are on top of the newer ones, change line 618 to for image in images[::-1]:

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top