Graphing matplotlib with Python code in a R Markdown document
Is it possible to use Python matplotlib code to draw graph in RStudio? e.g. below Python matplotlib 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() Output graph will be: Then I need to write a R Markdown to include these code and generate graph automatically after knitting the markdown. One possible solution is save the plot as a image, then load the file to markdown. ### Call python code sample ```{r,engine='python'}