Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Matplotlib tutorial for beginner
| Date | Stars |
|---|---|
| 2026-07-24 | 3166 |
| 2026-07-25 | 3166 |
| 2026-07-28 | 3166 |
| 2026-07-30 | 3166 |
| 2026-08-06 | 3166 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day
===================
Matplotlib tutorial
===================
------------------
Nicolas P. Rougier
------------------
.. image:: https://zenodo.org/badge/doi/10.5281/zenodo.28747.svg
:target: http://dx.doi.org/10.5281/zenodo.28747
.. contents:: Table of Contents
:local:
:depth: 1
Sources are available from
`github <https://github.com/rougier/matplotlib-tutorial>`_
All code and material is licensed under a `Creative Commons
Attribution-ShareAlike 4.0
<http://creativecommons.org/licenses/by-sa/4.0>`_.
You can test your installation before the tutorial using the `check-installation.py <scripts/check-installation.py>`_ script.
See also:
* `From Python to Numpy <http://www.labri.fr/perso/nrougier/from-python-to-numpy/>`_
* `100 Numpy exercices <https://github.com/rougier/numpy-100>`_
* `Ten simple rules for better figures <http://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1003833>`_
Introduction
============
matplotlib is probably the single most used Python package for 2D-graphics. It
provides both a very quick way to visualize data from Python and
publication-quality figures in many formats. We are going to explore
matplotlib in interactive mode covering most common cases.
IPython
-------
`IPython <http://ipython.org/>`_ is an enhanced interactive Python shell that
has lots of interesting features including named inputs and outputs, access to
shell commands, improved debugging and much more. It allows
interactive matplotlib sessions that have Matlab/Mathematica-like functionality.
pyplot
------
pyplot provides a convenient interface to the matplotlib object-oriented
plotting library. It is modeled closely after Matlab(TM). Therefore, the
majority of plotting commands in pyplot have Matlab(TM) analogs with similar
arguments. Important commands are explained with interactive examples.
Simple plot
===========
In this section, we want to draw the cosine and sine functions on the same
plot. Starting from the default settings, we'll enrich the figure step by step
to make it nicer.
The first step is to get the data for the sine and cosine functions:
::
import numpy as np
X = np.linspace(-np.pi, np.pi, 256, endpoint=True)
C, S = np.cos(X), np.sin(X)
X is now a NumPy array with 256 values ranging from -π to +π (included). C is
the cosine (256 values) and S is the sine (256 values).
To run the example, you can download each of the examples and run it using::
$ python exercice_1.py
You can get source for each step by clicking on the corresponding figure.
Using defaults
--------------
.. admonition:: Documentation
* `plot tutorial <http://matplotlib.sourceforge.net/users/pyplot_tutorial.html>`_
* `plot() command <http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.plot>`_
.. image:: figures/exercice_1.png
:align: right
:target: scripts/exercice_1.py
Matplotlib comes with a set of default settings that allow customizing all
kinds of properties. You can control the defaults of almost every property in
matplotlib: figure size and dpi, line width, color and style, axes, axis and
grid properties, text and font properties and so on. While matplotlib defaults
are rather good in most cases, you may want to modify some properties for
specific cases.
.. include:: scripts/exercice_1.py
:code: python
:start-line: 4
Instantiating defaults
----------------------
.. admonition:: Documentation
* `Customizing matplotlib <http://matplotlib.sourceforge.net/users/customizing.html>`_
.. image:: figures/exercice_2.png
:align: right
:target: scripts/exercice_2.py
In the script below, we've instantiated (and commented) all the figure settings
that influence the appearance of the plot. The settings have been explicitly
set to their default values, but now you can interactively play with the values
to explore tExcerpt of 49,448 characters
Read on GitHubWould you bet a product on this? Bounded 0–100 and slow moving.
matched fp:8a85a20bd8a34902, topic:tutorial, name:tutorial, desc:tutorial