Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

matplotlib.use('nbagg ') does not work in Python 3 #3436

Closed
stahlous opened this issue Aug 29, 2014 · 3 comments
Closed

matplotlib.use('nbagg ') does not work in Python 3 #3436

stahlous opened this issue Aug 29, 2014 · 3 comments
Milestone

Comments

@stahlous
Copy link
Contributor

This snippet:

import matplotlib
matplotlib.use('nbagg')
from matplotlib import pyplot as plt

Results in this traceback:

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-5-68fd53519d64> in <module>()
      1 import matplotlib
      2 matplotlib.use('nbagg')
----> 3 from matplotlib import pyplot as plt

C:\Miniconda\envs\py34\lib\site-packages\matplotlib\pyplot.py in <module>()
    106 
    107 from matplotlib.backends import pylab_setup
--> 108 _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
    109 
    110 

C:\Miniconda\envs\py34\lib\site-packages\matplotlib\backends\__init__.py in pylab_setup()
     30     # imports. 0 means only perform absolute imports.
     31     backend_mod = __import__(backend_name,
---> 32                              globals(),locals(),[backend_name],0)
     33 
     34     # Things we pull in from all backends

C:\Miniconda\envs\py34\lib\site-packages\matplotlib\backends\backend_nbagg.py in <module>()
     10 
     11 from matplotlib.figure import Figure
---> 12 from matplotlib.backends.backend_webagg_core import (FigureManagerWebAgg,
     13                                                      FigureCanvasWebAggCore,
     14                                                      NavigationToolbar2WebAgg)

C:\Miniconda\envs\py34\lib\site-packages\matplotlib\backends\backend_webagg_core.py in <module>()
    239 
    240 
--> 241 class NavigationToolbar2WebAgg(backend_bases.NavigationToolbar2):
    242     _jquery_icon_classes = {
    243         'home': 'ui-icon ui-icon-home',

C:\Miniconda\envs\py34\lib\site-packages\matplotlib\backends\backend_webagg_core.py in NavigationToolbar2WebAgg()
    255                  for text, tooltip_text, image_file, name_of_method
    256                  in (backend_bases.NavigationToolbar2.toolitems +
--> 257                      (('Download', 'Download plot', 'download', 'download'),))
    258                  if image_file in _jquery_icon_classes]
    259 

C:\Miniconda\envs\py34\lib\site-packages\matplotlib\backends\backend_webagg_core.py in <listcomp>(.0)
    256                  in (backend_bases.NavigationToolbar2.toolitems +
    257                      (('Download', 'Download plot', 'download', 'download'),))
--> 258                  if image_file in _jquery_icon_classes]
    259 
    260     def _init_toolbar(self):

NameError: name '_jquery_icon_classes' is not defined

And this, I believe, is why:

http://stackoverflow.com/questions/13905741/accessing-class-variables-from-a-list-comprehension-in-the-class-definition

Thanks!

@tacaswell tacaswell added this to the v1.4.x milestone Aug 29, 2014
@tacaswell
Copy link
Member

cc @pelson @mdboom

@astrojuanlu
Copy link

Confirmed on both 3.3 and 3.4, everything works as expected on Python 2.7.

I tried to solve the issue in a hacky way just replacing the variable names with their contents, but still everything I see is a blank plot.

@jenshnielsen
Copy link
Member

Yes, @stahlous is right. The simplest is probably to rewrite the list comprehensions as regular for loops.

@tacaswell tacaswell modified the milestones: v1.4.x, v1.4.1 Sep 3, 2014
tacaswell added a commit to tacaswell/matplotlib that referenced this issue Sep 3, 2014
Due to scoping fixes in py3k, list comprehensions over class level
attributes during class definition does not work (see
http://stackoverflow.com/questions/13905741/accessing-class-variables-from-a-list-comprehension-in-the-class-definition).

Superficially Fixes matplotlib#3436. There seem to be other issues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants