ebook img

Scientific Visualization: Python + Matplotlib PDF

249 Pages·2021·19.95 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Scientific Visualization: Python + Matplotlib

HAL Id: hal-03427242 https://hal.inria.fr/hal-03427242 Submitted on 13 Nov 2021 HAL is a multi-disciplinary open access archive for the deposit and dissemination of sci- entific research documents, whether they are pub- lished or not. The documents may come from teaching and research institutions in France or abroad, or from public or private research centers. L’archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d’enseignement et de recherche français ou étrangers, des laboratoires publics ou privés. Distributed under a Creative Commons Attribution - NonCommercial - ShareAlike| 4.0 International License Scientific Visualization: Python + Matplotlib Nicolas Rougier To cite this version: Nicolas Rougier. Scientific Visualization: Python + Matplotlib. Nicolas P. Rougier. 2021, 978-2- 9579901-0-8. hal-03427242 S C I E N T I F I C P Y T H O N V O L U M E I I S C I E N T I F I C V I S U A L I Z AT I O N P Y T H O N & M A T P L O T L I B N I C O L A S P. R O U G I E R ii SCıENTıFıC VıſUALıſATıON, PYTHON & MATPLOTLıB Copyright © 2021 Nicolas P. Rougier. Some rights reserved. This volume is licensed under a Creative Commons Attribution Non‐Commercial Share‐ Alike 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license, and indicate if changes were made. You may not use the material for commercial purposes. If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original. To learn more, visit creativecommons.org . First Edition: November 2021. ISBN 978‐2‐9579901‐0‐8 This book is typeset in Roboto, Source Serif Pro & Source Code pro. It has been written in re‐ StructuredText, converted to LATEX using docutils and exported to Portable Document Format using X E LATEX. Printing: 1 2 3 4 5 6 7 8 9 10 Scientific Visualisation Python & Matplotlib NıCOLAſ P. ROUGıER SCıENTıFıC PYTHON – VOLUME II ii In memory of John D. Hunter (1968 — 2012), creator of the Matplotlib library & Maxim Shemanarev (1966 — 2013), creator of the antigrain geometry library. Two brilliant minds that are dearly missed. Contents Preface ix Acknowledgments xiii Introduction xvii I Fundamentals 1 Anatomy of a figure 3 2 Coordinate systems 19 3 Scales & projections 33 4 Elements of typography 45 5 A primer on colors 55 II Figure design 6 Ten simple rules 71 7 Mastering the defaults 85 8 Size, aspect & layout 95 9 Ornaments 109 III Advanced concepts 10 Animation 121 11 Going 3D 135 12 Architecture & optimization 149 13 Graphic library 159 vi CONTENTS IV Showcase Filled contours with dropshadows 177 Domain coloring 179 Escher like projections 181 Self-organizing maps 183 Waterfall plots 185 Streamlines 187 Mandelbrot set 189 Recursive Voronoi 191 3D Heightmap 193 Voronoi mosaic 195 Text shadow 197 Text spiral 199 V Conclusion VI Appendix A External resources 207 B Quick References 211 Bibliography 221 CONTENTS vii Preface About the author Nicolas P. Rougier is a full‐time researcher in computational cognitive neuroscience, located in Bordeaux, France. He’s doing his research at Inria (the French institute for computer science) and the Institute of Neu‐ rodegenerative Diseases where he investigates decision making, learning and cognition using computational models of the brain and distributed, numerical and adaptive computing, a.k.a. artificial neural networks and machine learning. His research aims to irrigate the fields of philosophy with regard to the mind‐body problem, medicine to account for the nor‐ mal and pathological functioning of the brain and the digital sciences to offer alternative computing paradigms. Beside neuroscience and philos‐ ophy, he’s also interested in open and reproducible science (he has co‐ founded ReScience C with Konrad Hinsen and ReScience X with Etienne Roesch), scientific visualization (he created glumpy, co‐created VisPy), Science outreach (e.g. The Conversation) and computer graphics (espe‐ cially digital typography). Nicolas P. Rougier has been using Python for more than 20 years and Mat‐ plotlib for more than 15 years for modeling in neuroscience, machine learning and for advanced visualization. Nicolas P. Rougier is the author of several online resources and tutorials and he’s teaching Python, NumPy and scientific visualisation at the University of Bordeaux as well as at var‐ ious conferences and schools worldwide. x Preface About this book This open access book has been written in reStructuredText converted to LaTeX using docutils and exported to Portable Document Format using XeLaTeX. Sources are available at github.com/rougier/python‐scientific‐ visualisation How to contribute If you want to contribute to this book, you can: • Review chapters & suggest improvements • Report issues & correct my English • Star the project on GitHub & buy the printed book Prerequisites This book is not a Python beginner guide and you should have an interme‐ diate level in Python and ideally a beginner level in NumPy. If this is not the case, have a look at the bibliography for a curated list of resources. Conventions We will use usual naming conventions. If not stated explicitly, each script should import NumPy, SciPy and Matplotlib as: import scipy import numpy as np import matplotlib.pyplot as plt We’ll use up‐to‐date versions (at the date of writing, June 2019) of the dif‐ ferent packages: >>> import sys; print(sys.version) 3.7.4 (default, Jul 9 2019, 18:13:23) [Clang 10.0.1 (clang-1001.0.46.4)] >>> import numpy; print(numpy.__version__) 1.16.4 >>> import scipy; print(scipy.__version__) 1.3.0 >>> import matplotlib; print(matplotlib.__version__) 3.1.0 Preface xi License This volume is is licensed under a Creative Commons Attribution Non Commercial Share Alike 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or for‐ mat, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license, and indicate if changes were made. You may not use the material for commercial pur‐ poses. If you remix, transform, or build upon the material, you must dis‐ tribute your contributions under the same license as the original. To learn more, visit creativecommons.org . Unless stated otherwise, all the figures are licensed under a Creative Com‐ mons Attribution 4.0 International License and all the code is licensed under a BSD 2‐clause license. xii Preface

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.