In previous versions of rpy2 my proposed solution did not work. However with rpy2-2.4.3
the following now works as expected:
%load_ext rpy2.ipython
%R require(ggplot2)
%Rdevice svg
After setting up R, the plotting works as expected and the shown plot will be in svg format.
Create data as a pandas DataFrame in python:
import pandas as pd
data = pd.DataFrame({"x":[1,2,3], "y": [3,2,1]})
And finally do the plotting:
%%R -i data
plot = ggplot(data) + geom_line(aes(x=x, y=y))
print(plot)