Xaringan: Figure generated by python is not displayed

Created on 24 Dec 2019  ·  7Comments  ·  Source: yihui/xaringan

I'm on macOS Mojave with R 3.6.2 and xaringan 0.13. I was trying to insert a figure generated by python. The chunk code can run without an issue, and the figure file is indeed generated. But the figure is not inserted in the xaringan slides. The R-generated figure is fine.

Screenshot 2019-12-24 at 7 27 24 AM

However, the issue doesn't appear for other Rmarkdown output formats (Rmarkdown notebook, ioslides, etc).

Screenshot 2019-12-24 at 7 29 20 AM


By filing an issue to this repo, I promise that

  • [x] I have fully read the issue guide at https://yihui.org/issue/.
  • [x] I have provided the necessary information about my issue.

    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.

    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('xaringan'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('yihui/xaringan').

    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.

  • [x] I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

All 7 comments

Please include the code for the slides in your screenshot. You can copy the source from the .Rmd file and put it between a pair of 4-backticks in a comment to this issue. Or copy the block below into a comment, and then replace the < ... > with your slide source.

```` <paste your slide source here> ````

It's incredibly easy to copy and paste code from text; much harder to copy and paste code from images.

Also, it would probably be helpful (if not necessary) for you to include the output of xfun::session_info('xaringan') as requested in the issue guidelines.

Here's the Rmd code that gives rise to the issue:

````

title: "Presentation Ninja"
subtitle: "⚔
with xaringan"
author: "Yihui Xie"
institute: "RStudio, Inc."
date: "2016/12/12 (updated: r Sys.Date())"
output:
xaringan::moon_reader:
lib_dir: libs
nature:
highlightStyle: github
highlightLines: true

countIncrementalSlides: false

```{r setup, include=FALSE}
library(reticulate)

```{python}
import matplotlib.pyplot as plt
import numpy as np 
t = np.arange(0.0, 2.0, 0.01)
s = np.sin(t)
plt.plot(t, s)
plt.show()

````

The output xfun::session_info('xaringan') is as follows:

R version 3.6.2 (2019-12-12)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.6, RStudio 1.2.5019

Locale: en_US.UTF-8 / en_US.UTF-8 / en_US.UTF-8 / C / en_US.UTF-8 / en_US.UTF-8

Package version:
  base64enc_0.1.3 BH_1.72.0.2     digest_0.6.23   evaluate_0.14  
  glue_1.3.1      graphics_3.6.2  grDevices_3.6.2 highr_0.8      
  htmltools_0.4.0 httpuv_1.5.2    jsonlite_1.6    knitr_1.26     
  later_1.0.0     magrittr_1.5    markdown_1.1    methods_3.6.2  
  mime_0.8        promises_1.1.0  R6_2.4.1        Rcpp_1.0.3     
  rlang_0.4.2     rmarkdown_2.0   servr_0.15      stats_3.6.2    
  stringi_1.4.3   stringr_1.4.0   tinytex_0.18    tools_3.6.2    
  utils_3.6.2     xaringan_0.13   xfun_0.11       yaml_2.2.0   

I can reproduce with CRAN version of reticulate, and

I think this could be related with https://github.com/rstudio/reticulate/issues/645 and other linked issues. mainly with https://github.com/rstudio/reticulate/issues/669

Currently reticulate knitr engine provide absolute path to image, that does not work correctly in a webpage. In your example, if you replace image link by a relative one, it works as expected

This is currently being discussed and fixed on reticulate repos.

Hi,

Can you check with last reticulate dev version ?

remotes::install_github("rstudio/reticulate")

rstudio/reticulate#671 should have fixed this.

Yes, it fixes the issue.

Nice ! Glad it works now !

@yihui, may I ping you here ?
I think you can close this issue now and also add the labels and milestones you usually put. I currently can't do this myself in this repo ☺️

@cderv Sure. Please always feel free to ping me for such simple tasks! I have also given you write access to this repo. Thanks a lot!

Was this page helpful?
0 / 5 - 0 ratings