我有两个目录:
blogdown
文件所在的位置,以及python-snipplet
李>为了执行使用数据文件的python-snipplet
,我更改了blogdownPySnipplet.rmd
文件中的目录。python
-代码(以plt.show()
结尾)执行得很好,但不是在我的blogdownPySnipplet.rmd
派生的blogdownPySnipplet.html
(在网站上)中显示绘图,而是在snipplet
所在的目录中创建一个目录,并创建一个figure.html
文件
执行.rmd
之前的类似目录层次结构:
-- blogdownDirectory -- blogdownPySnipplet.rmd -- otherDirectory -- python-snipplet -- dataFile1 -- dataFile2 ...
执行.rmd
后的类似目录层次结构:
-- blogdownDirectory -- blogdownPySnipplet.rmd -- otherDirectory -- python-sniplet -- dataFile1 -- dataFile2 ... -- blogdownPySnipplet -- figure.html -- figureFile.html
如何让plt.show
直接在网站上显示我的情节
```{r python}
knitr::opts_knit$set(root.dir = "C:/Users/shudras/Project2/experimental_data")
# to be able to load the data files into the pySnipplet
{python, python.reticulate = FALSE,
code = readLines("C:/Users/shudras/Project2/experimental_data/pySnipplet.py")}
# executing the code and plotting the data files
# python code extract
import numpy as np
from mpl_toolkits.axes_grid1 import make_axes_locatable
# matplotlib import needs some extra attention
import matplotlib.pyplot as plt
import os
os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = 'C:\ProgramData\Anaconda3\Library\plugins\platforms'
files = os.listdir() # import data file names
# code where doing calculations and making subfigures...
plt.show()
目前没有回答
相关问题 更多 >
编程相关推荐