Меню

Python matplotlib установка ошибка

Obtaining Matplotlib version#

To find out your Matplotlib version number, import it and print the
__version__ attribute:

>>> import matplotlib
>>> matplotlib.__version__
'0.98.0'

matplotlib install location#

You can find what directory Matplotlib is installed in by importing it
and printing the __file__ attribute:

>>> import matplotlib
>>> matplotlib.__file__
'/home/jdhunter/dev/lib64/python2.5/site-packages/matplotlib/__init__.pyc'

matplotlib configuration and cache directory locations#

Each user has a Matplotlib configuration directory which may contain a
matplotlibrc file. To
locate your matplotlib/ configuration directory, use
matplotlib.get_configdir():

>>> import matplotlib as mpl
>>> mpl.get_configdir()
'/home/darren/.config/matplotlib'

On Unix-like systems, this directory is generally located in your
HOME directory under the .config/ directory.

In addition, users have a cache directory. On Unix-like systems, this is
separate from the configuration directory by default. To locate your
.cache/ directory, use matplotlib.get_cachedir():

>>> import matplotlib as mpl
>>> mpl.get_cachedir()
'/home/darren/.cache/matplotlib'

On Windows, both the config directory and the cache directory are
the same and are in your Documents and Settings or Users
directory by default:

>>> import matplotlib as mpl
>>> mpl.get_configdir()
'C:\Documents and Settings\jdhunter\.matplotlib'
>>> mpl.get_cachedir()
'C:\Documents and Settings\jdhunter\.matplotlib'

If you would like to use a different configuration directory, you can
do so by specifying the location in your MPLCONFIGDIR
environment variable — see
Setting environment variables in Linux and macOS. Note that
MPLCONFIGDIR sets the location of both the configuration
directory and the cache directory.

Getting help#

There are a number of good resources for getting help with Matplotlib.
There is a good chance your question has already been asked:

  • The mailing list archive.

  • GitHub issues.

  • Stackoverflow questions tagged matplotlib.

If you are unable to find an answer to your question through search, please
provide the following information in your e-mail to the mailing list:

  • Your operating system (Linux/Unix users: post the output of uname -a).

  • Matplotlib version:

    python -c "import matplotlib; print(matplotlib.__version__)"
    
  • Where you obtained Matplotlib (e.g., your Linux distribution’s packages,
    GitHub, PyPI, or Anaconda).

  • Any customizations to your matplotlibrc file (see
    Customizing Matplotlib with style sheets and rcParams).

  • If the problem is reproducible, please try to provide a minimal, standalone
    Python script that demonstrates the problem. This is the critical step.
    If you can’t post a piece of code that we can run and reproduce your error,
    the chances of getting help are significantly diminished. Very often, the
    mere act of trying to minimize your code to the smallest bit that produces
    the error will help you find a bug in your code that is causing the
    problem.

  • Matplotlib provides debugging information through the logging library, and
    a helper function to set the logging level: one can call

    plt.set_loglevel("info")  # or "debug" for more info
    

    to obtain this debugging information.

    Standard functions from the logging module are also applicable; e.g. one
    could call logging.basicConfig(level="DEBUG") even before importing
    Matplotlib (this is in particular necessary to get the logging info emitted
    during Matplotlib’s import), or attach a custom handler to the «matplotlib»
    logger. This may be useful if you use a custom logging configuration.

If you compiled Matplotlib yourself, please also provide:

  • any changes you have made to setup.py or setupext.py.

  • the output of:

    rm -rf build
    python setup.py build
    

    The beginning of the build output contains lots of details about your
    platform that are useful for the Matplotlib developers to diagnose your
    problem.

  • your compiler version — e.g., gcc --version.

Including this information in your first e-mail to the mailing list
will save a lot of time.

You will likely get a faster response writing to the mailing list than
filing a bug in the bug tracker. Most developers check the bug
tracker only periodically. If your problem has been determined to be
a bug and can not be quickly solved, you may be asked to file a bug in
the tracker so the issue doesn’t get lost.

Problems with recent git versions#

First make sure you have a clean build and install (see How to completely remove Matplotlib),
get the latest git update, install it and run a simple test script in debug
mode:

rm -rf /path/to/site-packages/matplotlib*
git clean -xdf
git pull
python -m pip install -v . > build.out
python -c "from pylab import *; set_loglevel('debug'); plot(); show()" > run.out

and post build.out and run.out to the matplotlib-devel
mailing list (please do not post git problems to the users list).

Of course, you will want to clearly describe your problem, what you
are expecting and what you are getting, but often a clean build and
install will help. See also Getting help.

  • Редакция Кодкампа

17 авг. 2022 г.
читать 1 мин


Одна распространенная ошибка, с которой вы можете столкнуться при использовании Python:

no module named ' matplotlib '

Эта ошибка возникает, когда Python не обнаруживает библиотеку matplotlib в вашей текущей среде.

В этом руководстве представлены точные шаги, которые вы можете использовать для устранения этой ошибки.

Шаг 1: pip устанавливает matplotlib

Поскольку matplotlib не устанавливается автоматически вместе с Python, вам нужно будет установить его самостоятельно. Самый простой способ сделать это — использовать pip , менеджер пакетов для Python.

Вы можете запустить следующую команду pip для установки matplotlib:

pip install matplotlib

В большинстве случаев это исправит ошибку.

Шаг 2: Установите пип

Если вы все еще получаете сообщение об ошибке, вам может потребоваться установить pip. Используйте эти шаги , чтобы сделать это.

Вы также можете использовать эти шаги для обновления pip до последней версии, чтобы убедиться, что он работает.

Затем вы можете запустить ту же команду pip, что и раньше, чтобы установить matplotlib:

pip install matplotlib

На этом этапе ошибка должна быть устранена.

Шаг 3: проверьте версии matplotlib и pip

Если вы все еще сталкиваетесь с ошибками, возможно, вы используете другую версию matplotlib и pip.

Вы можете использовать следующие команды, чтобы проверить, совпадают ли ваши версии matplotlib и pip:

which python
python --version
which pip

Если две версии не совпадают, вам нужно либо установить более старую версию matplotlib, либо обновить версию Python.

Шаг 4: Проверьте версию matplotlib

После того, как вы успешно установили matplotlib, вы можете использовать следующую команду, чтобы отобразить версию matplotlib в вашей среде:

pip show matplotlib

Name: matplotlib
Version: 3.1.3
Summary: Python plotting package
Home-page: https://matplotlib.org
Author: John D. Hunter, Michael Droettboom
Author-email: matplotlib-users@python.org
License: PSF
Location: /srv/conda/envs/notebook/lib/python3.7/site-packages
Requires: cycler, numpy, kiwisolver, python-dateutil, pyparsing
Required-by: seaborn, scikit-image
Note: you may need to restart the kernel to use updated packages.

Примечание. Самый простой способ избежать ошибок с версиями matplotlib и Python — просто установить Anaconda , набор инструментов, предустановленный вместе с Python и matplotlib и бесплатный для использования.

Дополнительные ресурсы

В следующих руководствах объясняется, как исправить другие распространенные проблемы в Python:

Как исправить: нет модуля с именем numpy
Как исправить: нет модуля с именем plotly
Как исправить: имя NameError ‘pd’ не определено
Как исправить: имя NameError ‘np’ не определено

Comments

@KushalSharma19

mwaskom

added a commit
to mwaskom/seaborn
that referenced
this issue

Oct 26, 2020

@mwaskom

mwaskom

added a commit
to mwaskom/seaborn
that referenced
this issue

Oct 29, 2020

@mwaskom

mwaskom

added a commit
to mwaskom/seaborn
that referenced
this issue

Oct 29, 2020

@mwaskom

millerda

added a commit
to millerda/seaborn
that referenced
this issue

Apr 26, 2021

* Ignore otherwise unavoidable warnings in conftest.ini

* Remove old Makefile targets for Stanford website

* Update table css to not break API page

* Update Python kernel that is hardcoded into notebooks

* Fix thumbnail on gallery page

* Include tests in lint check

* PEP8 on Py27

* Force alphabetical sort of example gallery thumbs

* Add file with pinned versions of doc dependencies

* Add v0.9.1 to release notes page

* Add a relplot example to line/scatterplot

Closes #1664

* Add intersphinx links where kwargs are defined

Closes #1937

* Update to reflect new example data

* New pytest breaks coverage?

* Update release notes

* Update install docs to reflect new minimum dependencies

[ci skip]

* Fix gallery generator

* Release notes text

* More improvements to clustergrid layout

This enables use of tight_layout within clustermap. Ideally most plots will
now have everything in the figure and looking nice out of the box. It uses
a somewhat hacky approach that should be revisted as constrained_layout matures.

Also updates the docs a little bit and adds a rule where cbar_pos=None implies
that no colorbar will be drawn.

* Improve clustermap API examples

* Remove commented code

[ci skip]

* Add thumbnail images on the tutorial homepage

* Drop Python 2 from setup files

* Excise six

* Drop 2.7 (and 3.5) from travis build

* Remove references to 2.7 from README/docs

* Make tutorial thumbnails link to relevant page

* Modernize minimal dependencies

* Reorganize 0.9.1 feature notes

* Explicitly error in setup on Python < 3.6

* Remove smooth bootstrap

* Remove seaborn.timeseries

* Remove seaborn.linearmodels

* Remove seaborn.apionly

* Remove top-level import of timeseries module

* Add link to website footer

* Add version 0.10 release notes

* Update version for 0.10.0 release candidate

* Release v0.10.0.rc0

* Make dogplot more tolerant

I really like this easter egg :-)

However, when you suggest someone to use `dogplot` instead of `catplot`, they will receive a `TypeError` explaining that they provided too many arguments. This kind of spoils the fun. What about making it more tolerant?

* Add a pandas API link in introduction

* Bump version for v0.10 release

* Fix a few things in the docs

* Release v0.10.0

* Tweak release notes

* Bump version back to dev on master

* Add 0.9.1 and 0.10.0 DOI badges

* Use the correct platform integer type

`np.array.take` requires that the index be the platform integer type (`int32` for 32bit and `int64` for 64bit), but `np.random.RandomState.randint` returns an `int64` on any platform by default.  This makes sure it returns the right type of integer for the current platform.

Fixes mwaskom#1950

* Fix release notes link

* Add 0.10.1 release notes file and mention bootstrap fix

