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 [2020/07/19 22:39] – [Références] villersd | teaching:progappchim:matplotlib_simple [2022/09/29 08:13] – [Références] 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://towardsdatascience.com/animations-with-matplotlib-d96375c5442c|Animations with Matplotlib]] FIXME | * [[https://towardsdatascience.com/animations-with-matplotlib-d96375c5442c|Animations with Matplotlib]] |
| * [[https://towardsdatascience.com/the-simplest-way-of-making-gifs-and-math-videos-with-python-aec41da74c6e|The easiest and fastest way to make GIFs and math videos with Python - How to create amazing animations in seconds using Celluloid]] Bruno Rodrigues, Medium, 13/10/2020 → [[https://github.com/jwkvam/celluloid]] |
* [[https://matplotlib.org/gallery/animation/rain.html]] | * [[https://matplotlib.org/gallery/animation/rain.html]] |
| |
* [[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://medium.com/python-in-plain-english/radar-chart-basics-with-pythons-matplotlib-ba9e002ddbcd|Radar Chart Basics with Python’s Matplotlib]] | * [[https://medium.com/python-in-plain-english/radar-chart-basics-with-pythons-matplotlib-ba9e002ddbcd|Radar Chart Basics with Python’s Matplotlib]] |
* [[https://towardsdatascience.com/matplotlib-who-said-it-needs-to-be-simple-7156df7c827b|Matplotlib — Who said it needs to be simple? - by Renan Lolico - Jun, 2020 - Towards Data Science]] | * [[https://towardsdatascience.com/matplotlib-who-said-it-needs-to-be-simple-7156df7c827b|Matplotlib — Who said it needs to be simple? - by Renan Lolico - Jun, 2020 - Towards Data Science]] |
| * [[https://medium.com/python-in-plain-english/line-chart-basics-with-pythons-matplotlib-e52032981bd3|Line Chart Basics with Python’s Matplotlib]] One of the most used and most effective ways of visualizing data |
| * [[https://towardsdatascience.com/5-powerful-tricks-to-visualize-your-data-with-matplotlib-16bc33747e05|5 Powerful Tricks to Visualize Your Data with Matplotlib]] - How to use LaTeX font, create zoom effect, outbox legend, continuous error, and adjust box pad margin - Towards Data Science, Medium, 29/09/2020 |
| * [[https://towardsdatascience.com/everything-about-plotting-in-python-c12ccdc359bc|Everything about plotting in Python - From matplotlib to pandas.plot()]] Medium, 17/07/2020 |
| * [[https://www.youtube.com/playlist?list=PL-osiE80TeTvipOqomVEeZ1HRrcEvtZB_|Matplotlib Tutorials]] 10 videos Youtube de Corey Schafer |
| * [[https://towardsdatascience.com/visualizations-with-matplotlib-part-1-c9651008b6b8|Python Data Visualization with Matplotlib — Part 1 - Completed Matplotlib tutorials for Python plotting from basic to advanced, with 90+ examples]], Medium, 20/10/2020 Rizky Maulana Nurhidayat |
| * [[https://becominghuman.ai/9-tips-and-tricks-for-better-visualization-in-matplotlib-301a2b475537|9 Tips and Tricks for Better Visualization in Matplotlib]] |
| * [[https://towardsdatascience.com/how-to-highlight-cells-in-matplotlib-tables-bd438cd4858a|How to Highlight Cells in Matplotlib Tables]] |
| * [[https://medium.com/swlh/creating-3d-video-visualization-with-matplotlib-python-data-visualization-series-d8f5dfe1c460|Create 3D Video Visualization With Matplotlib - A guide to visualize your 3D plot into a video]] |
| * [[https://towardsdatascience.com/stacked-bar-charts-with-pythons-matplotlib-f4020e4eb4a7|Stacked Bar Charts with Python’s Matplotlib - An excellent way to visualize proportions and composition]] Thiago Carvalho, 23/11/2020, Medium |
| * [[https://towardsdatascience.com/making-publication-quality-figures-in-python-part-i-fig-and-axes-d86c3903ad9b|Making publication-quality figures in Python (Part I): Fig and Axes]] (Guangyuan (Frank) Li, Medium, Jan, 2021) |
| * [[https://towardsdatascience.com/making-publication-quality-figures-in-python-part-ii-line-plot-legends-colors-4430a5891706|Making publication-quality figures in python (Part II): Line plot, Legends, Colors]] (Guangyuan (Frank) Li, Medium, Jan, 2021) |
| * [[https://towardsdatascience.com/making-publication-quality-figures-in-python-part-iii-box-plot-bar-plot-scatter-plot-407fa457449|Making publication-quality figures in Python (Part III): box plot, bar plot, scatter plot, histogram, heatmap, color map - Walking you through how to understand the mechanisms behind these widely-used figure types]] (Guangyuan (Frank) Li, Medium, Jan, 2021) |
| * [[https://towardsdatascience.com/making-publication-quality-figures-in-python-part-iv-violin-plot-and-dendrogram-ed0bb8b23ddd|Making publication-quality figures in Python (Part IV): Violin plot and dendrogram - Drawing violin plot and dendrogram from the scratch, a step-by-step guide]] (Guangyuan (Frank) Li, Medium, Jan, 2021) |
| * [[https://towardsdatascience.com/all-you-need-to-know-about-seaborn-6678a02f31ff|All you need to know about Seaborn - When should I use Seaborn versus matplotlib, and how to use it?]] (Guangyuan (Frank) Li, Medium, Jan, 2021) |
| * [[https://github.com/frankligy/python_visualization_tutorial|GitHub - frankligy/python_visualization_tutorial: A comprehensive guide of how to make publication-ready figures 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/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 |
| * [[https://towardsdatascience.com/4-things-to-know-to-have-a-better-understanding-of-matplotlib-a84ed54b3b2c|4 Things to Know to Have a Better Understanding of Matplotlib - Getting familiar with one of the original Python data visualization libraries]] Soner Yıldırım, 16/09/2022, Medium |
| - Figure and Axes |
| - Some things can be implicit |
| - Labels on Figure and Axes |
| - Figure with multiple Axes |
| * [[https://medium.com/codex/how-to-create-scientific-plots-using-matplotlib-python-and-latex-23a471c8bb69|How to Create Scientific Plots Using Matplotlib, Python, and LaTeX]] Berkay Kullukçu, Medium, 16/08/2022 |
| |
| |
| |
* [[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. |
| |