0

I want a seaborn style pairgrid for some data that I am working with in R. I used something on the lines of https://towardsdatascience.com/python-seaborn-plots-in-r-using-reticulate-fb59cebf61a7

If I use pairplot I get one nice chart. But if I switch to pairgrid and add elements using map_offdiag then I get each child plot in its own window and an empty grid.

See code below for details. Below snippet with pairplot works. This is on lines of link copied above

library(reticulate)
data(iris)
sns <- import('seaborn')
mplt <- import('matplotlib', convert = TRUE)
plt <- import('matplotlib.pyplot')
sns$pairplot(r_to_py(iris[,1:4]),diag_kind = "hist", kind = "reg")
plt$show()

But the one below with pair grid shows each child plot in a separate window

library(reticulate)
data(iris)
sns <- import('seaborn')
mplt <- import('matplotlib', convert = TRUE)
plt <- import('matplotlib.pyplot')
g <- sns$PairGrid(r_to_py(iris[,1:4]))
g <- g$map_offdiag(sns$jointplot,kind = "kde")
plt$show()

I see an empty grid plot and then each child plot in its own window

NoNameMLer
  • 21
  • 5
  • I have no idea how reticulate works, but this sounds a lot like every line is send to a new python process or similar. When you do `a <- plt$plot([1,2,3])` newline `b <- plt$plot([4,5,6])`, do you also get two plot windows? Does `plt$ioff()` have any effect? – ImportanceOfBeingErnest Aug 09 '19 at 21:26
  • had left out a couple of lines of code above. anyway to answer your questions i dont see any plots till i run the plt$show() in either case . – NoNameMLer Aug 19 '19 at 20:09
  • My question was: When you do `a <- plt$plot([1,2,3])` newline `b <- plt$plot([4,5,6])`, do you get one or two windows? – ImportanceOfBeingErnest Aug 19 '19 at 20:24
  • `a<-plt$plot(1,2,3)` newline `b<-plt$plot(4,5,6)` newline `plt$show() ` shows one plot. And doesnt show anything till i execute the plt$show() – NoNameMLer Aug 21 '19 at 02:07
  • Wow, this means the issue is much deeper... I fear I cannot help more at this point due to the lack of being able to test anything (I don't have R available here). – ImportanceOfBeingErnest Aug 21 '19 at 09:04
  • Yeah i think something is getting lost in the translation between reticulate and how it recognizes the seaborn object returned by python. Might have to post this on rstudio forums (since they made reticulate) – NoNameMLer Aug 21 '19 at 13:28

0 Answers0