Docsity
Docsity

Prepare-se para as provas
Prepare-se para as provas

Estude fácil! Tem muito documento disponível na Docsity


Ganhe pontos para baixar
Ganhe pontos para baixar

Ganhe pontos ajudando outros esrudantes ou compre um plano Premium


Guias e Dicas
Guias e Dicas


matplotlib instuções, Resumos de Compiladores

muito bom demais , aprender a mecher no matplot lib e python cap 1 cap 2

Tipologia: Resumos

2020

Compartilhado em 26/09/2020

biruleibenana
biruleibenana 🇧🇷

1 documento

1 / 2371

Toggle sidebar

Esta página não é visível na pré-visualização

Não perca as partes importantes!

bg1
Matplotlib
Release 2.2.2
John Hunter, Darren Dale, Eric Firing, Michael Droettboom and the matplotlib development team
March 19, 2018
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Pré-visualização parcial do texto

Baixe matplotlib instuções e outras Resumos em PDF para Compiladores, somente na Docsity!

Matplotlib

Release 2.2.

John Hunter, Darren Dale, Eric Firing, Michael Droettboom and the ma

March 19, 2018

  • I User’s Guide
  • 1 History
  • 2 Installing
  • 3 Tutorials
  • 4 Interactive plots
  • 5 What’s new in Matplotlib
  • 6 GitHub Stats
  • 7 License
  • 8 Credits
  • II The Matplotlib FAQ
  • 9 Installation
  • 10 How-To
  • 11 Troubleshooting
  • 12 Environment Variables
  • 13 Working with Matplotlib in Virtual environments
  • 14 Working with Matplotlib on OSX
  • III Toolkits
  • 15 mplot3d
  • 16 axes_grid1
  • 17 axisartist
  • IV External Resources
  • 18 Books, Chapters and Articles
  • 19 Videos
  • 20 Tutorials
  • V Third party packages
  • 21 Mapping toolkits
  • 22 Declarative libraries
  • 23 Specialty plots
  • 24 Interactivity
  • 25 Miscellaneous
  • VI The Matplotlib API
  • 26 The Pyplot API
  • 27 The Object-Oriented API
  • 28 Colors in Matplotlib
  • 29 API Changes
  • 30 The top level matplotlib module
  • 31 afm (Adobe Font Metrics interface)
  • 32 animation
  • 33 artist Module
  • 34 Axes class
  • 35 axis and tick API
  • 36 backends
  • 37 cbook
  • 38 cm (colormap)
  • 39 collections
  • 40 colorbar
  • 41 colors
  • 42 contour
  • 43 container
  • 44 dates
  • 45 dviread
  • 46 figure
  • 47 font_manager
  • 48 gridspec
  • 49 image
  • 50 legend and legend_handler
  • 51 lines
  • 52 markers
  • 53 mathtext
  • 54 mlab
  • 55 offsetbox
  • 56 patches
  • 57 path
  • 58 patheffects
  • 59 projections
  • 60 rcsetup
  • 61 sankey
  • 62 scale
  • 63 spines
  • 64 style
  • 65 table
  • 66 text
  • 67 ticker
  • 68 tight_layout
  • 69 Working with transformations
  • 70 triangular grids
  • 71 type1font
  • 72 units
  • 73 widgets
  • 74 matplotlib.pyplot
  • 75 Toolkits
  • VII The Matplotlib Developers’ Guide
  • 76 Contributing
  • 77 Developer’s tips for testing
  • 78 Writing documentation
  • 79 Plot directive documentation
  • 80 Developer’s guide for creating scales and transformations
  • 81 Developer’s tips for writing code for Python 2 and
  • 82 Working with Matplotlib source code
  • 83 Reviewers guideline
  • 84 Release Guide
  • 85 Minimum Version of Dependencies Policy
  • 86 Matplotlib Enhancement Proposals
  • 87 Licenses
  • 88 Default Color changes
  • VIII Glossary
  • Bibliography
  • Python Module Index
  • Index

vi

CHAPTER

ONE

HISTORY

Note: The following introductory text was written in 2008 by John D. Hunter (1968-2012), the original author of Matplotlib.

