Skip to content

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

Closed

Description

@stahlous

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!

Activity

  1. added this to the v1.4.x milestone on Aug 29, 2014
  2. tacaswell commented on Aug 29, 2014

    @tacaswell
    Member
  3. astrojuanlu commented on Aug 31, 2014

    @astrojuanlu

    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.

  4. jenshnielsen commented on Sep 1, 2014

    @jenshnielsen
    Member

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

  5. modified the milestones: v1.4.x, v1.4.1 on Sep 3, 2014
  6. added a commit that references this issue on Sep 3, 2014
    126fb9c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions