How To use GGPlot in Python

conda install rpy2
from rpy2.robjects.packages import importr utils = importr('utils') 
utils.install_packages("ggplot2")
mirror_number=12 #small positive integer <40 preferable utils.chooseCRANmirror(ind=mirror_number)
import rpy2.robjects as robjects robjects.r("library(ggplot2)")
from rpy2.robjects importpandas2ri pandas2ri.activate()
import rpy2.robjects.lib.ggplot2 as ggplot2
pp=ggplot2.ggplot(heart)+ggplot2.geom_point(ggplot2.aes_string(x="age",y="chol"))
from rpy2.ipython.ggplot import image_png 
img=image_png(pp)
img

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store