for example, when I plot something and add titles and so forth, I get a list of lines showing output like the ones below before the actual plot shows, sometimes very long lists.
<matplotlib.figure.Figure at 0x244deb8dd68>
<matplotlib.axes._subplots.AxesSubplot at 0x244deb99358>
<matplotlib.text.Text at 0x244defc9240>
Is there a way to hide these when plotting?
Press 'control-shift-p', that opens the command palette. Then type 'clear cell output'. That will let you select the command to clear the output.
To hide lines in Matplotlib, we can use line. remove() method.
What does %% capture do in Jupyter? Capturing Output With %%capture IPython has a cell magic, %%capture , which captures the stdout/stderr of a cell. With this magic you can discard these streams or store them in a variable. By default, %%capture discards these streams. This is a simple way to suppress unwanted output.
It just means that any graph which we are creating as a part of our code will appear in the same notebook and not in separate window which would happen if we have not used this magic statement.
Add ";" after your matplotlib commands. This seems to suppress output.
plt.plot(np.arange(0,5))
plt.title('Some Title')
Yields:
<matplotlib.text.Text at 0x119188490>
and an image.
Yet:
plt.plot(np.arange(0,5))
plt.title('Some Title');
just yields the image.
This was done using python 2 in a v4 Jupyter notebook.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With