Thanks to visit codestin.com
Credit goes to github.com

Skip to content

mpl or plt in code example #9115

Closed
@liuyigh

Description

@liuyigh

Bug report

Bug summary
https://matplotlib.org/users/dflt_style_changes.html
On this page, mpl was not specified. I could not find it in other document with reasonable efforts.

Code for reproduction

import matplotlib as mpl
mpl.style.use('classic')

Actual outcome

Traceback (most recent call last):
  File "plotindex_2.py", line 3, in <module>
    matplotlib.style.use('classic')
AttributeError: 'module' object has no attribute 'style'

Expected outcome

It works after I changed to

import matplotlib.pyplot as plt
plt.style.use('classic')

plt is used all through the documents. Using mpl here while it really needs plt is confusing.

It would be nice to explicitly show what mpl is on that page

Matplotlib version

  • Operating System: Ubuntu 16.04
  • Matplotlib Version: 2.0.2
  • Python Version: 2.7
  • Jupyter Version (if applicable):
  • Other Libraries:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions