如何在 Jupyer 笔记本中绘图后抑制文本输出

Soy*_*yol 5 python matplotlib jupyter-notebook

当你想使用 python 更新绘图参数时mpl.rcParams.update(params),它会打印一个数组来表示你拥有的绘图数量,比如说,如果你使用 hist 作为 12 个参数,你会得到一个 12 行的数组,如下所示

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)
Run Code Online (Sandbox Code Playgroud)

我怎样才能避免/禁止在 jupyter 笔记本中打印它。

示例代码:

params = {'axes.titlesize':'60', 'xtick.labelsize':'24', 'ytick.labelsize':'24'} 
mpl.rcParams.update(params);
data.hist(figsize=(50, 30), bins=10)
Run Code Online (Sandbox Code Playgroud)

Bla*_*ear 7

plt.show()更好的选择是在单元格末尾调用。这样,即使您将笔记本转换为独立的 python 脚本,您的绘图也会显示出来