Graphing matplotlib with Python code in a R Markdown document
<p>Is it possible to use Python matplotlib code to draw graph in RStudio?</p>

<p>e.g. below Python matplotlib code:</p>

<pre><code>import numpy as np
import matplotlib.pyplot as plt

n = 256
X = np.linspace(-np.pi,np.pi,n,endpoint=True)
Y = np.sin(2*X)

plt.plot (X, Y+1, color='blue', alpha=1.00)
plt.plot (X, Y-1, color='blue', alpha=1.00)
plt.show()
</code></pre>

<p>Output graph will be:</p>

<p><a href="https://i.stack.imgur.com/HDlLk.png" rel="noreferrer"><img src="https://i.stack.imgur.com/HDlLk.png" alt="enter image description here"></a></p>

<p>Then I need to write a R Markdown to include these code and generate graph automatically after knitting the markdown.</p>