Does Rmarkdown allow knitting of matplotlib plots? If so, will you help me troubleshoot?

153
June 30, 2019, at 06:10 AM

I am comfortable in R and just decided to study python. I have been making an Rmarkdown notebook to take notes on my python studies. Within RStudio I have been able to knit the document containing my python code to html with no problem until I started plotting data using matplotlib. The curious part is that the plots are generated correctly within the code chunks. However after knitting, it spits out an error every time at 80%.

Here is my sample code:

---
title: "Python Plot"
output: html_document
---
```{r setup, include=FALSE}
library(knitr)
knitr::opts_chunk$set(echo = TRUE)
library(reticulate) #Allows for Python to be run in chunks
```

```{python, eval=F}
trees = np.array(r.trees) #Imported an internal R dataset. It got rid of headers and first row. Don't know how to deal with that right now.
type(trees)
np.shape(trees)
print(trees[1:6,:])
import matplotlib.pyplot as plt
plt.plot(trees[:,0], trees[:,1])
plt.show()
plt.clf() #Reset plot surface
```

Again, this plot comes out just fine when processing within the chunk, but does not knit. The error message says,

"This application failed to start because it could not find or load the Qt platform plugin "windows" in "",

Reinstalling the application may fix this problem."

I have uninstalled and reinstalled both Rstudio and Python and continue to have the same result. I find it odd that it works within the chunk but not to knit to html. All my other python code knits just fine.

I have python 3.7.3 (default, Mar 27 2019, 17:13:21) [MSC v.1915 64 bit (AMD64)] and Rstudio Version 1.2.1335.

I've done web searches and stack overflow searches to no avail. I do not have another computer to test the issue out. If this is just on my machine then I aplogize and will delete the question.

Thanks,

Scott

Rent Charter Buses Company
READ ALSO
Is it possible to link README file in javadocs?

Is it possible to link README file in javadocs?

I currently use my README file as a set of instructions, and would like to refer to it in javadocsI know it is possible to link directories in javadoc, for example to link an image I can do

149
Run Flexible Number of Progressbar like Whatsapp Status

Run Flexible Number of Progressbar like Whatsapp Status

In my app there is a status activity to show all the images uploaded as statusThe statusbar (horizontal recyclerview) is in home activity and on clicking a specific cell in the recyclerview the control goes to Status Activity

140
Url Rewrite :Deploying Node.js-angular app to iis

Url Rewrite :Deploying Node.js-angular app to iis

I have deployed nodejs and angular app in iisnode

158
“loose”: true is not fixing Support for the experimental syntax 'classProperties' isn't currently enabled

“loose”: true is not fixing Support for the experimental syntax 'classProperties' isn't currently enabled

Support for the experimental syntax 'classProperties' isn't currently enabled

176