Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente Prochaine révisionLes deux révisions suivantes |
teaching:progappchim:matplotlib_simple [2021/01/11 12:30] – [Références] villersd | teaching:progappchim:matplotlib_simple [2022/05/12 14:47] – villersd |
---|
====== Les bases de Matplotlib, une librairie pour réaliser des graphiques 2D ====== | ====== Les bases de Matplotlib, une librairie pour réaliser des graphiques 2D ====== |
| |
[[http://matplotlib.org/|Matplotlib]] est une bibliothèque très puissante du langage de programmation Python destinée à tracer et visualiser des données sous formes de graphiques. Elle est souvent combinée avec les bibliothèques python de calcul scientifique : | [[https://matplotlib.org/stable/index.html/|Matplotlib]] est une bibliothèque très puissante du langage de programmation Python destinée à tracer et visualiser des données sous formes de graphiques. Elle est souvent combinée avec les bibliothèques python de calcul scientifique : |
* [[http://www.numpy.org/|NumPy]] : gestion de tableaux numériques multidimensionnels, algèbre linéaire, transformées de Fourier, nombres (pseudo-)aléatoires | * [[http://www.numpy.org/|NumPy]] : gestion de tableaux numériques multidimensionnels, algèbre linéaire, transformées de Fourier, nombres (pseudo-)aléatoires |
* [[http://scipy.org/scipylib/index.html|SciPy]] : méthodes numériques comme l'intégration ou l'optimisation | * [[http://scipy.org/scipylib/index.html|SciPy]] : méthodes numériques comme l'intégration ou l'optimisation |
Avec Matplotlib, on peut créer rapidement un graphe à partir de deux listes (voir le premier exemple ci-après). | Avec Matplotlib, on peut créer rapidement un graphe à partir de deux listes (voir le premier exemple ci-après). |
| |
Matplotlib permet de générer facilement des graphiques, camemberts ou autres histogrammes, intégrant symboles, barres d'erreur, éléments colorés,... Il peut créer pratiquement tous les types connus de graphiques (consulter la [[http://matplotlib.org/gallery.html|galerie d'exemples]]). | Matplotlib permet de générer facilement des graphiques, camemberts ou autres histogrammes, intégrant symboles, barres d'erreur, éléments colorés,... Il peut créer pratiquement tous les types connus de graphiques (consulter la [[https://matplotlib.org/stable/gallery/index.html|galerie d'exemples]]). |
| |
Le projet [[http://wiki.scipy.org/PyLab|Pylab]] vise à regrouper ces différentes librairies. De nombreuses commandes de Pylab ont été définies semblablement aux commandes du logiciel commercial [[http://fr.wikipedia.org/wiki/MATLAB|MatLab]]. | Le projet [[http://wiki.scipy.org/PyLab|Pylab]] vise à regrouper ces différentes librairies. De nombreuses commandes de Pylab ont été définies semblablement aux commandes du logiciel commercial [[http://fr.wikipedia.org/wiki/MATLAB|MatLab]]. |
| |
TODO : différences pyplot comme ici : https://towardsdatascience.com/5-quick-facts-about-python-matplotlib-53f23eab6d31 | TODO : différences pyplot comme ici : [[https://towardsdatascience.com/5-quick-facts-about-python-matplotlib-53f23eab6d31]] |
| |
===== Installation ===== | ===== Installation ===== |
%matplotlib inline | %matplotlib inline |
</code> | </code> |
| |
| ===== Régression linéaire ===== |
| * exemple simple : [[https://openwritings.net/pg/python/python-use-scipystatslinregress-get-linear-least-squares-regression-equation|Python - Use scipy.stats.linregress to get the linear least-squares regression equation]] |
| * voir aussi [[pandas]] |
| |
===== Animations ===== | ===== Animations ===== |
* [[https://github.com/thehackerwithin/PyTrieste/wiki/Python7-MatPlotLib|Un tutoriel en anglais]] | * [[https://github.com/thehackerwithin/PyTrieste/wiki/Python7-MatPlotLib|Un tutoriel en anglais]] |
* [[http://scipy-lectures.github.io/intro/matplotlib/matplotlib.html|Matplotlib: plotting]], par Nicolas Rougier, Mike Müller, Gaël Varoquaux (et la [[http://www.labri.fr/perso/nrougier/teaching/matplotlib/|version dérivée]] de Nicolas Rougier) | * [[http://scipy-lectures.github.io/intro/matplotlib/matplotlib.html|Matplotlib: plotting]], par Nicolas Rougier, Mike Müller, Gaël Varoquaux (et la [[http://www.labri.fr/perso/nrougier/teaching/matplotlib/|version dérivée]] de Nicolas Rougier) |
| * [[https://github.com/rougier/scientific-visualization-book|Scientific Visualization: Python & Matplotlib]] (Nicolas P. Rougier) |
* [[https://realpython.com/python-matplotlib-guide/|Python Plotting With Matplotlib (Guide)]], 2018 | * [[https://realpython.com/python-matplotlib-guide/|Python Plotting With Matplotlib (Guide)]], 2018 |
* [[http://www.thetechrepo.com/main-articles/465-how-to-create-a-graph-in-python.html]] | * [[http://www.thetechrepo.com/main-articles/465-how-to-create-a-graph-in-python.html]] |
* [[https://python-graph-gallery.com/|the Python Graph Gallery]], galerie de graphes Seaborn/Matplotlib avec code | * [[https://python-graph-gallery.com/|the Python Graph Gallery]], galerie de graphes Seaborn/Matplotlib avec code |
* [[https://medium.com/@neuralnets/statistical-data-visualization-series-with-python-and-seaborn-for-data-science-5a73b128851d|Data Visualization with Python and Seaborn]] | * [[https://medium.com/@neuralnets/statistical-data-visualization-series-with-python-and-seaborn-for-data-science-5a73b128851d|Data Visualization with Python and Seaborn]] |
| * [[https://medium.com/codex/a-reference-notebook-for-30-statistical-charts-in-seaborn-9da14b156ef9|A Reference Notebook for (+30) Statistical Charts in Seaborn]] Anello, Medium, 02/04/2021 |
| * [[https://medium.com/geekculture/8-best-seaborn-visualizations-20143a4b3b2f|8 Best Seaborn Visualizations - How to plot statistical graphs using the Python Seaborn library?]] Tirendaz Academy, Medium, 07/05/2022 |
* [[https://waterprogramming.wordpress.com/2016/04/29/interactive-plotting-basics-in-matplotlib/|Interactive plotting basics in matplotlib]] | * [[https://waterprogramming.wordpress.com/2016/04/29/interactive-plotting-basics-in-matplotlib/|Interactive plotting basics in matplotlib]] |
* [[https://heartbeat.fritz.ai/introduction-to-matplotlib-data-visualization-in-python-d9143287ae39|Introduction to Matplotlib — Data Visualization in Python]] | * [[https://heartbeat.fritz.ai/introduction-to-matplotlib-data-visualization-in-python-d9143287ae39|Introduction to Matplotlib — Data Visualization in Python]] |
* [[https://towardsdatascience.com/making-matplotlib-beautiful-by-default-d0d41e3534fd|Making Matplotlib Beautiful By Default - Use Seaborn to control Matplotlib defaults (and forget that shade of blue forever)]] Callum Ballard, Medium, 22/05/2020 | * [[https://towardsdatascience.com/making-matplotlib-beautiful-by-default-d0d41e3534fd|Making Matplotlib Beautiful By Default - Use Seaborn to control Matplotlib defaults (and forget that shade of blue forever)]] Callum Ballard, Medium, 22/05/2020 |
* [[https://towardsdatascience.com/creative-report-designed-only-with-matplotlib-without-office-software-9d8b5af4f9c2|Creative report designed only with Matplotlib, without office software]] Yefeng Xia, Medium, 04/01/2021 | * [[https://towardsdatascience.com/creative-report-designed-only-with-matplotlib-without-office-software-9d8b5af4f9c2|Creative report designed only with Matplotlib, without office software]] Yefeng Xia, Medium, 04/01/2021 |
| * [[https://towardsdatascience.com/texts-fonts-and-annotations-with-pythons-matplotlib-dfbdea19fc57|Texts, Fonts, and Annotations with Python’s Matplotlib - When and how to use texts in your data visualizations]] Thiago Carvalho, Medium, 21/01/2021 |
| * [[https://medium.com/dataseries/mastering-matplotlib-part-1-a480109171e3|Mastering Matplotlib: Part 1. Understanding Matplotlib Architecture...]] by Lawrence Alaso Krukrubo - DataSeries - Medium, 17/06/2020 |
| * [[https://medium.com/dataseries/mastering-matplotlib-part-2-a5114433fa0|Mastering Matplotlib: Part 2. Exploring Matplotlib-Pandas]] by Lawrence Alaso Krukrubo - DataSeries - Medium, 29/06/2020 |
| * [[https://levelup.gitconnected.com/matplotlib-ultimate-cheat-sheet-2021-2bcd1646f41e|Matplotlib Ultimate Cheat Sheet (2021) |
| The complete guide to Matplotlib in Python for your plotting needs]] Nathaniel J, 04/05/2021 |
| |
| |
* [[http://nbviewer.jupyter.org/url/jakevdp.github.com/downloads/notebooks/XKCD_plots.ipynb|XKCD plots in Matplotlib]] + [[http://nbviewer.jupyter.org/url/jakevdp.github.io/downloads/notebooks/XKCD_sketch_path.ipynb|ceci]] | * [[http://nbviewer.jupyter.org/url/jakevdp.github.com/downloads/notebooks/XKCD_plots.ipynb|XKCD plots in Matplotlib]] + [[http://nbviewer.jupyter.org/url/jakevdp.github.io/downloads/notebooks/XKCD_sketch_path.ipynb|ceci]] |
* [[https://github.com/naveenv92/python-science-tutorial|Python Science Tutorials]] Naveen Venkatesan, contains a series of scripts and notebooks to help people get acclimated to using Python for scientific publications. | * [[https://github.com/naveenv92/python-science-tutorial|Python Science Tutorials]] Naveen Venkatesan, contains a series of scripts and notebooks to help people get acclimated to using Python for scientific publications. |
| |