rstudio / rstudio/reticulate

Using reticulate with Jupyter

Open
#488 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
1.8k
Forks
349
Avg merge
5h 13m
Merged PRs (30d)
4

Description

Is it possible to use reticulate with Jupyter Lab and produce charts using the python packages matplotlib/seaborn?

When I tried to replicate this: https://datascienceplus.com/how-to-make-seaborn-pairplot-and-heatmap-in-r-write-python-in-r/ (code submitted is below)

I got this message, but no chart: AxesSubplot(0.125,0.11;0.62x0.77)

library(reticulate)
use_python("/opt/rh/rh-python36/root/usr/bin", required = TRUE)
use_virtualenv("/opt/pmaqa/pydev/py36-venv", required = TRUE)

#py_config()
#py_discover_config()
 
plt <- import('matplotlib.pyplot')
sns <- import('seaborn')
pd <- import('pandas')

#using R's inbuilt AirPassengers dataset
df <- datasets::AirPassengers

#converting Time-Series object into an R Dataframe
#Thx: https://stackoverflow.com/questions/5331901/transforming-a-time-series-into-a-data-frame-and-back
df1 <- data.frame(tapply(df, list(year = floor(time(df)), month = month.abb[cycle(df)]), c))
df1 <- df1[month.abb]

#building a heatmap using seaborn
#please note the function r_to_py() that converts R object into a python
sns$heatmap(r_to_py(df1), fmt="g", cmap ='viridis')

#display the plot
plt$show()

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the provided reticulate code in Jupyter Lab with the specified Python and virtualenv settings, focusing on the seaborn heatmap and matplotlib display calls. Done means determining why the plot is not rendered, establishing whether this combination is supported, and documenting the result or a reproducible fix.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter, jupyter-notebook, matplotlib, pandas, python, r
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.