Reputation: 4307
This is how I am plotting
from matplotlib import pyplot
pyplot.figure();
pyplot.scatter(x=data[feat], y=data[target]);
pyplot.xlabel(feat);
pyplot.ylabel(target);
pyplot.show();
And I get output like
Figure size 432x288 with 0 Axes>
<matplotlib.collections.PathCollection at 0x7fd80c2fbf50>
Text(0.5,0,'Age1')
Text(0,0.5,'Target')
How can I suppress this output? The semicolon did not work. I am running this in a jupyter notebook.
Upvotes: 3
Views: 7311
Reputation: 542
The issue is documented here https://github.com/ipython/ipython/issues/10794
You/Something has probably set your interactive shell to
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
all
to last_expr
The consequence of this is that a cell will display the output of the last expression rather than every expression. You could still of course print
something and that would work normally.
;
to the last expressionfor example, you could add
pass;
at the end of the cells, which would suppress output
Make sure you're not using that variable elsewhere
Upvotes: 6
Reputation: 51335
Assign your calls to plot to a random variable name, and there won't be any output. By convention, this could be _
, but you can use whatever variable name you want:
from matplotlib import pyplot
_ = pyplot.figure()
_ = pyplot.scatter(x=data[feat], y=data[target])
_ = pyplot.xlabel('feat')
_ = pyplot.ylabel('target')
pyplot.show()
Note that unlike MATLAB
, semi-colons don't suppress the output in python
, they are simply used to delimit different statements, and are generally unnecessary if you are using newlines as delimiters (which is the standard way to do it)
Upvotes: 4