knitr:python引擎输出不在.md或.html中

knitr:python引擎输出不在.md或.html中,python,matplotlib,knitr,Python,Matplotlib,Knitr,处理.Rmd文件时,不会显示matplotlib img。是否有一个区块选项,或者需要一个不同的matplotlib方法 --- title: "Viz Examples" output: html_document: keep_md: true --- ```{r testplot, engine="python"} from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import num

处理.Rmd文件时,不会显示matplotlib img。是否有一个区块选项,或者需要一个不同的matplotlib方法

---
title: "Viz Examples"
output:
  html_document:
    keep_md: true
---

```{r testplot, engine="python"}
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
for c, z in zip(['r', 'g', 'b', 'y'], [30, 20, 10, 0]):
xs = np.arange(20)
ys = np.random.rand(20)

# You can provide either a single color or an array. To demonstrate this,
# the first bar of each set will be colored cyan.
cs = [c] * len(xs)
cs[0] = 'c'
ax.bar(xs, ys, zs=z, zdir='y', color=cs, alpha=0.8)

ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')

plt.print()

```
而不是
plt.print()
plt.show()
使用

plt.savefig("somefilename.ext")
如果
ext
png
jpg
或其他支持的输出格式,以及任何其他
savefig
选项,如
transparent
,则使用标准knitr机制使用图形

```{r showfig,include=TRUE,echo=FALSE,results='asis'} 猫(“!(./threedee.png)”)


```

很抱歉,knitr不支持Python图形。仅支持文本输出。