matplotlib
Pycharm 4 new release claims support for matplotlib.
How do you setup and Pycharm to use matplotlib and what settings are needed in matplotlib?
This is not "automagic". In every environment, matplotlib is hyper sensitive to the "backend" which is chosen and to whether automatic refresh/display is chosen and to whether inline is used. I sort of forget how to do the latter.
I am on Mac OS X so the only rational backend to use is macosx. Not qt, tk, or any of the other backends.
How do you setup and Pycharm to use matplotlib and what settings are needed in matplotlib?
This is not "automagic". In every environment, matplotlib is hyper sensitive to the "backend" which is chosen and to whether automatic refresh/display is chosen and to whether inline is used. I sort of forget how to do the latter.
I am on Mac OS X so the only rational backend to use is macosx. Not qt, tk, or any of the other backends.
Please sign in to leave a comment.
Matplotlib supports two types of backends: interactive and non-interactive. You can work interactively only if interactive backend is chosen and interactive mode is turned on. In PyCharm, interactive mode is turned on automatically for all interactive backends. All other matplotlib settings are default and you can set them as from the basic Python console.
Yes, on Mac OS X your default matplotlib backend is 'macosx' backend.
You can read more about matplotlib backends and interactive mode here:
http://matplotlib.org/faq/usage_faq.html#what-is-a-backend
http://matplotlib.org/faq/usage_faq.html#what-is-interactive-mode
Some background:
C:\Anaconda3\python.exe -u C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0\helpers\pydev\pydevconsole.py 57155 57156
Python 3.4.1 |Anaconda 2.1.0 (64-bit)| (default, Sep 24 2014, 18:32:42) [MSC v.1600 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.
IPython 2.2.0 – An enhanced Interactive Python.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
PyDev console: using IPython 2.2.0
import sys; print('Python %s on %s' % (sys.version, sys.platform))
sys.path.extend(['C:\\fin\\options\\bin\\ScraperStocksAndOptions'])
Python 3.4.1 |Anaconda 2.1.0 (64-bit)| (default, Sep 24 2014, 18:32:42) [MSC v.1600 64 bit (AMD64)] on win32
In[2]: import matplotlib as mp
Traceback (most recent call last):
File "C:\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2883, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-2-f2799853cb60>", line 1, in <module>
import matplotlib as mp
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0\helpers\pydev\pydev_import_hook.py", line 29, in do_import
module = self._system_import(name, globals, locals, fromlist, level)
File "C:\Anaconda3\lib\site-packages\matplotlib\__init__.py", line 180, in <module>
from matplotlib.compat import subprocess
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0\helpers\pydev\pydev_import_hook.py", line 29, in do_import
module = self._system_import(name, globals, locals, fromlist, level)
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0\helpers\pydev\pydev_import_hook.py", line 29, in do_import
module = self._system_import(name, globals, locals, fromlist, level)
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0\helpers\pydev\pydev_import_hook.py", line 31, in do_import
self._modules_to_patch[name]() #call activate function
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0\helpers\pydev\pydev_ipython\matplotlibtools.py", line 73, in activate_matplotlib_inner
gui, backend = find_gui_and_backend()
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0\helpers\pydev\pydev_ipython\matplotlibtools.py", line 28, in find_gui_and_backend
backend = matplotlib.rcParams['backend']
AttributeError: 'module' object has no attribute 'rcParams'
In[3]: import matplotlib as mpl
Traceback (most recent call last):
File "C:\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2883, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-3-048e35a72bec>", line 1, in <module>
import matplotlib as mpl
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0\helpers\pydev\pydev_import_hook.py", line 29, in do_import
module = self._system_import(name, globals, locals, fromlist, level)
File "C:\Anaconda3\lib\site-packages\matplotlib\__init__.py", line 193, in <module>
from matplotlib.rcsetup import (defaultParams,
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0\helpers\pydev\pydev_import_hook.py", line 29, in do_import
module = self._system_import(name, globals, locals, fromlist, level)
File "C:\Anaconda3\lib\site-packages\matplotlib\rcsetup.py", line 24, in <module>
from matplotlib.colors import is_color_like
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0\helpers\pydev\pydev_import_hook.py", line 29, in do_import
module = self._system_import(name, globals, locals, fromlist, level)
File "C:\Anaconda3\lib\site-packages\matplotlib\colors.py", line 59, in <module>
import matplotlib.cbook as cbook
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0\helpers\pydev\pydev_import_hook.py", line 29, in do_import
module = self._system_import(name, globals, locals, fromlist, level)
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0\helpers\pydev\pydev_import_hook.py", line 31, in do_import
self._modules_to_patch[name]() #call activate function
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0\helpers\pydev\pydev_ipython\matplotlibtools.py", line 73, in activate_matplotlib_inner
gui, backend = find_gui_and_backend()
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0\helpers\pydev\pydev_ipython\matplotlibtools.py", line 28, in find_gui_and_backend
backend = matplotlib.rcParams['backend']
AttributeError: 'module' object has no attribute 'rcParams'
In[4]: import matplotlib
Traceback (most recent call last):
File "C:\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2883, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-4-82be63b7783c>", line 1, in <module>
import matplotlib
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0\helpers\pydev\pydev_import_hook.py", line 29, in do_import
module = self._system_import(name, globals, locals, fromlist, level)
File "C:\Anaconda3\lib\site-packages\matplotlib\__init__.py", line 193, in <module>
from matplotlib.rcsetup import (defaultParams,
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0\helpers\pydev\pydev_import_hook.py", line 29, in do_import
module = self._system_import(name, globals, locals, fromlist, level)
File "C:\Anaconda3\lib\site-packages\matplotlib\rcsetup.py", line 24, in <module>
from matplotlib.colors import is_color_like
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0\helpers\pydev\pydev_import_hook.py", line 29, in do_import
module = self._system_import(name, globals, locals, fromlist, level)
File "C:\Anaconda3\lib\site-packages\matplotlib\colors.py", line 59, in <module>
import matplotlib.cbook as cbook
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0\helpers\pydev\pydev_import_hook.py", line 29, in do_import
module = self._system_import(name, globals, locals, fromlist, level)
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0\helpers\pydev\pydev_import_hook.py", line 31, in do_import
self._modules_to_patch[name]() #call activate function
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0\helpers\pydev\pydev_ipython\matplotlibtools.py", line 73, in activate_matplotlib_inner
gui, backend = find_gui_and_backend()
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0\helpers\pydev\pydev_ipython\matplotlibtools.py", line 28, in find_gui_and_backend
backend = matplotlib.rcParams['backend']
AttributeError: 'module' object has no attribute 'rcParams'
In[5]: %matplotlib inline
Traceback (most recent call last):
File "C:\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2883, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-5-e27d371d6baa>", line 1, in <module>
get_ipython().magic('matplotlib inline')
File "C:\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2205, in magic
result = fn(*args,**kwargs)
File "<string>", line 2, in matplotlib
File "C:\Anaconda3\lib\site-packages\IPython\core\magic.py", line 193, in <lambda>
call = lambda f, *a, **k: f(*a, **k)
File "C:\Anaconda3\lib\site-packages\IPython\core\magics\pylab.py", line 80, in matplotlib
gui, backend = self.shell.enable_matplotlib(args.gui)
File "C:\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2931, in enable_matplotlib
gui, backend = pt.find_gui_and_backend(gui, self.pylab_gui_select)
File "C:\Anaconda3\lib\site-packages\IPython\core\pylabtools.py", line 252, in find_gui_and_backend
import matplotlib
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0\helpers\pydev\pydev_import_hook.py", line 29, in do_import
module = self._system_import(name, globals, locals, fromlist, level)
File "C:\Anaconda3\lib\site-packages\matplotlib\__init__.py", line 193, in <module>
from matplotlib.rcsetup import (defaultParams,
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0\helpers\pydev\pydev_import_hook.py", line 29, in do_import
module = self._system_import(name, globals, locals, fromlist, level)
File "C:\Anaconda3\lib\site-packages\matplotlib\rcsetup.py", line 24, in <module>
from matplotlib.colors import is_color_like
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0\helpers\pydev\pydev_import_hook.py", line 29, in do_import
module = self._system_import(name, globals, locals, fromlist, level)
File "C:\Anaconda3\lib\site-packages\matplotlib\colors.py", line 59, in <module>
import matplotlib.cbook as cbook
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0\helpers\pydev\pydev_import_hook.py", line 29, in do_import
module = self._system_import(name, globals, locals, fromlist, level)
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0\helpers\pydev\pydev_import_hook.py", line 31, in do_import
self._modules_to_patch[name]() #call activate function
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0\helpers\pydev\pydev_ipython\matplotlibtools.py", line 73, in activate_matplotlib_inner
gui, backend = find_gui_and_backend()
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0\helpers\pydev\pydev_ipython\matplotlibtools.py", line 28, in find_gui_and_backend
backend = matplotlib.rcParams['backend']
AttributeError: 'module' object has no attribute 'rcParams'
From: Elizaveta Shashkova - PyCharm <jetforum@jetbrains.com<mailto:jetforum@jetbrains.com>>
Date: Sunday, November 23, 2014 at 12:36 PM
To: Lewis Levin <lewis@neilson-levin.org<mailto:lewis@neilson-levin.org>>
Subject: Re: matplotlib
PyCharm<http://forum.jetbrains.com/forum/PyCharm> > matplotlib<http://forum.jetbrains.com/thread/PyCharm-2449> [ plot<http://forum.jetbrains.com/tag/PyCharm-plot> ] 3:35 pm<http://forum.jetbrains.com/thread/PyCharm-2449?message=PyCharm-2449-3> updated 3:35 pmElizaveta Shashkova<http://forum.jetbrains.com/user/Elizaveta%20Shashkova>
Yes, you are right. It is bug and it will be fixed soon. You can observe its status in our tracker: https://youtrack.j+{color:green}etb{color}+rains.com/issue/PY-14472
Lewis<http://forum.jetbrains.com/user/Lewis> @ Nov 20<http://forum.jetbrains.com/thread/PyCharm-2449>
Pycharm 4 new release claims support for matplotlib.
How do you setup and Pycharm to use matplotlib and what settings are needed in matplotlib?
This is not "automagic". In every environment, matplotlib is hyper sensitive to the "backend" which is chosen and to whether automatic refresh/display is chosen and to whether inline is used. I sort of forget how to do the latter.
I am on Mac OS X so the only rational backend to use is macosx. Not qt, tk, or any of the other backends.
JetBrains Forum | Build #176 (May/07/2014 4:41PM) | Feedback<http://confluence.jetbrains.net/display/JETF/Feedback>