Book contents
- Frontmatter
- Contents
- Preface to the Second Edition
- Preface to the First Edition
- 1 Introduction
- 2 Getting Started with IPython
- 3 A Short Python Tutorial
- 4 NumPy
- 5 Two-Dimensional Graphics
- 6 Multi-Dimensional Graphics
- 7 SymPy: A Computer Algebra System
- 8 Ordinary Differential Equations
- 9 Partial Differential Equations: A Pseudospectral Approach
- 10 Case Study: Multigrid
- Appendix A Installing a Python Environment
- Appendix B Fortran77 Subroutines for Pseudospectral Methods
- References
- Hints for Using the Index
- Index
5 - Two-Dimensional Graphics
Published online by Cambridge University Press: 02 August 2017
- Frontmatter
- Contents
- Preface to the Second Edition
- Preface to the First Edition
- 1 Introduction
- 2 Getting Started with IPython
- 3 A Short Python Tutorial
- 4 NumPy
- 5 Two-Dimensional Graphics
- 6 Multi-Dimensional Graphics
- 7 SymPy: A Computer Algebra System
- 8 Ordinary Differential Equations
- 9 Partial Differential Equations: A Pseudospectral Approach
- 10 Case Study: Multigrid
- Appendix A Installing a Python Environment
- Appendix B Fortran77 Subroutines for Pseudospectral Methods
- References
- Hints for Using the Index
- Index
Summary
The most venerable and perhaps best-known scientific graphics package is Gnuplot, and downloads of this open-source project can be obtained from its website. The official documentation is Gnuplot Community (2016), some 250 pages, and a more descriptive introduction can be found in Janert (2015). Gnuplot is of course independent of Python. However, there is a NumPy interface to it, which provides Python-like access to the most commonly used Gnuplot functions. This is available on line. Although most scientific Python implementations install the relevant code as a matter of course, the documentation and example files from this online source are useful. For many applications requiring two-dimensional graphics, the output from Gnuplot is satisfactory, but only at its best is it of publication quality. Here Matlab has been, until recently, the market leader in this respect, but Python aims to equal or surpass it in quality and versatility.
The Matplotlib project aims to produce Matlab-quality graphics as an add-on to NumPy. Almost certainly, this should be part of your installation. It is installed by default in most Python packages designed for scientists. There is extensive “official documentation” (2842 pages) at Matplotlib Community (2016), and a useful alternative description in Tosi (2009). The reader is strongly urged to peruse the Matplotlib Gallery where a large collection of publication quality figures, and the code to generate them, is displayed. This is an excellent way (a) to explore the visual capabilities of Matplotlib and (b) to obtain code snippets to help create a desired figure. Because Matplotlib contains hundreds of functions, we can include here only a small subset. Note that almost all of the figures in this and subsequent chapters were generated using Matplotlib, and the relevant code snippets are included here. However the exigencies of book publishing have required the conversion of these colour figures to black, white and many shades of grey.
As with all other powerful versatile tools, a potential user is strongly encouraged to read the instruction manual, but at well over one thousand pages few scientific users will attempt to do so.
- Type
- Chapter
- Information
- Python for Scientists , pp. 82 - 108Publisher: Cambridge University PressPrint publication year: 2017