Randy Treit
Randy Treit

Reputation: 21

Text not displaying in ggplot2 plot using rpy2 magic

When I generate any ggplot2 plot using R magic in Jupyter Notebook, all text in the plot is rendered as little empty boxes.

My environment is running the notebook via Jupyter Hub on Ubuntu server. R magic is working great in general, with the goal of re-using some existing R code I have to output a Word Cloud via wordcloud package. However, when I generate any plot using ggplot2 any text is missing and all I see are small empty boxes.

library(ggplot2)
ggplot(mtcars, aes(x = drat, y = mpg)) +
    geom_point()

see image here

The plot should show text on the axis labels but no text is displayed, just empty boxes.

Generating the same plot when running R from ssh terminal and saving it to disk (it's on a headless server) looks fine. Generating plot via pandas data frame in a different cell looks fine. So it seems related to rpy2? I'm stumped.

[EDIT]: in fact I see the same behavior using R kernel on this server, so it seems to not be specific to rpy2 / R magic.

Upvotes: 2

Views: 182

Answers (1)

Randy Treit
Randy Treit

Reputation: 21

I was able to solve this by installing all the needed packages via R install.packages() rather than conda. Next time I think I will avoid using conda for R packages altogether; this isn't the first time it has caused issues.

Upvotes: 0

Related Questions