* DOC: update truncate parameter string to reflect new default (#1961)

* Use numpy's indexing dtype in bootstrap (#1968)

Follow-up to #1952 that uses the correct dtype

* Don't fail in regplot on singletons, don't fit regression either (#1969)

* FIX: don't squeeze singletons

* Disable regression fit in case of singleton inputs

* Update release notes

[ci skip]

* Copy props from old cmap when creating new cmap in heatmap (#1948)

* preserve cmap props when centering

* preserve explicitly set extremes

* Update release notes

* added tests for sig_stars() function (#1972)

* added tests for sig_stars() function

Since the `sig_stars()` function in utils.py doesn't have tests. I added the test to increase the coverage test.

* fixed 5th case in test_sig_stars() function

* Changed the stars variables

* Removed whitespaces in blank lines

* FIX: Ignore masked cells when finding heatmap data limits (#1956)

* respect mask when setting heatmap limits

* respect mask when setting heatmap limits

* improve code style

* Update release notes

* Add deprecation notice for sig_stars (#1973)

* MNT: Remove unused code paths (#1965)

* TST: pandas==1.0 compat

* Remove old matplotlib paths

* Remove old scipy paths

* Remove _set_spine_position

The behavior that this function addressed has been resolved in matplotlib 1.4:
https://github.com/matplotlib/matplotlib/pull/3104

* Clean more old compat code paths

Removed a few try/except clauses aimed to cover old matplotlib/pandas
versions that are no longer supported.

* Remove __future__ imports

* Improve code style

* Make all links possible use https:// (#1985)

* FIX: avoid error when prop_cycle has no color (#1992)

* Rework get_color_cycle

* No longer fail when cycler has no color (fixes #1977)

* Improves docstring

* Adds tests

* default to dark gray

* remove redundant test

* Avoid error in despine when axis has matplotlib categories (#1991)

Fixes #1978

* Make remaining links use https:// (#1984) (#1988)

* python3-only to_utf8 (#1979)

Co-authored-by: Michael Waskom <mwaskom@users.noreply.github.com>

* Fix `add_legend` to always populate `_legend` (#1999)

Even when `legend_out` is False

* Fix test import

* Avoid floating point error with maximum husl sat/lum (#2000)

* homogenization to use _color_to_rgb and normalization of husl_to_rgb output in [0,1]

* added better test to husl_to_rgb input and output

* Use numpy function and improve tests

Co-authored-by: Ivan Gonzalez <scratchmex@gmail.com>

* Autoscale in swarmplot to get valid transform (#2017)

Fixes #2013

* Add optional argument showfliers for boxenplot (#2010)

* Add optional argument showfliers for boxenplot

Same API as matplotlib boxplot to show/hide markers beyond the box(es)

* Remove trailing whitespace

* Add default value (True) for showfliers parameter

* Fix doc of showfliers parameter

* Add test for boxenplot showfliers parameter

* Update release notes

* Added fix for minor typos in 0.9.1 release notes (#2019)

* Housekeeping in utilities module (#2035)

* Tweak some utitlity docstrings and deprecate percentiles function

percentiles is now redundant with numpy.percentile and had not been
used internally in some time.

* Switch from internal percentiles function to numpy.percentile

* Deprecate ci_to_errorsize and pmf_hist

Closes #2034

* Revert deprecation of ci_to_errsize

* Excise and deprecate sort_df

Closes #2033

* PEP8

* Update release notes

* Fix deprecation warning handling in tests

* ENH: Handle`legend.title_fontsize` rcparam (#2025)

* test legend title size

* don't ignore legend.title_fontsize rcparam

* add 'legend.title_fontsize' to context

* Update release notes

* Examples of ways to have the same mapping between facets (#2030)

* PEP8

* Avoid seeing an error from statsmodels in kdeplot when data IQR == 0 (#2040)

* Handle some small housekeeping items prior to releasing v0.10.1 (#2041)

Document functions supporting example data

Add v0.10.1 release notes to whatsnew page

Avoid matplotlib deprecation warning in boxplot example

* Finalize v0.10.1 release notes

* Add Zenodo DOI for v0.10.1

* Add explicit warning in swarmplot about gutters (#2045)

Currently set to warn when > 2% of the points overlap; with a little playing
around, this seemed like where the distribution started to get obscured.
But it is ad hoc.

* Make FacetGrid a bit more convenient (#2046)

* Add FacetGrid.axes_dict attribute

* Clear inner labels from FacetGrid when setting x/y labels

* Update release notes

* Require keyword arguments for most parameters (#2052)

* Enforce keyword-only arguments for all non-semantic parameters in plotting API

* Ignore vscode cruft

* Fix tests that use positional arguments

* Standardize function signature formatting

* Accept positional args past * and warn for next release cycle

* Converge on standard plotting function signatures

* Update tests to use keyword arguments

* Move development-related decorators to specific module

* Standardize parameter names in distributions module (#2060)

* Standardize parameter names in distributions module

* Compat with older statsmodels

* Improve kdeplot tests

* Stricter code linting

- Define fewer PEP8 exceptions
- Define flake8 config centrally
- Fix existing issues

* Stricter code linting (#2064)

- Define fewer PEP8 exceptions
- Define flake8 config centrally
- Fix existing issues

* Add tight_layout method on FacetGrid and PairGrid (#2073)

* Add Grid.tight_layout for legend-aware automatic layout

* Use Grid.tight_layout internally

* Refactor variable processing (#2071)

* Add initial common function for processing long-form inputs

* Attempt to use new core variable processing for longform relational plots

* Create and ignore a directory for notes

* Move relational plots to use common variable processing

* Refactor establish_variables method into core

* Allow relational plots to use wide lists of lists

* Change base class to _VectorPlotter

* Add initial attempt at generalized wide data processing

* Modify tests for new intermeidate wide-form data representation

* Remove relational-specific wide data processing

* Fold relplot tests under TestRelationalPlotter

* Move tests for core variable processing

* Revert test reorganization; PEP8 and clean up names

* Add tests for wide dict inputs

* Pandas compat

* Modernize numpy random usage in test fixtures

* Fix docstring and comments

* Use containment checks rather than KeyError handling

* Improve test coverage for long data and messy wide data

* Test variables from dataframe index

* Flesh out wide data docstring

* Return variables dict along with plot_data df

* First attempt at generalizing relplot inputs

* Refactor and parametrize flat variables tests

* Test at base class level

* Test relplot from wide data and long vectors

* Fix test

* Programmatically define arbitrarily large style mappings (#2075)

* Programatically define arbitrary dash specs

* Add unique default markers and update tests

* Don't pass MarkerStyle into plt.plot

This fails; see https://github.com/matplotlib/matplotlib/issues/17432

* Update release notes

* Emphasize that default dashes/markers are unique.

* Add refs to github PRs

* Scale the default scatterplot edge width by the point radius (#2078)

* Scale the default scatterplot edge width by the point radius

* Reorder operations in scatterplot plot

* Allow vectors for c= or s= in scatterplot (#2079)

* Improve FacetGrid margin titles to not show previous texts (#2083)

* Improve FacetGrid margin titles to not show previous texts

* Add ref to github issue

* Require keyword arguments almost everywhere (#2081)

* Require all args but `data` to have keywords

* Remove argument __repr__ from keyword warning

Fixes #2066

* Update internal code and docstring examples to use kwargs everywhere

* Don't fail on anonymous functions

* Add keyword arguments in gallery examples and tutorials

* Provide more information in the warning

* Centralize and modify variable type inference (#2084)

* Centralize and modify variable type inference

* Use core.variable_type elsewhere in the library

* Bump pinned pandas to avoid bug

* Test coverage

* Move orientation inference to core and improve error handling

* Parameterize necessity of numeric variable by plot type

* Tweak language

* Shorten parameter name

* Correct comment

* Tweak docs

* Deprecate iqr and axlabel; improve deprecation warning class (#2087)

* Deprecate iqr and axlabel; improve deprecation warning class

* Note deprecations

[ci skip]

* Refactor semantic mapping operations (#2090)

* Prototype of rugplot that passes original tests

* Update test style

* Implement idea for less-verbose interaction with Plotter classes

* Explore an idea about how to abstract hue mapping

* Shush Flake8

* Define semantics with tuples, not lists, to make immutable

* Define semantic mappings with some complex higher-order magic

* Move some of the hue mapping logic

* Continued refactoring of variable assignment and hue mapping

* Refactor lineplot and get tests to pass

* Get most RelationalPlotter tests passing

* Fix error introduced during refactoring

* Move hue mapping tests from test_relational to test_core

* Avoid treating string palette arg as signaling categorical

* Set map_type to include datetime, add note about missing implementation

* Change semantic inheritance to be restrictive rather than expansive

* Consider boolean data categorical at Plotter level

* Sort out where utils/core funcs should go

* Strip nose out of the utils tests

* Move new decorator to where it belongs and add a test

* Clean up a few leftovers from utils reorg

* Add more HueMapping tests

* Make core module private

* Make objects in core non-private

* Add initial version of SizeMapping object

* Messy first pass at replacing parse_size with SizeMapping

* Fix size mapping to match current behavior, defer decoupling from plotter

* Add test to capture relplot bug

* Fix relplot numeric hues

* Move all hue/size lookup logic into corresponding Mapping objects

* Finalize refactoring of size mapping

* Add prototype of StyleMapping

* Integrate StyleMapping into relational plots

* Get relational tests to pass

* Move StyleMapping tests to core and excise parse_style from relational

* Point rugplot at old code for now

* Add some more basic tests

* Treat units as a normal semantic

* Rename assign_variables method

* Address some TODOs about style/organization/defaults

* Address more small TODOs and flesh out docs

* LogNorm now fails with non-positive data (as it arguably should)

* Handle units in relplot (fixes #2080)

* Ignore false-alarm warning from numpy on string/number comparison

* Catch a few pieces of residual cruft

* Ignore a separate dubious numpy warning

* Improve test coverage

* Avoid error in relational user guide page

* Improve lineplot handling of mpl kwargs (#2095)

* Improve lineplot handling of mpl kwargs

Fixes #1526

* Update release notes

* Refactor method for getting semantic subsets down to core (#2097)

* Refactor method for getting semantic subsets down to core

* Require explicit grouping semantics

* Fix ordering bug by maintaining category metadata (#2099)

* Update docs (#2098)

* Update kdeplot example to use keyword-only arguments
* Update intersphinx path to numpy docs

* Fix typo and dud test (#2100)

* Add basic CI workflow

* Fix CI workflow

* Iterate CI

* Add doc build to CI

* Define kernel for doc build during CI

* Explicit install of deps and utils during CI

* Test docs during CI (#2109)

* Excecute gallery scripts and fail on errors

* Revert change to github ci workflow

* Test doc build with intentionally broken notebook

* Revert broken notebook

* Use MPLBACKEND environment variable

* Reorganize testing-related files

* Specify qt version for travis

* Don't test backend rcParam

* Fix dud test. (#2116)

* Modernize kdeplot and rugplot (#2104)

* Add expand_margins parameter to rugplot and make default

* Reorganize handling of mpl kwargs

* Handle deprecated rugplot params and begin specing out kdeplot

* Prototype out kdeplot using existing internal functions

* Mostly functional new implementation of univariate kdeplot

* Add new (and changed) kdeplot parameters: bw_method, bw_adjust, weights

* Prototype a number of new kdeplot features

* Reorganize KDE plotting a bit

* Tidy up the univariate plotting function with comments

* Handle missing hue levels and stacked cumulative plots

* Implement kde in log space

* Clean up existing tests

* Add test coverage for univariate kde plot

* Consider boolean x/y variables to be numeric

* Add explicit log scaling and reorganize outer kdeplot logic

* Add more kdeplot tests

* Compat with pinned matplotlib and scipy versions

* Handle and test singleton input

* Add axis labels to core and use in kdeplot

* Make flat_data organization parameterizable

* Add provisional legend for kdeplot

* Implement soft deprecation of shade in kdeplot

* Allow positional x in kdeplot/rugplot

* Cleaning

* Add tests for new rugplot

* Rename scale_by_hue -> common_norm and cut_by_hue -> common_grid

* Input checking and TODO cleanup

* Make univariate fill default depend on hue_method

* Use fill= instead of shade= when using kdeplot internally

* Refactor kernel density estimation logic into its own class

* Add bivariate KDE computation

* Implement much of new bivariate kdeplot

* Sort out bivariate kdeplot color(mapping) and some other issues

* Add bivariate log scaling and handle some aspects of the old API

* Temporarily enable old approach to bivariate color map

* Reverse the gradient of the hue-mapped light_palette

* Deprecate shade_lowest in favor of thresh

* Mark old tests that aren't going to pass with new version

* Fix color= logic in kdeplot

* Add rugplot legend

* Add test coverage for bivariate kdeplot

* Pinned matplotlib compat

* Add reverse iteration through semantic subsets and clean up kdeplot

* Improve stack/fill computation and set sticky support edges for fill

* Disable density axis labels in jointgrid marginal axes

* Update kdeplot usage elsewhere in library

* Allow lable for bivariate kdeplot without hue

* Remove old code and tests

* Add parameter documentation and notes for kdeplot

* Check the inputs types to a bivariate kdeplot and error early

* Add bivariate kdeplot examples

* Add a matplotlib rc to the doc directory forcing bbox_inches=tight

* Add rugplot api docs

* Skip doctests on pinned dep build

* Fix link to matplotlib color docs

* Remove last remaining internal usage of shade

* Add release notes for new distribution plots

* Simplify common_norm logic

* Converge on multiple= parameter

* Use only fill_between for filled densities, and add more color handling

* Update references to matplotlib artists in kdeplot

* Remove separate fill_kws dictionary

* Allow None as clip value

* Add new gallery examples

* Update axisgrid tests

* Simplify kdeplot drawing and modify test for old matplotlib compat

* Fix small issues in docstrings

[ci skip]

* Add overwrought apporach to docstring standardization

* Allow used named .format arguments

* Don't fail on int input and mask (#2103)

Cast to float before filling with np.nan (fixes #2102)

* Boxenplot bug fixes, small features and style changes (#2086)

* Avoid drawing unnecessary outliers

* Remove deprecated lvplot

* refactor defaults and internal signatures

* Fix and improve boxenplots tests

* FIX: avoid generating an extra box (#2086)

* Draw a single box with the correct color

* Tweaked boxenplot style

A few changes to make it more consistent with boxplot:

* Outliers now use gray color instead of plot color.

* Boxes also have edge color of self.gray. The default style enforces
  patches edges to be white (#1468) and this made invisible boxes on
  white background. boxplot uses self.gray edges as well so this is
  consistent.

* Use butt capstyle for medians

* Add boxenplot tests

* Allow k to be a number

* autoscale after drawing boxenplot (#2085)

* Make last box have some color

* more tests

* improve tests coverage

* improve strip over boxen example

* improve boxenplot docstring

* use tukey method by default (#803)

* improve code style

* add 'full' option to k_depth

* restrict 'outlier_prop' to (0,1]

* Fix "trustworthy" method (#2118)

* Adds a new parameter to control alpha levels of "trustworthy"

* Fixes the formula to calculate number of boxes for "trustworthy"

* update release notes

* rename box_alpha to trust_alpha

* improve code style

* Store code examples in API docs using notebooks (#2123)

* Add new infrastructure for generating docs from notebooks

* Move rugplot examples into notebook

* More imporvements to new notebook processing infrastructure

* Add output stripping to doc notebook build

* Add script for auto-generating API doc notebooks

* Improve Makefile infra

* Convert kdeplot API docs to notebook

* Read notebook kernel from environment variable

* Add pandoc to GH doc build

* Consolidate workflow

* Add histplot function (#2125)

* Refactor the KDE plotting so the computation is easier to re-use

* Add univariate histogram computation

* Prototype out much of the innner histogram functionality

* Add log-scaling, unsegmented hist, and other features

* Add sticky edges

* Further flesh out segment/fill for histogram

* Improve default aesthetics

* Spec out public histplot function

* Add discrete mode in histplot

* Copy over some supporting code from kdeplot for the time being

* Add bivariate histogram computation

* Add tests for histogram computation

* Add some histplot tests

* Cover most of histplot with tests

* Code housekeeping

* Simplify default linewidth scaling and other changes

* Better, although still unsatisfying, default handling

* Add shrink parameter

* Further tweak default linewidth

* Fix parsing of function docstrings

* Increase allowed linewidth

* Add API docs and examples for histplot

* Pin more specific matplotlib version

* Fix histplot kde color

* Add example that uses histplot

* Adapt default binwidth to the orientation of the plot

* Fix example

* Convert internal use of distplot to histplot

* Udpdate axisgrid tests

* Update histplot alpha test

* PEP8

* Refactor axis units/scaling, allowing experimental support for category/datetime in distribution plots

* Add tests for new axis scale/unit interaction

* Bump minimal matplotlib to 2.2 for consistent category and datetime64 behavior

* Prefer dropna method once we have reduced columns of plot data

* Allow non-filled bar edges to be a bit thicker

* Add clean rules to doc notebook subeets

* Use penguins and planets in histplot docstring

* Make segement default depend on presence of hue semantic

* Fix awkward wording

* Add 'dodge' as a multple method in histplot

* Make three options for histplot appearance: bars, step, poly

* Remove vestgial utility function

* Introduce other elements earlier in histplot examples

* Add frequency as a histogram stat

* Fix test name

* Reorganize DistributionPlotter methods

* Modify implementation of discrete

* Add prototype of bivariate histogram

* Add external interface for bivariate histogram

* Fix test for discrete histogram

* Add test coverage for bivariate histogram

* Document bivariate histplot

* PEP8

* Standardize bivariate colormaps and colorbars between histplot and kdeplot

* Add example that uses bivariate histogram

* Change multiple regression example to use penguins

* Add release notes on histplot

* Add color to histplot signature

* Don't follow color cycle with datetime variable when drawing filled plot

* Fix hue test

* Tweak some docs and comments

* Revert test for unused default

* Default to discrete bins for categorical variables

* Work around #2135 to always use non-null data

* Clean up a couple of TODO comments

* Simplify example

* Fix default color in histplot with datetime variable (#2136)

* Fix default color in histplot with datetime variable

* Fix default color in histplot with datetime variable

* Improve support for datetime (and categorical) data in relational plots (#2138)

* Improve support for datetime (and categorical) data in relational plots

Fixes #2130

* Disable pandas unit conversion during testing

* Force matplotlib date converters in test fixture

* Clarified documentation of despine (#2140)

* clarified documentation of despine

* improved wording

* Add ecdfplot function (#2141)

* Add basic ecdfplot implementation

* Allow user to override drawstyle

* Add unit tests

* Add docstring content

* Add more docstring information and fix test

* Add complementary ECDF

* Add ecdfplot API examples

* Fix step plots with y data variable

* Housekeeping

* Fix error message

* Mention ecdfplot in release notes

* MNT: fix some failures with matplotlib=3.3.0rc1 (#2144)

* Avoid error on new matplotlib for equal aspect test

* Avoid palplot failure on mpl3.3

* Avoid error for unnamed groups

Mpl3.3 requires that removing tick labels for categorical
plots is done with empty labels rather than an empty list.
This is an issue with unnamed groups for categorical plots
(e.g. boxplot(x=vector)).

* Delete .mailmap

* TST: Increase testing speed by utilizing multiple cores (#2146)

* utilize multiple CPUs with pytest

* cache test datasets before testing

* avoid pulling qt for non-interactive tests

* cleanup qtagg mentions

* Dont add null columns in plot_data for unassigned semantics (#2148)

* Dont assign null columns in plot_data for unassigned semantics

* Fix comment wording

[ci skip]

* DOC: enable Sphinx rules for linking to GitHub issues, PRs and users (#2151)

* add sphinx-issues extension

* remove unnecessary mpl import

* add links to PRs

* Elaborate on how to build the docs

* Improve seaborn discoverability (#2160)

* update trove classifiers

* Explicitly install pyqt to allow qt5agg tests

Since not all matplotlib distributions specify pyqt as a dependency

* Remove magic number in example script (#2165)

* Fix typo (#2168)

* Improve matrix functions docstrings (#2188)

* fix matplotlib backends usage path

* add intersphinx links

* Better comply with numpydoc

* Use only stdlib in get_dataset_names (#2190)

* Use only stdlib in get_dataset_names

* Fix import for miscplot tests

* Don't test on matplotlib 3.3.1 to avoid scatter bug (#2197)

xref #2194, matplotlib/matplotlib#18254

* Add displot, a figure-level distribution function  (#2157)

* Initial pass at prototyping new approach to figure-level functions

* Very messy implementation of new figure-level distplot

* Mostly functional bivariate histogram distplot, with hacks

* Use utility function to share default parameters (good idea?)

* Simplify some operations, add more original distplot features

* Implement basic kind='kde' in new distplot

* Implement basic kind=ecdf in new distplot

* Implement backwards compat for ax

* Minor formatting changes

* Rename semantic_subsets -> iter_data

* Centralize log scale logic

* Minor changes to easy distplot API transition

* Remove vestigial code that subset columns of plot_data

* Fix semantic ordering bug

* Increased hackification of the interface between VectorPlotter and FacetGrid

* Handle histogram post-processing on each facet

* Better (but still partial) integration between distplot and FacetGrid

* More distplot deprecation/API change handling

* Get tests passing

* Avoid duplicate columns in the dataframe passed to FacetGrid

* Enable log scaling and custom color

* Attempt to ease more distplot transition w/r/t kde_kws

* Abandon plan to convert distplot, introduce displot instead

* Add FacetGrid parameters to displot signature

* Add stopgap to get proper FacetGrid legend kind of working

* Revert all distplot changes since v0.10.1

* Add deprecation notice to distplot

* Revert keyword change in existing distplot docs and tests

* Add minimal support for new-style API in distplot, for use in FacetGrid

* Fix small issues with kde color and facet parameters

* Address some TODOs

* Handle a missing-data problem in hue mapping

* Add categorical ordering for some diamonds fields

* Add displot docstring

* Change direction of distribution/axisgrid imports; fill in displot template

* Add API examples for displot

* Add basic infrastructure for testing displot against axes-level function

* Add displot vs kdeplot tests

* Add displot tests vs ecdfplot

* Add rug tests and silence warnings

* Test bivariate and faceted displot

* Add test to cover some new core functionality

* Test new utility function

* Update example gallery

* Improve faceted displot test

* Handle stack/fill/dodge properly in faceted displot

* Control range of bivariate histogram colormap with respect to axes-specific bins

* Add another displot gallery example

* Drop NA in bivariate histogram when determining bins

* Invert y axis with categorical variables

* Handle some TODOs in the code

* Move location of keyword arg dict copy

* Fix inverted categorical y axis on older matplotlibs

* Deal with some TODOs but add note about shared categorical axes

* Add new distributions tutorial

* Update release notes

* Handle legend kwarg in displot

* Unset sticky edges on (thresholded) 2D hist

* Run coverage checks across travis matrix; enhance coverage

* Make a few edits to the new doc README

* Fix and modernize aspects of relational plot docs (#2200)

* Fix relational colors test method

Fixes #2147

* Modernize relational doc inheritence

Fixes #2065, Fixes #2187

* Dedent relplot doc components

* Reorganize docs to emphasize distribution module

* Handle mpl33 deprecations (#2199)

Co-authored-by: Maoz Gelbart <13831112+MaozGelbart@users.noreply.github.com>

* Support wide data with categorical columns (#2202)

* Convert relational model API examples to use notebooks (#2201)

* Update scatterplot API docs to use notebook

* Convert lineplot API examples to notebook

* Convert relplot API examples to use notebook

* Improve notebook processing, don't remove html output

* Start improving lineplot API examples

* Improve (?) lineplot API examples

* Improve scatterplot API examples

* Hide import cells in distribution plot API examples

* Demo using FacetGrid in relplot docs

* Fix doc bugs

[ci skip]

* Always set private despine variable in PairGrid (#2203)

Fixes #2166

* Change dropna default to False in axisgrid.py (#2204)

* Change dropna default to False in axisgrid.py

* Update release notes

* Improve variable assignment feedback (#2205)

* Raise when semantics are set with wide-form data

* Improve error messages when assigning longform data

* Fix tests that trigger new errors

* Avoid kde when variance is almost 0 (#2206)

Fixes #2186

* Address various warnings raised within the test (#2208)

* Fix log warning in comp_data test (and fix comp_data too)

* Avoid numpy ragged array warning when checking flat data

* Adjust code that triggers ragged array error

* Address other ragged array warnings

* Set xticks/yticks before setting labels

* use scatterplot instead of plt.scatter (#2069)

Co-authored-by: Michael Waskom <mwaskom@users.noreply.github.com>

* FIX: allow un-sharing categories in catplot (#2196)

* add tests for 1702

* unify categories across facets only when required

* document count as allowed kind parameter

* Honor user order input

* remove lvplot remnants

* warn if different categories may share color

* update release notes

* don't warn if hue is provided

* fix failing jointplot example

* fix distplot example 6

* Scale `legend.title_fontsize` when scaling fonts (#2214)

* add legend.title_fontsize to tested keys

* scale also legend.title_fontsize

* update release notes

* Add hue as parameter in JointGrid and "hist" as a kind in jointplot (#2210)

* Add 'hist' as a kind in jointplot

* Accept thresh=None in kdeplot

* Add provisional hue support in JointGrid/jointplot

* Move plot equality assertions into _testing module

* Test JointGrid with hue

* Test new jointplot features

* Make jointplot(kind='kde') default to unfilled densities

* Dispatch tuple-ized bin parameters with histplot

* Accept hue mapping parameters and pass to joint/marginal functions if possible

* Use core input processing in JointGrid

* Remove distplot kwargs from the marginal_kws dict and warn about them

* Fix internal names for JointGrid variables

* Default to densities for jointplot margins, like in pairplot

* Do hue-conditional behavior correctly in wide-form mode

* Add marginal_ticks as parameter of jointplot/JointGrid

* Fix typo

* Convert jointplot/JointGrid API examples to notebooks and update with new features

* Adapt marginal ticks test to run on older matplotlibs

* Convert JointGrid/jointplot docstrings to use inherited descriptions

* Update distributions tutorial and fix tutorial index page

* Update JointGrid-related examples

* Try setting backend to Agg during doc build

* Debugging doc build failure

* Attempting to isolate doc failure

* Don't crash doc build on bad thumbnail

* Add marginal ticks example back to the repo

* Undebug ci workflow

* Update release notes

* Fix object-typed numeric hue/size input to relational plots (#2173)

* Test object-typed hue/size

* Soft-convert object-typed arrays

* Satisfy linter

* fix a typo

* Change culmen to bill in all examples using penguins (#2215)

Mirrors changes in the R penguins dataset, saves characters, and
it's easier to remember how to spell 'bill'

* Adjust swarmplot overlap warning and avoid in examples (#2216)

* Adjust swarmplot warning to 5% of points

* Adjust examples that trigger swarmplot warning

* Remove deprecaed JointGrid annotation code (#2217)

* Add user guide documentation on plotting functions and data structures (#2218)

* Add more informative error message for bad dataset name

* Add narrative docs on seaborn data structures

* Fix heatmap example to reflect short month names

* Language tweaks

* Add a tutorial chapter giving an overview to seaborn plotting functions

* Add a schematic figure of long-frm vs wide-form data

* Add new basic user guide chapters to tutorial homepage

* Remove figure-level/axes-level and data structure discussion from introduction

* Convert main scatterplot matrix example to penguins

* Fix typos

* Tweak gallery examples

* Set penguins sex to title case on load

* Tweak thumbnail

* Point to new docs in release notes

* Make note section highlighting lighter

* Use decreasing values for categorical size mapping (#2221)

Fixes #2122

* Use core axis labeling method in relational plots (#2222)

* Add a rich HTML representation of color palette objects (#2225)

* Add rich html_repr to color palette object

* Update palettes tutorial and notebook

* Reverse direction of default distributions sequential colormap (#2224)

* Reduce surprise about relational plot legends (#2229)

* Fix unknown palette error

* Select better brief ticks

Larger maximum number of ticks and no ticks outside the range of the data

* Add 'auto' legend mode in relational plots

* Use 'auto' when relational legend is 'True'

* Only use dummy-artist 'subtitles' with multiple semantic variables

* Add clarity about numeric semantic mapping in scatterplot/lineplot docstrings

* Update release notes

* Update relplot legend tests

* Update legend locator test

* Add utility function to make subtitles look more like titles

* Delint

* Old matplotlib compat

* Try testing on latest matplotlib

* Test legendd=True

* Don't try to set attributes on removed axes (#2233)

Fixes #2228

* Delegate hue in PairGrid to plotting functions (#2234)

* Add provisional support for delegating hue in PairGrid

* Use histplot on pairplot diagonal

* Update Pairgrid tests

* Return self from map_diag

* Improve test coverage

* Convert PairGrid docstring to notebook and update

* Fix test

* Improve support for legends and markers with new plots

* Make color/label injection optional

* Update markers test

* More flexibility in PairGrid

* Convert pairplot API examples to notebook

* Add public access to Grid legend object

* Fix iterative plot_bivariate and improve test coverage

* Don't cast diagonal data to array (fixes #1663)

* replace numpy aliases with builtin types (#2236)

* Add new palette functionality and new colormaps (#2237)

* Add flare and crest colormaps

* Fix internal link

* Tweak some examples to use new colormaps

* Add as_cmap option to color_palette

* Get color palette object through color_palette

* Fix typo

* Get cmap object in kdeplot from internal lookup

* Test new functionality

* Fix logic of _d colormaps and allow _r_d

* Change sep default to 1 in diverging palette

* Pre-release docs enhancements (#2239)

* Add colormap html repr to matplotlib colormaps in palette tutorial

* Organize v0.11 release notes by module

* More release note improvements

* Execute all notebooks with python 3.8 and latest libraries

* Fix regression in palettes image

* Add late-breaking pairgrid enhancements to release notes

* Tweak gallery thumbnails

* Mention new colormaps in release notes

* Cover new color palette functionality in the release notes

* Reorganize homepage thumbnails

* Rewrite color palettes tutorial

* Simplify notebook cleaning code

* Improve palette docstrings

* More color theory background in palette tutorial

* More color variation on homepage

* PMention new palette tutorial in release notes

* Don't copy docstring source files into built site

* Add release note category badges

* Improve grouped barplot example

* Improve links

* Convert and update FacetGrid docstring

* Update tutorials

* Tweaks

* More tweaks

* Add references to seaborn objects used in gallery scripts

* Add proper logos to docs (#2245)

* Add proper logos to docs

* Add logo to README

* Left-align logo

[ci skip]

* Fix discrete string-specified light/dark palettes (#2247)

* DOC: minor fixes (#2242)

* Fix broken link

* tweak

* prefer :doc: over :ref:

* fix broken link

* fix comma

* Better documentation of FacetGrid's access to underlying matplotlib objects (#2248)

* Document FacetGrid axes_dict
Correct axes_dict example

* Further clarify FacetGrid's public access to underlying matplotlib objects

Co-authored-by: Maoz Gelbart <13831112+MaozGelbart@users.noreply.github.com>

* Pre-release docs updates (#2250)

* Language tweaks in intro

* Add background back to cubehelix palette example

* Add an example of making a heatmap using a scatterplot

* Fix cropping fof function overview schematic

* Tweak violinplot example

* Add a new histogram example and tweak another one

* Reorganize example gallery

* Downsize images a bit

* Tweak some text in various notebooks

* Improve installation page

* Improvements and streamlining of the introduction page

* Add axis label kwargs in FacetGrid.set_axis_labels

* Tweaking a bit further

* Mention docs updates in the release notes

* Streamline color theory examples

* Tweak lineplot example colors

* Clarify long/wide data

* Tweak logo

* Remove whitebg svg logos

* Various tweaks

* Fix typo

* Add link to seaborn discourse channel

* Add set_theme() to replace set() (#2253)

* Add set_theme function and change set to an alias

* Add test

* Change set -> set_theme everywhere

* Update aesthetics tutorial

* Update API page and release notes

* Expose set_theme as public API

* Fix bivariate histogram color in displot (#2255)

* Fix bivariate histogram color in displot

* Fix univariate kdeplot color in displot

* Convert coor attribute to rgba in artist tetsts

* Improve PairGrid tight_layout (#2256)

- Track the layout_pad parameter and use whenever tight_layout is called
- Call tight_layout at the end of pairplot

* Small formatting fixes in release notes

* Fix tutorial links in displot docstring

* Add new Zenodo DOIs

* Update internal version to 0.12.0.dev0

* Add links to archived versions of docs

* Pass `col_order` and `row_order` to FacetGrid in displot (#2262)

Co-authored-by: badge <mbadger@hudsonenergy.co.uk>

* Fix PairGrid with non-square grid and non-marginal diagonal axes (#2270)

* Fix PairGrid with non-square grid and non-marginal diagonal axes

Fixes #2260

* Add #2262 to release notes

* TST: fix colors and paths comparison in relational tests (#2281)

* test correct collection

* use matplotlib's same_color

* compare paths arrays lengths

* Fix: use linewidth when plotting boxes and medians (#2287)

* throw a meaningful error message in lmplot in case  kwarg is missing (#2302)

* Fix: do not annotate clustermap w/ annot=False (#2323)

Co-authored-by: criddell <criddell@ucdvais.edu>

* Fix `adjust_subtitles` when `legend_out=False`. (#2304)

* Test adjust_subtitles and legend_out interactions

* Fix adjust_subtitles when legend_out is False

* Remove redundant smoke tests

* Force doc CI to use Python 3.8 (#2335)

Relevant matplotlib issue https://github.com/matplotlib/matplotlib/issues/18718

* Error if row/col colors are indexed but data isn't (#2313)

* Test pandas row/col colors against nonindexed data

* Error if col/row colors are pandas but data isn't

* Improve matrix docstrings

* Reformat code block

* Use numpy array directly

* Format single backticks as literal code block

* Fix jointplot reference syntax in distributions tutorial. (#2359)

* Fix jointplot reference syntax in distributions tutorial.

* Fix rST syntax for hue (add space around ``code``).

* better checks for `sharey` and `sharex` in `axesgrid.py` (#2347)

* bugfix issue 2346

* fix

* MAINT: Drop nose and test on python==3.9 (#2328)

* MAINT: Migrate nose to pytest

* MAINT: Migrate nose to pytest

* MAINT: Migrate nose to pytest

* MAINT: Migrate nose to pytest

* MAINT: Migrate nose to pytest

* MAINT: Migrate nose to pytest

* Modernize some tests

* MAINT: Migrate nose to pytest

* Drop nose dependency

* Improve skip parameter name

* Test on python3.9

* Declare python==3.9 support

* TST: FIX: Consider array length in artist arrays comparison (#2363)

* Add artists length comparison

* Fix jointplot tests

* Fix displot tests

* Fix pairgrid (#2368)

* Add failing test for #2307

* Fix PairGrid hue mapping logic

Fixes #2307

* Fix faceted bivariate KDE normalization (#2378)

Fixes #2377

* Fix NA propagation in lineplot (#2273)

* Use nanpercentile in ci function

Fixes #2272

* Drop NA inside lineplot

Narrowly fixes #2272

But would like a broader solution here that also addresses #1552

* Add a test to catch NA propagation

* FIX: Infer categorical dtypes before boolean resolution (#2379)

* Add test for #2317

* Improve variable_type docstring

* Give precedence to categorical dtype inference

* Run tests on github actions (#2383)

* Assorted fixes for small problems (#2382)

* Fix color_palette docstring (fixes #2372)

* Disable jitter in dotplot example (fixes #2366)

* Raise early in jointplot when selected kind does not support hue (fixes #2326)

* Add weights to ecdfplot docstring (fixes #2348)

* Fix corner PairGrid without marginal diagonal (fixes #2354)

* Use math.isclose for zero variance check

See https://github.com/numpy/numpy/issues/10161

Fixes #2294

* Raise informative error when PairGrid has no rows/columns (Fixes #2311)

* Use same y axis scaling for diag_kind='hist' and diag_kind='auto' resolving to hist (fixes #2314)

* Handle list/array boolean check

* Update release notes

* Fix error with no marginal plots where density axis would be shared

* Slight rearrangement of PairGrid variable processing

* Add/restore functionality to long-form data processing (#2386)

* Add/restore functionality to long-form data processing

* Add tests for restored functionality

* Update release notes

* Require strings to access index fields

* Allow clustermap row/col colors to be categorical (#2389)

* Test for categorical row/col_colors input

* Allow categorical row/col_colors input

* Remove unreachable code

At this stage colors is not a pandas object

* Remove unused variables

* Reduce usage of global matplotlib state in axisgrid objects (#2388)

* Reduce usage of global matplotlib state in axisgrid objects

* Improve test coverage and legac compat in JointGrid

* Update release notes

* Always cast func.__module__ to str for safety

* Docs tidying for v0.11.1 release (#2393)

* Update doc dependencies

* Suppress function signatures on main API page

* Add conf params for compatability with newer doc theme

* Fix typos and formatting

* Prepare release notes for release

* Simplify CI build matrix

* Fix PF reference in release notes

* Fix API page sphinx

* Try building docs in parallel

* Fix API docs sphinx

* Reduce doc CI parallelization (#2394)

Can't parallelize over notebooks/html steps without breaking things

* Add v0.11.1 Zenodo badge

* Corrects typo in the diverging palette doc sub-section title (#2397)

* Corrects typo in the doc.

* Fixes the length of the underline

* Raise minimal supported Python to 3.7 and bump requirements (#2396)

* Raise minimal officially supported Python to 3.7

Following NEP29 and upstream libraries

* Make minor bumps to minimally supported library dependencies

Otherwise I couldn't get the pinned libraries installed on Python 3.7

* Change pip requirements style in CI

* Remove code that special-cases now unsupported scipy

* Fix KDE weights test

* Adapt test that fails on pinned matplotlib

* Remove compatability for no-longer-supported dependency versions

* Update release notes

* Make scipy an optional dependency (#2398)

* Vendor reduced version of scipy's KDE, adapt existing KDE code

* Adapt violinplot and stripplot to not require scipy

* Remove vendored kde docstring examples

* Fix missing import

* Remove more unhelpful doctests

* Note that cumulative kdeplot requres scipy

* Make scipy optional in matrix module

* Replace scipy iqr calls and adapt old distplot code

* Standardize flag for scipy availability

* Define extra dependencies in setup file

* Rework CI workflow for new dependency strategy

* Pass extras_require to setuptools

* Remove previously deprecated utility functions

* Remove scipy from categorical tests

* Remove scipy from regression module

* Remove scipy from categorical

* Remove scipy from distribution tests

* Protect scipy-using code in matrix tests

* Remove scipy from distributions tests (again)

* Fix docs about scipy requirements

* Update installing docs

* Update release notes

* Cover some missing-scipy-triggered errors in tests

* Update README and Remove requirements file

* Use modern canonical way of drawing the figure (#2399)

Closes #2343

* Add a note about getting offline docs access through the website repo

* Revert change to forced draw command (#2408)

The change in #2399 inadvertantly broke seaborn on the macosx mpl
backend.

See https://github.com/matplotlib/matplotlib/issues/19197

This PR reverts that change until the issue can be sorted out.

* Increase errorbar flexibility (#2407)

* Add EstimateAggregator and related functions

* Add tests for EstimateAggregator object

* Rework lineplot to use new aggregator object

* Test warning/redirection of old ci= arg

* Update errorbar param in lineplot docs and tutorial

* Add errorbar param to lineplot docstring

* Remove now-unused lineplot-specific aggregation method

* Add release notes stub

* Add text for tutorial chapter on error bars

* Fix lineplot on log scaled axis

* Let log_scaled default to False for unattached plotters

* Handle named functions and nans better in bootstrap function

* Generalize ci deprecation and increase docstring salience

* Simplify code

* Refactor tests and bump minimal pandas (#2412)

* Move long-form variable assignment tests to core test class

* Lift minimum pandas to 0.24

* Modernize some pandas type conversions

* Update .values -> .to_numpy() in tests

* Improve NA robustness in VectorPlotter.comp_data (#2417)

* Improve NA robustness in VectorPlotter.comp_data

* Adjust datetime test to account for archaic matplotlib limitation

* Update release notes

* Abstract logic of forcing figure draw with matplotlib backcompat (#2426)

See https://github.com/matplotlib/matplotlib/issues/19197 for context
Fixes #2343

* boxplot whis keyword docstring clarification (#2427)

* whis keyword docstring change

* Tweak language

Co-authored-by: Michael Waskom <mwaskom@users.noreply.github.com>

* Restrict comparison values for variable type strings (#2436)

This should avoid subtle bugs that could crop up when comparing against
the wrong form (e.g. "category" instead of "categorical").

There might be a built-in way to do this, but I couldn't find it...

* support Float64Dtype in boxenplot, related to #2434 (#2435)

* Fix typo (#2431)

* Modernize categorical plotting and refactor stripplot (#2413)

* Proof of principle refactored stripplot passing all tests

* Improve handling of categorical dates

* Improve automatic categorical orientation with dates

* Add more continuous datetime variable to long_df fixture

* Begin updating stripplot tests

* Update more stripplot tests

* Add test for single strip, with hue

* Fix infer_orient argcheck

* Add tests for flat and wide data in stripplot

* Refactor hue backcompat into a plotter class method, make optional

* Enable new default coloring rules in stripplot

* Update catplot to use new stripplot function

* Update assert_plots_equal to test all collections

* Clean up some comments

* Remove old stripplot code

* Fix typo

* Add explicit categorical order to VectorPlotter._attach

* Modify the implementation of categorical data handling to permit unshared facets

* Improve integration of axis converters with unshared facet grids

* Fix ordering by category dtype

* Fix catplot point sizes

* Add (un)fixed_scale

* Fix plot equality assertion

* Disable tests that hit matplotlib bug due to incomplete implemenation

* Improve test coverage

* Move forced/ordered categorical scaling logic to core

* Add core-level tets for scale method(s)

* Reduce use of special attributes, add formatter and hue_norm

* Update stripplot API examples

* Re-enable kwarg deprecation warning

* Fix log scaled stripplot

* Fixed log-scaled categorical axis

* Don't jitter single strips

* Improve swarmplot algorithm (#2443)

* WIP making swarmplot dynamically update the swarm

* Move beeswarm algorithm into distinct class

* Remove old swarm algorithm methods

* Update beeswarm algorithm to use pointwise sizes

* Force figure draw in swarmplot tests to activate swarm algorithm

* Use exact original value axis data

* Update swarmplot tests and release notes

* Fix tets

* Refactor swarmplot (#2447)

* Refactor swarmplot to match new stripplot (copying too much code)

* Refactor some shared components of swarm and strip plot

* Add dropna logic to iter_data

* Don't try to swarm empty collection

* Fix rst syntax

* Improve droopna logic and copy dataframe to avoid warnings

* Fix bug with jitter on empty category

* Remove original swarmplot code

* Transition catplot with kind='swarm' to new code

* Add more swarmplot tests

* Fix small test issues

* Mark a puzzling pinned test failure as xfail

* Delay log scale query in beeswarm until draw time

* Fix single point jitter

* Added control over the swarmplot warning with warn_thresh

* Update datalim and force autoscale at draw-time

* Update swarmplot API examples

* Refactor common parts of strip and swarm plot tests

* Always update datalim while swarming

* Move bug report text from website into contributing file

* Generalize getting default color from color cycle (#2449)

* Clean up auto-gray code

* Add initial versiono of default_color function

* Reenable swarmplot mandaatory kwarg warning deprecator

* Expand flexibility of supported scatter coloring kwarg

* Change logic of scatter-based coloring to post-proccess mpl object

* Test default and specified colors

* Rework how shared strip/swarm tests work

* Test user-supplied color array with swarm/strip plot

* Address failures on pinned tests

* Use centralized default_color function in scatterplot

* Use default_color function in lineplot

* Use general default color function for kdeplot, rugplot, and ecdfplot

* Use default_color function in histplot

* Get default color after attaching axes

* Mark kdeplot datetime autoscale test as xfail due to matplotlib bug

* Fix logic of color tests

* Workaround empty fill_between datetime autoscale bug

Fixes #2133 on newer matplotlibs

* More backcompat and edge casing

* Add color tests for distribution module

* Fix bar hist legend artists

* Mute color with hue warning for now

* Update README CI status badge to reflect GitHub Actions status

Closes #2453

* Handle deprecation of ci=None in lineplot (#2457)

Fixes #2441

* Fix rugplot with datetime data (#2458)

Fixes #2451

* Set alpha properly on unfilled hist/kde plots (#2460)

* Set alpha properly on unfilled hist/kde plots

Fixes #2450

* Fix typo in kdeplot docstring

* Generalize color comparison

* Add percent-based normalization in histplot (#2461)

* Add percent-based normalization in histplot

* Test bivariate normalization

* Fix multiple resolution when hue variable has no name (#2462)

* Fix multiple resolution when hue variable has no name

Fixes #2452

(cherry picked from commit 008f7e0e030681f8047c7d628e6bb3fc3d23e6ff)

* Remove unused kwarg

* Don't try to resolve multiples if there aren't any

* Simplify logic that ignored multiple when no hue was assigned

* Fix typo and remove outdated comment

* Fix faceted bivariate histogram normalization at displot (#2468)

Fixes #2465

* Update release notes

* Don't fail when docstrings have been stripped by -OO mode (#2473)

* Don't fail when docstrings have been stripped by -OO mode

Fixes #2470

* Fix comment

* Clarify language

* Fix typo

* Fix histplot shrink with non-discrete bins (#2477)

The code for shifting the shrunken bars assumed that discrete binning
was in effect. This is probably the only situation where shrinking
really makes sense, but there was no prevention or warning of getting
an innacurate result when using it with continuous bins.

Fixes #2476

* Update dates

* update matplotlib canonical... (#2482)

.. this will help with inter sphinx warnings.

* Don't pass a set to ListedColormap in clustermap (#2490)

* Don't pass a set object to ListedColormap

Addresses the issue in https://github.com/matplotlib/matplotlib/issues/19544

* Handle multiple LineCollection color kwargs

* Test side colors size homogeneity test

* Fix log scaling in distribution plots (#2504)

* Improve log_scale parameter documentation

Partly addresses #2454

* Fix log-scaled ecdf plots (fixes #2502)

* Fix log-scaled rug plot

* Fix histplot auto line width with log scale or categorical y axis (#2522)

* Fix histplot auto linewidth on log scaled axis

Fixes #2513

* Fix auto linewidth for categorical histograms on the y axis

Fixes #2523

* Add JOSS paper to docs/README (#2546)

* Update docs/readme with links to joss paper

* Remove Zenodo DOIs

* Mention JOSS paper in v0.12 release notes

* DOC: Clarify how to derive dodge parameter value for aligning pointplot in stripplot (#2548)

* DOC: clarify how to derive value for dodge param

* DOC: fix typo develpoment -> development

* DOC: misc fixes. (#2558)

Typos, non-existing parameters, and the fact that space before colon in
parameters is necessary for numpydoc to correctly parse the name and
type

* Reduce redundant computation in distplot linewidth (#2559)

Co-authored-by: Michael Waskom <mwaskom@nyu.edu>
Co-authored-by: Michael Waskom <mwaskom@users.noreply.github.com>
Co-authored-by: Jan Pipek <jan.pipek@gmail.com>
Co-authored-by: Todd <toddrme2178@gmail.com>
Co-authored-by: Christopher Whelan <topherwhelan@gmail.com>
Co-authored-by: Maoz Gelbart <13831112+MaozGelbart@users.noreply.github.com>
Co-authored-by: Iqrar Agalosi Nureyza <misteriqrar@gmail.com>
Co-authored-by: Sebastian Pipping <sebastian@pipping.org>
Co-authored-by: bennguvaye <bennguvaye@users.noreply.github.com>
Co-authored-by: Ivan Gonzalez <scratchmex@gmail.com>
Co-authored-by: Lukas <36054362+lukasberbuer@users.noreply.github.com>
Co-authored-by: danyal-s <danyal-s@users.noreply.github.com>
Co-authored-by: Paul Rougieux <paul.rougieux@gmail.com>
Co-authored-by: Roman Werpachowski <61159095+romanwerpachowski@users.noreply.github.com>
Co-authored-by: Emilio Dorigatti <emilio.dorigatti@gmail.com>
Co-authored-by: Daniel Bauer <danijoo@users.noreply.github.com>
Co-authored-by: Tomas Ojea <tomasojea0@gmail.com>
Co-authored-by: Matthew Badger <badger.matthew@gmail.com>
Co-authored-by: badge <mbadger@hudsonenergy.co.uk>
Co-authored-by: Clément Robert <cr52@protonmail.com>
Co-authored-by: Cameron Riddell <31414128+CRiddler@users.noreply.github.com>
Co-authored-by: criddell <criddell@ucdvais.edu>
Co-authored-by: Bradley Dice <bdice@bradleydice.com>
Co-authored-by: Aaron Spring <aaronspring@users.noreply.github.com>
Co-authored-by: Robin Scheibler <fakufaku@gmail.com>
Co-authored-by: joooeey <lukas.schreiber@gmx.at>
Co-authored-by: André F. Rendeiro <afrendeiro@gmail.com>
Co-authored-by: Ondrej Zacha <ondrej.zacha@okra.ai>
Co-authored-by: Marçal Gabaldà <mgab@users.noreply.github.com>
Co-authored-by: Jody Klymak <jklymak@gmail.com>
Co-authored-by: Stefan Appelhoff <stefan.appelhoff@mailbox.org>
Co-authored-by: Matthias Bussonnier <bussonniermatthias@gmail.com>
Co-authored-by: Isaac Virshup <ivirshup@gmail.com>

Содержание

  1. Как исправить: нет модуля с именем matplotlib
  2. Шаг 1: pip устанавливает matplotlib
  3. Шаг 2: Установите пип
  4. Шаг 3: проверьте версии matplotlib и pip
  5. Шаг 4: Проверьте версию matplotlib
  6. Дополнительные ресурсы
  7. Troubleshooting#
  8. Obtaining Matplotlib version#
  9. matplotlib install location#
  10. matplotlib configuration and cache directory locations#
  11. Getting help#
  12. Problems with recent git versions#
  13. How to fix Matplotlib modulenotfound import errors?
  14. ModuleNotFoundError: no module named ‘matplotlib’ pyplot
  15. Install matplotlib with pip
  16. Anaconda environments
  17. Importerror no module named matplotlib.pyplot / matplotlib.path
  18. [Solved] ImportError: No module named matplotlib.pyplot
  19. ImportError: No module named matplotlib.pyplot
  20. Install Matplotlib in OSX/Linux
  21. Install Matplotlib in Windows
  22. Install Matplotlib in Anaconda
  23. modulenotfounderror: no module named ‘matplotlib’
  24. modulenotfounderror: no module named matplotlib windows 10
  25. modulenotfounderror: no module named ‘matplotlib’ ubuntu
  26. modulenotfounderror no module named ‘matplotlib’ python 3
  27. modulenotfounderror no module named ‘matplotlib’ jupyter notebook
  28. modulenotfounderror no module named ‘matplotlib’ anaconda
  29. modulenotfounderror: no module named ‘matplotlib’ pycharm
  30. modulenotfounderror: no module named ‘matplotlib.pyplot’; ‘matplotlib’ is not a package

Как исправить: нет модуля с именем matplotlib

Одна распространенная ошибка, с которой вы можете столкнуться при использовании Python:

Эта ошибка возникает, когда Python не обнаруживает библиотеку matplotlib в вашей текущей среде.

В этом руководстве представлены точные шаги, которые вы можете использовать для устранения этой ошибки.

Шаг 1: pip устанавливает matplotlib

Поскольку matplotlib не устанавливается автоматически вместе с Python, вам нужно будет установить его самостоятельно. Самый простой способ сделать это — использовать pip , менеджер пакетов для Python.

Вы можете запустить следующую команду pip для установки matplotlib:

В большинстве случаев это исправит ошибку.

Шаг 2: Установите пип

Если вы все еще получаете сообщение об ошибке, вам может потребоваться установить pip. Используйте эти шаги , чтобы сделать это.

Вы также можете использовать эти шаги для обновления pip до последней версии, чтобы убедиться, что он работает.

Затем вы можете запустить ту же команду pip, что и раньше, чтобы установить matplotlib:

На этом этапе ошибка должна быть устранена.

Шаг 3: проверьте версии matplotlib и pip

Если вы все еще сталкиваетесь с ошибками, возможно, вы используете другую версию matplotlib и pip.

Вы можете использовать следующие команды, чтобы проверить, совпадают ли ваши версии matplotlib и pip:

Если две версии не совпадают, вам нужно либо установить более старую версию matplotlib, либо обновить версию Python.

Шаг 4: Проверьте версию matplotlib

После того, как вы успешно установили matplotlib, вы можете использовать следующую команду, чтобы отобразить версию matplotlib в вашей среде:

Примечание. Самый простой способ избежать ошибок с версиями matplotlib и Python — просто установить Anaconda , набор инструментов, предустановленный вместе с Python и matplotlib и бесплатный для использования.

Дополнительные ресурсы

В следующих руководствах объясняется, как исправить другие распространенные проблемы в Python:

Источник

Troubleshooting#

Obtaining Matplotlib version#

To find out your Matplotlib version number, import it and print the __version__ attribute:

matplotlib install location#

You can find what directory Matplotlib is installed in by importing it and printing the __file__ attribute:

matplotlib configuration and cache directory locations#

Each user has a Matplotlib configuration directory which may contain a matplotlibrc file. To locate your matplotlib/ configuration directory, use matplotlib.get_configdir() :

On Unix-like systems, this directory is generally located in your HOME directory under the .config/ directory.

In addition, users have a cache directory. On Unix-like systems, this is separate from the configuration directory by default. To locate your .cache/ directory, use matplotlib.get_cachedir() :

On Windows, both the config directory and the cache directory are the same and are in your Documents and Settings or Users directory by default:

If you would like to use a different configuration directory, you can do so by specifying the location in your MPLCONFIGDIR environment variable — see Setting environment variables in Linux and macOS . Note that MPLCONFIGDIR sets the location of both the configuration directory and the cache directory.

Getting help#

There are a number of good resources for getting help with Matplotlib. There is a good chance your question has already been asked:

Stackoverflow questions tagged matplotlib.

If you are unable to find an answer to your question through search, please provide the following information in your e-mail to the mailing list:

Your operating system (Linux/Unix users: post the output of uname -a ).

Where you obtained Matplotlib (e.g., your Linux distribution’s packages, GitHub, PyPI, or Anaconda).

If the problem is reproducible, please try to provide a minimal, standalone Python script that demonstrates the problem. This is the critical step. If you can’t post a piece of code that we can run and reproduce your error, the chances of getting help are significantly diminished. Very often, the mere act of trying to minimize your code to the smallest bit that produces the error will help you find a bug in your code that is causing the problem.

Matplotlib provides debugging information through the logging library, and a helper function to set the logging level: one can call

to obtain this debugging information.

Standard functions from the logging module are also applicable; e.g. one could call logging.basicConfig(level=»DEBUG») even before importing Matplotlib (this is in particular necessary to get the logging info emitted during Matplotlib’s import), or attach a custom handler to the «matplotlib» logger. This may be useful if you use a custom logging configuration.

If you compiled Matplotlib yourself, please also provide:

any changes you have made to setup.py or setupext.py .

The beginning of the build output contains lots of details about your platform that are useful for the Matplotlib developers to diagnose your problem.

your compiler version — e.g., gcc —version .

Including this information in your first e-mail to the mailing list will save a lot of time.

You will likely get a faster response writing to the mailing list than filing a bug in the bug tracker. Most developers check the bug tracker only periodically. If your problem has been determined to be a bug and can not be quickly solved, you may be asked to file a bug in the tracker so the issue doesn’t get lost.

Problems with recent git versions#

First make sure you have a clean build and install (see How to completely remove Matplotlib ), get the latest git update, install it and run a simple test script in debug mode:

and post build.out and run.out to the matplotlib-devel mailing list (please do not post git problems to the users list).

Of course, you will want to clearly describe your problem, what you are expecting and what you are getting, but often a clean build and install will help. See also Getting help .

© Copyright 2002–2012 John Hunter, Darren Dale, Eric Firing, Michael Droettboom and the Matplotlib development team; 2012–2023 The Matplotlib development team.

Источник

How to fix Matplotlib modulenotfound import errors?

In today’s post i would like to provide some troubleshooting information for people installing the matplotlib library package in their computers.

ModuleNotFoundError: no module named ‘matplotlib’ pyplot

This error is thrown when Python can’t find the Matplotlib package in your development environment. Most probably you’ll be able to troubleshoot this error by downloading the library from the Python repository using the PIP utility.

Install matplotlib with pip

In order to troubleshoot this error follow this process (explained for Windows, might require minor adjustments for MAC and Linux). Note that the process is identical for most Python add on libraries / packages such as Seaborn, NumPy, Pandas and many others.

  • Save your work, and close your Jupyter Notebooks/Lab, Spyder or other development environment you might be using.
  • Open your Command Prompt.
  • Type cmd.
  • Then in the command prompt type, type the following command:
  • Now, go ahead and hit Enter.
  • Python will download the latest version of the matplotlib library from the Python package repository.
  • Once done, open your development environment and import matplotlib.
  • That’s it!

Anaconda environments

If you are have installed Anaconda, then by default, the basic Data Analysis packages, including Pandas and Matplotlib are already installed in your base environment. If for some reason you still receive an import error proceed as following.

  • From the Start mane, open Anaconda Navigator.

  • On the left hand side, hit the Environments tab (step 1)
  • Then highlight your Anaconda environment (step 2).
  • Then in the dropdown box (step 3), select Not Installed.
  • In the Search box, type matplotlib and hit Enter.
  • Then check the box near the package and hit Apply.
  • Then in the Install Packages dialog, click Apply again.

  • Once Anaconda Navigator is done, close it and reopen your development environment and download matplotlib.

Note: for completeness, you can also update your Anaconda environment manually (this is specially useful if you use MiniConda.

  • From the Windows Start Menu open the Anaconda Prompt
  • Type the following command
  • Hit Enter.
  • Now type
  • Hit Enter.
  • Matplotlib will be downloaded and installed.
  • That’s it.

Importerror no module named matplotlib.pyplot / matplotlib.path

This error is the base class of the ModuleNotFound error, and available since Python 3.3. The troubleshooting process we just described will remedy this error as well.

Questions? Feel free to leave us a comment

report this ad

Источник

[Solved] ImportError: No module named matplotlib.pyplot

Table of Contents Hide

The ImportError: No module named matplotlib.pyplot occurs if you have not installed the Matplotlib library in Python and trying to run the script which has matplotlib related code. Another issue might be that you are not importing the matplotlib.pyplot properly in your Python code.

In this tutorial, let’s look at installing the matplotlib module correctly in different operating systems and solve No module named matplotlib.pyplot.

ImportError: No module named matplotlib.pyplot

Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python.

Matplotlib is not a built-in module (it doesn’t come with the default python installation) in Python, you need to install it explicitly using the pip installer and then use it.

If you looking at how to install pip or if you are getting an error installing pip checkout pip: command not found to resolve the issue.

Matplotlib releases are available as wheel packages for macOS, Windows and Linux on PyPI. Install it using pip :

Install Matplotlib in OSX/Linux

The recommended way to install the matplotlib module is using pip or pip3 for Python3 if you have installed pip already.

Using Python 2

Using Python 3

Alternatively, if you have easy_install in your system, you can install matplotlib using the below command.

Using easy install

For CentOs

For Ubuntu

To install matplotlib module on Debian/Ubuntu :

Install Matplotlib in Windows

In the case of windows, you can use pip or pip3 based on the Python version, you have to install the matplotlib module.

If you have not added the pip to the environment variable path, you can run the below command in Python 3, which will install the matplotlib module.

Install Matplotlib in Anaconda

Matplotlib is available both via the anaconda main channel and it can be installed using the following command.

You can also install it via the conda-forge community channel by running the below command.

In case you have installed it properly but it still throws an error, then you need to check the import statement in your code.

In order to plot the charts properly, you need to import the matplotlib as shown below.

Источник

modulenotfounderror: no module named ‘matplotlib’

In this Python tutorial, we will discuss the modulenotfounderror: no module named ‘matplotlib’ and we shall also cover the following topics:

  • modulenotfounderror: no module named matplotlib windows 10
  • modulenotfounderror: no module named ‘matplotlib’ ubuntu
  • modulenotfounderror no module named ‘matplotlib’ python 3
  • modulenotfounderror no module named ‘matplotlib’ jupyter notebook
  • modulenotfounderror no module named ‘matplotlib’ anaconda
  • modulenotfounderror: no module named ‘matplotlib’ pycharm
  • modulenotfounderror: no module named ‘matplotlib.pyplot’; ‘matplotlib’ is not a package

Table of Contents

modulenotfounderror: no module named matplotlib windows 10

Check if you have pip installed already, simply by writing pip in the python console. If you don’t have pip, get a python script called get-pip.py from the internet and save it to your local system. pip is the python package installer.

Take note of where the file got saved and change the current directory to that directory from the command prompt.

Run the get-pip.py script to install pip by writing the following code in cmd (command prompt) to install pip:

Now in cmd type the following code to install matplotlib with its dependencies:

The error will be resolved, if not then follow through the end of this post.

modulenotfounderror: no module named ‘matplotlib’ ubuntu

If you don’t have matplotlib installed then to install Matplotlib for Python 3 through the APT package manager, you need the package python3-matplotlib:

If you want to install it with pip for python 2.7, you need to use pip:

If the error still arises, follow through to the end of the post.

modulenotfounderror no module named ‘matplotlib’ python 3

You can install matplotlib with pip for python 3 and above, you just need to use pip3.

Open the python console and execute the command given below:

By executing the above code, the matplotlib for your python will be installed.

modulenotfounderror no module named ‘matplotlib’ jupyter notebook

Create a virtual environment inside your project directory. If you don’t have it, you have to install virtualenv by executing the following command in the cmd/terminal.

Install matplotlib inside of your virtual environment.

Now, install ipykernel inside your virtual environment.

Connect your jupyter kernel to your new environment.

When you start your jupyter notebook, you will see the option to select an environment, select the environment you have created which has matplotlib installed. Now, you are good to go with it.

modulenotfounderror no module named ‘matplotlib’ anaconda

If you have Python installed previously, before installing Anaconda, the reason could be that it’s running your default Python installation instead of the one installed with Anaconda. You have to try prepending this to the top of your script:

If that does not work, restart the terminal and try installing matplotlib with conda in conda prompt or cmd, and see if it works.

If the problem still not resolves, maybe you have to create a virtual environment as given in the above topics.

modulenotfounderror: no module named ‘matplotlib’ pycharm

You can get this error if you are using pycharm and have matplotlib.py in your current working directory. You have to just delete or rename the matplotlib.py file to resolve the issue, most probably it will work.

modulenotfounderror: no module named ‘matplotlib.pyplot’; ‘matplotlib’ is not a package

The error is caused because of the following reasons, check them out:

  • Make sure that the version of matplotlib you are installing is compaitible with your python version installed.
  • If the python installed is 64 bits version with matplotlib is 32bits. Make sure they are the same.
  • Make sure to add PATH variable for system and environment variables with path to the python.
  • If pip version is outdated, upgrade it to the latest version.
  • Also make sure that there is no typos in the import statement.
  • If the error still exist then, try to check if there is any file matplotlib.py in your working directory. Remove that file, restart the kernel and import matplotib again. That should work.

You may also like reading the following articles.

In this Python tutorial, we have discussed the modulenotfounderror: no module named ‘matplotlib’ and we have also covered the following topics:

  • modulenotfounderror: no module named matplotlib windows 10
  • modulenotfounderror: no module named ‘matplotlib’ ubuntu
  • modulenotfounderror no module named ‘matplotlib’ python 3
  • modulenotfounderror no module named ‘matplotlib’ jupyter notebook
  • modulenotfounderror no module named ‘matplotlib’ anaconda
  • modulenotfounderror: no module named ‘matplotlib’ pycharm
  • modulenotfounderror: no module named ‘matplotlib.pyplot’; ‘matplotlib’ is not a package

Python is one of the most popular languages in the United States of America. I have been working with Python for a long time and I have expertise in working with various libraries on Tkinter, Pandas, NumPy, Turtle, Django, Matplotlib, Tensorflow, Scipy, Scikit-Learn, etc… I have experience in working with various clients in countries like United States, Canada, United Kingdom, Australia, New Zealand, etc. Check out my profile.

Источник

The ImportError: No module named matplotlib.pyplot occurs if you have not installed the Matplotlib library in Python and trying to run the script which has matplotlib related code. Another issue might be that you are not importing the matplotlib.pyplot properly in your Python code.

In this tutorial, let’s look at installing the matplotlib module correctly in different operating systems and solve No module named matplotlib.pyplot.  

Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python.

Matplotlib is not a built-in module (it doesn’t come with the default python installation) in Python, you need to install it explicitly using the pip installer and then use it.

If you looking at how to install pip or if you are getting an error installing pip checkout pip: command not found to resolve the issue.

Matplotlib releases are available as wheel packages for macOS, Windows and Linux on PyPI. Install it using pip:

Install Matplotlib in OSX/Linux 

The recommended way to install the matplotlib module is using pip or pip3 for Python3 if you have installed pip already.

Using Python 2

$ sudo pip install matplotlib

Using Python 3

$ sudo pip3 install matplotlib

Alternatively, if you have easy_install in your system, you can install matplotlib using the below command.

Using easy install

$ sudo easy_install -U matplotlib

For CentOs

$ yum install python-matplotlib

For Ubuntu

To install matplotlib module on Debian/Ubuntu :

$ sudo apt-get install python3-matplotlib

Install Matplotlib in Windows

In the case of windows, you can use pip or pip3 based on the Python version, you have to install the matplotlib module.

$ pip3 install matplotlib

If you have not added the pip to the environment variable path, you can run the below command in Python 3, which will install the matplotlib module. 

$ py -m pip install matplotlib

Install Matplotlib in Anaconda

Matplotlib is available both via the anaconda main channel and it can be installed using the following command.

$ conda install matplotlib

You can also install it via the conda-forge community channel by running the below command.

$ conda install -c conda-forge matplotlib

In case you have installed it properly but it still throws an error, then you need to check the import statement in your code.

In order to plot the charts properly, you need to import the matplotlib as shown below.

# importing the matplotlib 
import matplotlib.pyplot as plt
import seaborn as sns

# car sales data
total_sales = [3000, 2245, 1235, 5330, 4200]

location = ['Bangalore', 'Delhi', 'Chennai', 'Mumbai', 'Kolkatta']

# Seaborn color palette to plot pie chart
colors = sns.color_palette('pastel')

# create pie chart using matplotlib
plt.pie(total_sales, labels=location, colors=colors)
plt.show()

Avatar Of Srinivas Ramakrishna

Srinivas Ramakrishna is a Solution Architect and has 14+ Years of Experience in the Software Industry. He has published many articles on Medium, Hackernoon, dev.to and solved many problems in StackOverflow. He has core expertise in various technologies such as Microsoft .NET Core, Python, Node.JS, JavaScript, Cloud (Azure), RDBMS (MSSQL), React, Powershell, etc.

Sign Up for Our Newsletters

Subscribe to get notified of the latest articles. We will never spam you. Be a part of our ever-growing community.

By checking this box, you confirm that you have read and are agreeing to our terms of use regarding the storage of the data submitted through this form.

A common error you may encounter when using Python is modulenotfounderror: no module named ‘matplotlib’. This error occurs when Python cannot detect the Matplotlib library in your current environment. This tutorial goes through the exact steps to troubleshoot this error for the Windows, Mac and Linux operating systems.

Table of contents

  • ModuleNotFoundError: no module named ‘matplotlib’
    • What is ModuleNotFoundError?
    • What is Matplotlib?
    • How to Install Matplotlib on Windows Operating System
    • How to Install Matplotlib on Mac Operating System
    • How to Install Matplotlib on Linux Operating Systems
      • Installing pip for Ubuntu, Debian, and Linux Mint
      • Installing pip for CentOS 8 (and newer), Fedora, and Red Hat
      • Installing pip for CentOS 6 and 7, and older versions of Red Hat
      • Installing pip for Arch Linux and Manjaro
      • Installing pip for OpenSUSE
    • Check Matplotlib Version
    • Installing Matplotlib Using Anaconda
    • Importing matplotlib.pyplot
  • Summary

ModuleNotFoundError: no module named ‘matplotlib’

What is ModuleNotFoundError?

The ModuleNotFoundError occurs when the module you want to use is not present in your Python environment. There are several causes of the modulenotfounderror:

The module’s name is incorrect, in which case you have to check the name of the module you tried to import. Let’s try to import the re module with a double e to see what happens:

import ree
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
1 import ree

ModuleNotFoundError: No module named 'ree'

To solve this error, ensure the module name is correct. Let’s look at the revised code:

import re

print(re.__version__)
2.2.1

You may want to import a local module file, but the module is not in the same directory. Let’s look at an example package with a script and a local module to import. Let’s look at the following steps to perform from your terminal:

mkdir example_package

cd example_package

mkdir folder_1

cd folder_1

vi module.py

Note that we use Vim to create the module.py file in this example. You can use your preferred file editor, such as Emacs or Atom. In module.py, we will import the re module and define a simple function that prints the re version:

import re

def print_re_version():

    print(re.__version__)

Close the module.py, then complete the following commands from your terminal:

cd ../

vi script.py

Inside script.py, we will try to import the module we created.

import module

if __name__ == '__main__':

    mod.print_re_version()

Let’s run python script.py from the terminal to see what happens:

Traceback (most recent call last):
  File "script.py", line 1, in <module>
    import module
ModuleNotFoundError: No module named 'module'

To solve this error, we need to point to the correct path to module.py, which is inside folder_1. Let’s look at the revised code:

import folder_1.module as mod

if __name__ == '__main__':

    mod.print_re_version()

When we run python script.py, we will get the following result:

2.2.1

Lastly, you can encounter the modulenotfounderror when you import a module that is not installed in your Python environment.

What is Matplotlib?

Matplotlib is a data visualization and graphical plotting library for Python. Matplotlib is an open-source alternative to MATLAB. Pyplot is a Matplotlib module, which provides a MATLAB-like interface. You can use pyplot to create various plots, including line, histogram, scatter, 3D, image, contour, and polar.

The simplest way to install Matplotlib is to use the package manager for Python called pip. The following installation instructions are for the major Python version 3.

How to Install Matplotlib on Windows Operating System

First, you need to download and install Python on your PC. Ensure you select the install launcher for all users and Add Python to PATH checkboxes. The latter ensures the interpreter is in the execution path. Pip is automatically on Windows for Python versions 2.7.9+ and 3.4+.

You can check your Python version with the following command:

python3 --version

You can install pip on Windows by downloading the installation package, opening the command line and launching the installer. You can install pip via the CMD prompt by running the following command.

python get-pip.py

You may need to run the command prompt as administrator. Check whether the installation has been successful by typing.

pip --version

To install matplotlib with pip, run the following command from the command prompt.

pip3 install matplotlib

How to Install Matplotlib on Mac Operating System

Open a terminal by pressing command (⌘) + Space Bar to open the Spotlight search. Type in terminal and press enter. To get pip, first ensure you have installed Python3:

python3 --version
Python 3.8.8

Download pip by running the following curl command:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

The curl command allows you to specify a direct download link. Using the -o option sets the name of the downloaded file.

Install pip by running:

python3 get-pip.py

From the terminal, use pip3 to install Matplotlib:

pip3 install matplotlib

How to Install Matplotlib on Linux Operating Systems

All major Linux distributions have Python installed by default. However, you will need to install pip. You can install pip from the terminal, but the installation instructions depend on the Linux distribution you are using. You will need root privileges to install pip. Open a terminal and use the commands relevant to your Linux distribution to install pip.

Installing pip for Ubuntu, Debian, and Linux Mint

sudo apt install python-pip3

Installing pip for CentOS 8 (and newer), Fedora, and Red Hat

sudo dnf install python-pip3

Installing pip for CentOS 6 and 7, and older versions of Red Hat

sudo yum install epel-release

sudo yum install python-pip3

Installing pip for Arch Linux and Manjaro

sudo pacman -S python-pip

Installing pip for OpenSUSE

sudo zypper python3-pip

Once you have installed pip, you can install Matplotlib using:

pip3 install matplotlib

Check Matplotlib Version

Once you have successfully installed Matplotlib, you can use two methods to check the version of Matplotlib. First, you can use pip show from your terminal. Remember that the name of the package is Matplotlib.

pip show matplotlib
Name: matplotlib
Version: 3.3.4
Summary: Python plotting package
Home-page: https://matplotlib.org

Second, within your python program, you can import Matlotlib and then reference the __version__ attribute:

import matplotlib

print(matplotlib.__version__)
3.3.4

Installing Matplotlib Using Anaconda

Anaconda is a distribution of Python and R for scientific computing and data science. You can install Anaconda by going to the installation instructions. Once you have installed Anaconda, you can install Matplotlib using the following command:

conda install -c conda-forge matplotlib

Importing matplotlib.pyplot

You can import the Pyplot API to create plots using the following lines in your program

import matplotlib.pyplot as plt

It is common to abbreviate the pyplot import to plt.

Summary

Congratulations on reading to the end of this tutorial. The modulenotfounderror occurs if you misspell the module name, incorrectly point to the module path or do not have the module installed in your Python environment. If you do not have the module installed in your Python environment, you can use pip to install the package. However, you must ensure you have pip installed on your system. You can also install Anaconda on your system and use the conda install command to install Matplotlib.

Go to the online courses page on Python to learn more about Python for data science and machine learning.

Have fun and happy researching!

0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии

А вот еще интересные материалы:

  • Яшка сломя голову остановился исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного где ошибка
  • Python manage py createsuperuser ошибка
  • Python int обработка ошибок