Matplotlib is a library for making 2D plots of arrays in Python. Although it has its origins in emulating the MATLAB graphics commands, it is independent of MATLAB, and can be used in a Pythonic, object oriented way. Although Matplotlib is written primarily in pure Python, it makes heavy use of NumPy and other extension code to provide good performance even for large arrays. Matplotlib is designed with the philosophy that you should be able to create simple plots with just a few commands, or just one! If you want to see a histogram of your data, you shouldn’t need to instantiate objects, call methods, set properties, and so on; it should just work. For years, I used to use MATLAB exclusively for data analysis and visualization. MATLAB excels at mak- ing nice looking plots easy. When I began working with EEG data, I found that I needed to write applications to interact with my data, and developed an EEG analysis application in MATLAB. As the application grew in complexity, interacting with databases, http servers, manipulating complex data structures, I began to strain against the limitations of MATLAB as a programming language, and decided to start over in Python. Python more than makes up for all of MATLAB’s deficiencies as a programming language, but I was having difficulty finding a 2D plotting package (for 3D VTK more than exceeds all of my needs). When I went searching for a Python plotting package, I had several requirements:

  • Plots should look great - publication quality. One important requirement for me is that the text looks good (antialiased, etc.)
  • Postscript output for inclusion with TeX documents
  • Embeddable in a graphical user interface for application development
  • Code should be easy enough that I can understand it and extend it
  • Making plots should be easy Finding no package that suited me just right, I did what any self-respecting Python programmer would do: rolled up my sleeves and dived in. Not having any real experience with computer graphics, I decided to emulate MATLAB’s plotting capabilities because that is something MATLAB does very well. This had the added advantage that many people have a lot of MATLAB experience, and thus they can quickly get up to steam plotting in python. From a developer’s perspective, having a fixed user interface (the pylab interface) has been very useful, because the guts of the code base can be redesigned without affecting user code.

3

CHAPTER

TWO

INSTALLING

Note: If you wish to contribute to the project, it’s recommended you install the latest development version.

Contents

  • Installing
    • Installing an official release
      • Windows
      • macOS
      • Linux
      • Test Data
    • Third-party distributions of Matplotlib
      • Scientific Python Distributions
      • Linux : using your package manager
    • Installing from source
      • Dependencies
      • Building on Linux
      • Building on macOS
      • Building on Windows · Wheel builds using conda packages · Conda packages

5

Matplotlib, Release 2.2.

2.1 Installing an official release

Matplotlib and most of its dependencies are all available as wheel packages for macOS, Windows and Linux distributions: python -mpip install -U pip python -mpip install -U matplotlib

Note: The following backends work out of the box: Agg, ps, pdf, svg and TkAgg. For support of other GUI frameworks, LaTeX rendering, saving animations and a larger selection of file formats, you may need to install additional dependencies.

Although not required, we suggest also installing IPython for interactive use. To easily install a complete Scientific Python stack, see Scientific Python Distributions below.

2.1.1 Windows

In case Python 2.7 or 3.4 are not installed for all users, the Microsoft Visual C++ 2008 (64 bit or 32 bit for Python 2.7) or Microsoft Visual C++ 2010 (64 bit or 32 bit for Python 3.4) redistributable packages need to be installed.

2.1.2 macOS

If you are using Python 2.7 on a Mac you may need to do: xcode-select --install

so that subprocess32, a dependency, may be compiled. To use the native OSX backend you will need a framework build build of Python.

2.1.3 Linux

On extremely old versions of Linux and Python 2.7 you may need to install the master version of subpro- cess32 (see comments).

2.1.4 Test Data

The wheels (*.whl) on the PyPI download page do not contain test data or example code. If you want to try the many demos that come in the Matplotlib source distribution, download the *.tar.gz file and look in the examples subdirectory. To run the test suite:

  • extract the lib\matplotlib\tests or lib\mpl_toolkits\tests directories from the source dis- tribution;

6 Chapter 2. Installing

Matplotlib, Release 2.2.

We provide a setup.cfg file which you can use to customize the build process. For example, which default backend to use, whether some of the optional libraries that Matplotlib ships with are installed, and so on. This file will be particularly useful to those packaging Matplotlib. If you have installed prerequisites to nonstandard places and need to inform Matplotlib where they are, edit setupext.py and add the base dirs to the basedir dictionary entry for your sys.platform; e.g., if the header of some required library is in /some/path/include/someheader.h, put /some/path in the basedir list for your platform.

2.3.1 Dependencies

