Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppress output of object when plotting in ipython

Tags:

Is it possible to suppress the array output when plotting a histogram in ipython?:

For example:

plt.hist(OIR['Range'], bins, named=True, histtype='bar') 

outputs/prints the array information before displaying the graph.

ipython histogram

like image 902
aozkan Avatar asked Jan 24 '13 16:01

aozkan


People also ask

How do I turn off output in Jupyter?

Put a ';' at the end of a line to suppress the printing of output.

What does %% capture do?

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.

How do I stop Matplotlib from plotting?

We can simply save plots generated from Matplotlib using savefig() and imsave() methods. If we are in interactive mode, the plot might get displayed. To avoid the display of plot we use close() and ioff() methods.


2 Answers

just put ; after the code.
It works only in ipython-notebook.

plt.hist(...);

like image 126
weiz Avatar answered Oct 16 '22 10:10

weiz


Assign the return value to a variable (which I call _ to indicate it's unused):

_ = plt.hist(...) 
like image 31
NPE Avatar answered Oct 16 '22 08:10

NPE