1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
---
title: "matplotlib Example"
output:
html_document:
df_print: paged
pdf_document: default
---
```{r}
library(reticulate)
python <- "~/.virtualenvs/python-3.7.7-venv/bin/python"
if (file.exists(python))
use_python(python, required = TRUE)
```
```{python}
import matplotlib.pyplot as plt
import numpy as np
# Data for plotting
t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2 * np.pi * t)
fig, ax = plt.subplots()
ax.plot(t, s)
output = ax.set(xlabel='time (s)', ylabel='voltage (mV)',
title='About as simple as it gets, folks')
ax.grid()
plt.show()
```
|