Suppress output of object when plotting in ipython

2020-05-23 07:12发布

问题:

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.

回答1:

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

_ = plt.hist(...)


回答2:

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

plt.hist(...);



回答3:

You can also add plt.show():

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