GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — matplotlib 3.1.2: mplot3d must be explicitly imported to work · Issue #16192 · matplotlib/matplotlib

matplotlib 3.1.2: mplot3d must be explicitly imported to work #16192

New issue
Copy link
New issue
Copy link
Closed
#16272
Closed
matplotlib 3.1.2: mplot3d must be explicitly imported to work#16192
#16272
Copy link
Labels
Documentation
Milestone
v3.1-doc

Description

@pajot
pajot
opened on Jan 12, 2020
Issue body actions

Bug report

Bug summary

In "API Changes - Behavior changes" (https://matplotlib.org/api/api_changes.html#behavior-changes) it says

"mplot3d auto-registration

mpl_toolkits.mplot3d is always registered by default now. It is no longer necessary to import mplot3d to create 3d axes with

ax = fig.add_subplot(111, projection="3d")"

I am not seeing this behaviour.

Code for reproduction

import matplotlib.pyplot as plt
fig3 = plt.figure()
ax3 = fig3.add_subplot(111, projection='3d')

and

mpl.projections.get_projection_names()

Actual outcome

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
~/Berechnung/lib64/python3.6/site-packages/matplotlib/projections/__init__.py in get_projection_class(projection)
     57     try:
---> 58         return projection_registry.get_projection_class(projection)
     59     except KeyError:

~/Berechnung/lib64/python3.6/site-packages/matplotlib/projections/__init__.py in get_projection_class(self, name)
     24         """
---> 25         return self._all_projection_types[name]
     26 

KeyError: '3d'

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
<ipython-input-2-95b16d9d7a18> in <module>
      1 import matplotlib.pyplot as plt
      2 fig3 = plt.figure()
----> 3 ax3 = fig3.add_subplot(111, projection='3d')

~/Berechnung/lib64/python3.6/site-packages/matplotlib/figure.py in add_subplot(self, *args, **kwargs)
   1394         else:
   1395             projection_class, kwargs, key = \
-> 1396                 self._process_projection_requirements(*args, **kwargs)
   1397 
   1398             # try to find the axes with this key in the stack

~/Berechnung/lib64/python3.6/site-packages/matplotlib/figure.py in _process_projection_requirements(self, polar, projection, *args, **kwargs)
   1118 
   1119         if isinstance(projection, str) or projection is None:
-> 1120             projection_class = projections.get_projection_class(projection)
   1121         elif hasattr(projection, '_as_mpl_axes'):
   1122             projection_class, extra_kwargs = projection._as_mpl_axes()

~/Berechnung/lib64/python3.6/site-packages/matplotlib/projections/__init__.py in get_projection_class(projection)
     58         return projection_registry.get_projection_class(projection)
     59     except KeyError:
---> 60         raise ValueError("Unknown projection %r" % projection)
     61 
     62 

ValueError: Unknown projection '3d'

<Figure size 432x288 with 0 Axes>

and

['aitoff', 'hammer', 'lambert', 'mollweide', 'polar', 'rectilinear']

Expected outcome

An Axes3d object and the following output of mpl.projections.get_projection_names():

['3d', 'aitoff', 'hammer', 'lambert', 'mollweide', 'polar', 'rectilinear']

Matplotlib version

  • Operating system: Linux thinkpad_T500 4.19.72-gentoo Updated docs to refer to git #3 SMP Sun Dec 8 14:16:38 CET 2019 x86_64 Intel(R) Core(TM)2 Duo CPU T9400 @ 2.53GHz GenuineIntel GNU/Linux
  • Matplotlib version: 3.1.2
  • Matplotlib backend (print(matplotlib.get_backend())): module://ipykernel.pylab.backend_inline
  • Python version: 3.6.9
  • Jupyter version (if applicable): jupyter core : 4.6.1, jupyter-notebook : 6.0.2

Matplotlib is running in a python environment and was installed with pip.

Activity

  1. anntzer
    added
    Documentation
    on Jan 12, 2020
  2. anntzer
    added this to the v3.1-doc milestone on Jan 12, 2020
  3. anntzer commented on Jan 12, 2020

    @anntzer
    anntzer
    on Jan 12, 2020
    Contributor
    More actions

    This is only in 3.2 (not released yet), looks like the 3.1 whatsnew accidentally included some 3.2 stuff.

    Reacted by Stephen Bosch
  4. pajot commented on Jan 12, 2020

    @pajot
    pajot
    on Jan 12, 2020
    Author
    More actions

    Thanks for this information! Then the 3.1 whatsnew should be updated, no?

  5. dstansby
    closed this as completedin #16272on Jan 21, 2020
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

    Documentation

    Type

    No type

    Projects

    No projects

      Milestone

      • v3.1-doc

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.