为什么 Rstudio 中的 运行 Python 代码会出现冗余文本?

Why running Python code in Rstudio gives redundant text?

我是 运行 R-notebook 中的以下 python 代码:

```{r}
library(reticulate)
```

```{python}
import matplotlib
import numpy as np
import matplotlib.pyplot as plt

import matplotlib.pyplot as plt
import numpy as np

t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2*np.pi*t)
plt.plot(t, s)

plt.xlabel('time (s)')
plt.ylabel('voltage (mV)')
plt.title('About as simple as it gets, folks')
plt.grid(True)
plt.savefig("test.png")
plt.show()

```

很奇怪,除了剧情,还有文字结果。

能否请您解释一下出现这种现象的原因?

这是@Onyambu 的评论。我 post 在这里将我的问题从未回答列表中删除。

Well this is a behaviour of matplotlib. Even in python itself, unless you save the output to a given variable, there will be text printed on your console