




























































































Estude fácil! Tem muito documento disponível na Docsity
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Prepare-se para as provas
Estude fácil! Tem muito documento disponível na Docsity
Prepare-se para as provas com trabalhos de outros alunos como você, aqui na Docsity
Encontra documentos específicos para os exames da tua universidade
Prepare-se com as videoaulas e exercícios resolvidos criados a partir da grade da sua Universidade
Responda perguntas de provas passadas e avalie sua preparação.
Ganhe pontos para baixar
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
muito bom demais , aprender a mecher no matplot lib e python cap 1 cap 2
Tipologia: Resumos
1 / 2371
Esta página não é visível na pré-visualização
Não perca as partes importantes!





























































































March 19, 2018
vi
CHAPTER
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:
3
CHAPTER
Note: If you wish to contribute to the project, it’s recommended you install the latest development version.
Contents
5
Matplotlib, Release 2.2.
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:
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:
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:
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:
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
conda install -c conda-forge msinttypes
conda install -c conda-forge backports.functools_lru_cache
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
↪→path set MPLBASEDIRLIST=%CONDA_DEFAULT_ENV%\Library;.
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:
conda install conda-build
set CONDA_PY=3.
conda build ci\conda_recipe
conda install --use-local matplotlib
2.3. Installing from source 11
Matplotlib, Release 2.2.
12 Chapter 2. Installing