当我处理 .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()
or plt.show()
use
plt.savefig("somefilename.ext")
with ext
being png
or jpg
或其他支持的输出格式,以及任何其他savefig
选项,例如transparent
,然后使用使用标准针织机构的图形。
```{r showfig,include=TRUE,echo=FALSE, results='asis'}
猫(“!(./thirdee.png)”)
```
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)