How to hide additional information given be matplotlib in html output in R-markdown?

Viewed 104

I wrote a simple matplotlib plotting function in r-markdown

```{python}
Sw = np.arange(0.2, 0.9, 0.01)
Fw= np.arange(0.2, 0.9, 0.01)
fig = plt.figure(figsize=(20, 10))
plt.plot(Sw, Fw, 'b-', )
plt.xlim([0,1])
plt.ylim([0,1])
plt.show()
```

in the html output this is showing as

Sw = np.arange(0.2, 0.9, 0.01)
Fw= np.arange(0.2, 0.9, 0.01)
fig = plt.figure(figsize=(20, 10))
plt.plot(Sw, Fw, 'b-', )
[<matplotlib.lines.Line2D object at 0x0000000064D82910>]
plt.xlim([0,1])
(0.0, 1.0)
plt.ylim([0,1])
(0.0, 1.0)
plt.show()

plots are showing fine. but i want to remove these extra information like (0.0, 1.0) after plt.xlim() and plt.ylim() and [<matplotlib.lines.Line2D object at 0x0000000064D82910>] after plt.plot().

Any idea how to remove these?

1 Answers

Just add results = "hide" in python script indicator.

```{python, results = "hide"}
Sw = np.arange(0.2, 0.9, 0.01)
Fw= np.arange(0.2, 0.9, 0.01)
fig = plt.figure(figsize=(20, 10))
plt.plot(Sw, Fw, 'b-', )
plt.xlim([0,1])
plt.ylim([0,1])
plt.show()
```

This just disables text output, It will still show plots.

You can learn more about this here

Related