Pycharm does not show plot(Pycharm不显示情节)
问题描述
Pycharm 不显示以下代码中的绘图:
Pycharm does not show plot from the following code:
import pandas as pd
import numpy as np
import matplotlib as plt
ts = pd.Series(np.random.randn(1000), index=pd.date_range('1/1/2000', periods=1000))
ts = ts.cumsum()
ts.plot()
发生的情况是一个窗口出现了不到一秒钟,然后又消失了.
What happens is that a window appears for less than a second, and then disappears again.
在绘图按预期显示的相同代码上使用 Pyzo IEP IDE(使用相同的解释器).
Using the Pyzo IEP IDE (using same interpreter) on the same code the plot shows as expected.
...所以问题一定出在 Pycharm 上的某些设置上.我尝试使用 python.exe 和 pythonw.exe 作为解释器,结果相同.
...So the problem must be with some setting on Pycharm. I've tried using both python.exe and pythonw.exe as interpreter both with same results.
这是我的系统信息:
C:pyzo2014apythonw.exe -u C:Program Files (x86)JetBrainsPyCharm Community Edition 3.4.1helperspydevpydevconsole.py 57315 57316
PyDev console: using IPython 2.1.0import sys; print('Python %s on %s' % (sys.version, sys.platform))
Python 3.4.1 |Continuum Analytics, Inc.| (default, May 19 2014, 13:02:30) [MSC v.1600 64 bit (AMD64)] on win32
sys.path.extend(['C:\Users\Rasmus\PycharmProjects\untitled2'])
In[3]: import IPython
print(IPython.sys_info())
{'commit_hash': '681fd77',
'commit_source': 'installation',
'default_encoding': 'UTF-8',
'ipython_path': 'C:\pyzo2014a\lib\site-packages\IPython',
'ipython_version': '2.1.0',
'os_name': 'nt',
'platform': 'Windows-8-6.2.9200',
'sys_executable': 'C:\pyzo2014a\pythonw.exe',
'sys_platform': 'win32',
'sys_version': '3.4.1 |Continuum Analytics, Inc.| (default, May 19 2014, '
'13:02:30) [MSC v.1600 64 bit (AMD64)]'}
推荐答案
随便用
import matplotlib.pyplot as plt
plt.show()
此命令告诉系统在 Pycharm 中绘制绘图.
This command tells the system to draw the plot in Pycharm.
示例:
plt.imshow(img.reshape((28, 28)))
plt.show()
这篇关于Pycharm不显示情节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Pycharm不显示情节
基础教程推荐
- 与常规 dict 相比,Python manager.dict() 非常慢 2022-01-01
- 使用生成器和迭代器时 Python 多循环失败 2022-01-01
- Discord.py 缺少必需的参数 2022-01-01
- 尝试制作WhatsApp机器人 2022-01-01
- 用 Python 编写 Fortran 无格式文件 2022-01-01
- 在 Celery 工作人员中捕获 Heroku SIGTERM 以优雅地关 2022-01-01
- pyserial - 可以从线程 a 写入串行端口,是否阻塞从线程 b 读取? 2022-01-01
- 由Python将MP3转换为MIDI(类型错误:无法加载插件:mtg-Melodia:Melodia) 2022-01-01
- numpy float:比算术运算中内置的慢 10 倍? 2022-01-01
- 将 x 轴刻度更改为自定义字符串 2022-01-01