Matplotlib requires a large number of dependencies:

  • Python (>= 2.7 or >= 3.4)
  • NumPy (>= 1.7.1)
  • setuptools
  • dateutil (>= 2.1)
  • pyparsing
  • libpng (>= 1.2)
  • pytz
  • FreeType (>= 2.3)
  • cycler (>= 0.10.0)
  • six
  • backports.functools_lru_cache (for Python 2.7 only)
  • subprocess32 (for Python 2.7 only, on Linux and macOS only)
  • kiwisolver (>= 1.0.0) Optionally, you can also install a number of packages to enable better user interface toolkits. See What is a backend? for more details on the optional Matplotlib backends and the capabilities they provide.
  • tk (>= 8.3, != 8.6.0 or 8.6.1): for the TkAgg backend;
  • PyQt4 (>= 4.4) or PySide: for the Qt4Agg backend;
  • PyQt5: for the Qt5Agg backend;
  • pygtk (>= 2.4): for the GTK and the GTKAgg backend;
  • wxpython (>= 2.9 or later): for the WX or WXAgg backend;
  • cairocffi (>= v0.8): for cairo based backends;
  • pycairo: for GTK3Cairo;
  • Tornado: for the WebAgg backend;

8 Chapter 2. Installing

Matplotlib, Release 2.2.

For better support of animation output format and image file formats, LaTeX, etc., you can install the fol- lowing:

  • ffmpeg/avconv: for saving movies;
  • ImageMagick: for saving animated gifs;
  • Pillow (>=2.0): for a larger selection of image file formats: JPEG, BMP, and TIFF image files;
  • LaTeX and GhostScript (for rendering text with LaTeX).

Note: Matplotlib depends on a large number of non-Python libraries. pkg-config can be used to find required non-Python libraries and thus make the install go more smoothly if the libraries and headers are not in the expected locations.

Note: The following libraries are shipped with Matplotlib:

  • Agg: the Anti-Grain Geometry C++ rendering engine;
  • qhull: to compute Delaunay triangulation;
  • ttconv: a true type font utility.

2.3.2 Building on Linux

It is easiest to use your system package manager to install the dependencies. If you are on Debian/Ubuntu, you can get all the dependencies required to build Matplotlib with: sudo apt-get build-dep python-matplotlib

If you are on Fedora, you can get all the dependencies required to build Matplotlib with: sudo dnf builddep python-matplotlib

If you are on RedHat, you can get all the dependencies required to build Matplotlib by first installing yum-builddep and then running: su -c "yum-builddep python-matplotlib"

These commands do not build Matplotlib, but instead get and install the build dependencies, which will make building from source easier.

2.3.3 Building on macOS

The build situation on macOS is complicated by the various places one can get the libpng and FreeType requirements (MacPorts, Fink, /usr/X11R6), the different architectures (e.g., x86, ppc, universal), and the different macOS versions (e.g., 10.4 and 10.5). We recommend that you build the way we do for the macOS

2.3. Installing from source 9

Matplotlib, Release 2.2.

(continued from previous page) conda install pyqt

this package is only available in the conda-forge channel

conda install -c conda-forge msinttypes

for Python 2.

conda install -c conda-forge backports.functools_lru_cache

copy the libs which have "wrong" names

set LIBRARY_LIB=%CONDA_DEFAULT_ENV%\Library\lib mkdir lib || cmd /c "exit /b 0" copy %LIBRARY_LIB%\zlibstatic.lib lib\z.lib copy %LIBRARY_LIB%\libpng_static.lib lib\png.lib

Make the header files and the rest of the static libs available during the build

CONDA_DEFAULT_ENV is a env variable which is set to the currently active environment␣

↪→path set MPLBASEDIRLIST=%CONDA_DEFAULT_ENV%\Library;.

build the wheel

python setup.py bdist_wheel

The build_alllocal.cmd script in the root folder automates these steps if you have already created and activated the conda environment.

Conda packages

This needs a working installed C compiler for the version of Python you are compiling the package for but you don’t need to setup the environment variables:

only the first time...

conda install conda-build

the Python version you want a package for...

set CONDA_PY=3.

builds the package, using a clean build environment

conda build ci\conda_recipe

install the new package

conda install --use-local matplotlib

2.3. Installing from source 11

Matplotlib, Release 2.2.

12 Chapter 2. Installing