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.
Using the Pyzo IEP IDE (using same interpreter) on the same code the plot shows as expected.
...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.
This is my sys_info:
C:\pyzo2014a\pythonw.exe -u C:\Program Files (x86)\JetBrains\PyCharm Community Edition 3.4.1\helpers\pydev\pydevconsole.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)]'}
None of the above worked for me but the following did:
settings > Tools > Python Scientific
.I received the error
No PyQt5 module found
. Went ahead with the installation ofPyQt5
using :I realize this is old but I figured I'd clear up a misconception for other travelers. Setting
plt.pyplot.isinteractive()
toFalse
means that the plot will on be drawn on specific commands to draw (i.e.plt.pyplot.show()
). Settingplt.pyplot.isinteractive()
toTrue
means that everypyplot
(plt
) command will trigger a draw command (i.e.plt.pyplot.show()
). So what you were more than likely looking for isplt.pyplot.show()
at the end of your program to display the graph.As a side note you can shorten these statements a bit by using the following import command
import matplotlib.pyplot as plt
rather thanmatplotlib as plt
.I was able to get a combination of some of the other suggestions here working for me, but only while toggling the
plt.interactive(False)
toTrue
and back again.This will flash up the my plots. Then setting to
False
allowed for viewing.As noted also my program would not exit until all the windows were closed. Here are some details on my current run environment:
In Pycharm , at times the Matplotlib.plot won't show up.
So after calling
plt.show()
check in the right side toolbar for SciView. Inside SciView every generated plots will be stored.Soon after calling
call
You will get the matplotlib popup with the image.
This is a blocking way. Further script will not run until the pop is closed.
I tried different solutions but what finally worked for me was
plt.show(block=True)
. You need to add this command after themyDataFrame.plot()
command for this to take effect. If you have multiple plot just add the command at the end of your code. It will allow you to see every data you are plotting.