25

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

Community
  • 1
  • 1
aozkan
  • 799
  • 2
  • 9
  • 17

3 Answers3

47

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

plt.hist(...);

weiz
  • 2,609
  • 1
  • 10
  • 5
  • 8
    Brilliant solution! The reason this works is because the notebook shows the return value of the last command. By adding `;` the last command is "nothing" so there is no return value to show. – kynan Nov 06 '15 at 13:26
32

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

_ = plt.hist(...)
NPE
  • 464,258
  • 100
  • 912
  • 987
  • 14
    alternately, you can suppress output by putting a semicolon at the end of the last line: `plot(foo);` – minrk Jan 24 '13 at 19:43
2

You can also add plt.show():

plt.hist(OIR['Range'], bins, named=True, histtype='bar')
plt.show() 
Suraj Rao
  • 28,850
  • 10
  • 94
  • 99
user3114859
  • 289
  • 2
  • 3