禁用matplotlib pyplot的输出 [英] Disable the output of matplotlib pyplot
问题描述
我有一个形状为(1000,2000)的数组A
.我使用
I have an array A
of shape (1000, 2000). I use matplotlib.pyplot to plot the array, which means 1000 curves, using
import matplotlib.pyplot as plt
plt(A)
这个数字很好,但是有一千行:
The figure is fine but there are a thousand lines of:
<matplotlib.lines.Line2D at 0xXXXXXXXX>
我可以禁用此输出吗?
推荐答案
此输出是plt
函数返回的内容(我在这里假定您要编写plt.plot(A)
).要取消显示此输出,请为返回对象分配一个名称:
This output is what the plt
function is returning (I presume here you meant to write plt.plot(A)
). To suppress this output assign the return object a name:
_ = plt.plot(A)
_
通常用于指示一个临时对象,以后将不再使用它.请注意,您看到的此输出将仅显示在解释器中,而不是从解释器外部运行脚本时显示.
_
is often used to indicate a temporary object which is not going to be used later on. Note that this output you are seeing will only appear in the interpreter, and not when you run the script from outside the interpreter.
这篇关于禁用matplotlib pyplot的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!