【问题标题】:how to show figure from linux terminal in python? [closed]如何在 python 中从 linux 终端显示图形? [关闭]
【发布时间】:2014-10-13 08:01:56
【问题描述】:

我在 python 2.7 中使用 matplotlib 来显示数字。它在 spyder 环境中运行良好,但从终端尝试时没有任何反应。

使用代码:

py.plot(x)    
py.show()

小费在哪里?


感谢 darth kotic,我测试了以下内容,但没有任何改变。

import numpy as np
import scipy as sp 
import matplotlib as mpl  
import matplotlib.pyplot as plt  
from pylab import *              

ion()                           
v=range(10)
plt.plot(v)

【问题讨论】:

    标签: python linux matplotlib terminal


    【解决方案1】:

    spider 自动导入几个模块 只需在控制台中输入科学,您就会看到:

    This is a standard Python interpreter with preloaded tools for scientific 
    computing and visualization. It tries to import the following modules:
    
    >>> import numpy as np  # NumPy (multidimensional arrays, linear algebra, ...)
    >>> import scipy as sp  # SciPy (signal and image processing library)
    >>> import matplotlib as mpl         # Matplotlib (2D/3D plotting library)
    >>> import matplotlib.pyplot as plt  # Matplotlib's pyplot: MATLAB-like syntax
    >>> from pylab import *              # Matplotlib's pylab interface
    >>> ion()                            # Turned on Matplotlib's interactive mode
    

    【讨论】:

    • 要点是:如果你想在linux终端使用这个,你必须先导入这个模块。
    • 谢谢!是的,我已经完成了所有的进口,但它仍然是一样的
    • 好的。我测试了它。当解释器退出时,带有绘图的窗口会消失,因此您需要在文件末尾添加 raw_input("Press enter to continue") 之类的内容,然后它将起作用。
    猜你喜欢
    • 1970-01-01
    • 2011-11-30
    • 2023-03-27
    • 1970-01-01
    • 2018-10-29
    • 1970-01-01
    • 1970-01-01
    • 2012-03-11
    • 2013-09-04
    相关资源
    最近更新 更多