library(reticulate)

python <- "~/.virtualenvs/python-3.7.7-venv/bin/python"
if (file.exists(python))
  use_python(python, required = TRUE)
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()


rstudio/reticulate documentation built on Oct. 29, 2024, 8:07 a.m.