Reputation: 793
When you want to update plotting parameters in python using mpl.rcParams.update(params)
, it prints an array to the number of plots you have, say if you use hist for 12 parameters you get an array of 12 lines as
array([[<matplotlib.axes._subplots.AxesSubplot object at 0x1a1d27fc50>,
<matplotlib.axes._subplots.AxesSubplot object at 0x1a1d6292e8>,
<matplotlib.axes._subplots.AxesSubplot object at 0x1a1d63b6d8>],
[<matplotlib.axes._subplots.AxesSubplot object at 0x1a1e922c50>,
<matplotlib.axes._subplots.AxesSubplot object at 0x1a1e955208>,
<matplotlib.axes._subplots.AxesSubplot object at 0x1a1e97c780>],
[<matplotlib.axes._subplots.AxesSubplot object at 0x1a1e9a3cf8>,
<matplotlib.axes._subplots.AxesSubplot object at 0x1a1e9d52e8>,
<matplotlib.axes._subplots.AxesSubplot object at 0x1a1e9d5320>],
[<matplotlib.axes._subplots.AxesSubplot object at 0x1a1ea25da0>,
<matplotlib.axes._subplots.AxesSubplot object at 0x1a1ea55358>,
<matplotlib.axes._subplots.AxesSubplot object at 0x1a1ea7d8d0>]],
dtype=object)
How can I avoid/suppress this being printed in jupyter notebook.
Sample Code:
params = {'axes.titlesize':'60', 'xtick.labelsize':'24', 'ytick.labelsize':'24'}
mpl.rcParams.update(params);
data.hist(figsize=(50, 30), bins=10)
Upvotes: 5
Views: 3147
Reputation: 131
The easiest way to prevent spurious text above your graph is to end your code block with
None
Explanation: Jupyter captures the result from the last line of your code cell and typesets it "output." This is true even when your intended output is only your graph. Although Matplotlib functions are typically used for their "side effect" of modifying your graph, many of them also return arrays of handles, which Jupyter duly pastes into your "output" cell. Adding a single line of code that explicitly has no result (None
) causes Jupyter to instead paste that "no result" into the "output" cell.
Upvotes: 0
Reputation: 45
I find this is also useful:
data.hist(figsize=(50, 30), bins=10)[2]
Hope this will help you.
Upvotes: 0
Reputation: 22989
A better option would be to call plt.show()
at the end of the cell. This way your plots will be shown even in case you convert the notebook to a standalone python script
Upvotes: 7
Reputation: 1921
Try putting a semicolon at the end of the python command which produces this output. If that did not work, put a %%capture
at the beginning of the cell.
Upvotes: 3