|
20 | 20 | # visualizations involve taking data and transforming it through functions and
|
21 | 21 | # methods.
|
22 | 22 | #
|
23 |
| -# There are two main ways of producing plots with Matplotlib, stateful and |
| 23 | +# There are two main ways of producing graphs with Matplotlib, stateful and |
24 | 24 | # stateless. Stateful code, using `pyplot`, or stateless code, using Object
|
25 | 25 | # Oriented Programming (OOP), are the foundation for creating and manipulating
|
26 | 26 | # data into visualizations.
|
|
34 | 34 | # Stateless programming, OOP, helps users generalize code and is useful for
|
35 | 35 | # repeated uses or larger projects. This is also a more robust way of
|
36 | 36 | # controlling customizations for visualizations. Users looking to have control
|
37 |
| -# over every part of the plot can call methods on each item. |
| 37 | +# over every part of the graph can call methods on each item. |
38 | 38 | #
|
39 | 39 | #
|
40 | 40 | #
|
|
45 | 45 | # Requirements
|
46 | 46 | # ============
|
47 | 47 | #
|
48 |
| -# Matplotlib is a Python library. Depending on your operating system, Python |
49 |
| -# may already be installed on your machine. |
| 48 | +# Matplotlib is a Python library and an installed version of Python 3.6 or |
| 49 | +# higher is required. Depending on your operating system, Python may already |
| 50 | +# be installed on your machine. |
50 | 51 | #
|
51 | 52 | # Installing Maptlotlib is required in order to generate plots with the
|
52 | 53 | # library. You can install Matplotlib for your own development environment(s)
|
53 | 54 | # or use a third-party package distribution.
|
54 | 55 | #
|
55 | 56 | # Third-party package distributions, such as
|
56 |
| -# `Anaconda <https://www.anaconda.com/>`_ |
57 |
| -# , `ActiveState <https://www.activestate.com/activepython/downloads>`_ |
58 |
| -# , or `WinPython <https://winpython.github.io/>`_, |
59 |
| -# already provide Matplotlib and its dependencies. These packages work as is |
60 |
| -# and do not require additional installations. |
| 57 | +# `Anaconda <https://www.anaconda.com/>`_, |
| 58 | +# `ActiveState <https://www.activestate.com/activepython/downloads>`_, |
| 59 | +# or `WinPython <https://winpython.github.io/>`_, |
| 60 | +# already provide Matplotlib and its dependencies. They have the added benefit |
| 61 | +# of including other scientific Python libraries as well. These packages work |
| 62 | +# as is and do not require additional installations. |
61 | 63 | #
|
62 | 64 | # Installation from source
|
63 | 65 | # ------------------------
|
64 | 66 | #
|
65 |
| -# The following command line executions use Python to install Matplotlib. |
| 67 | +# In order to install Matplotlib from the source directory, you can run the |
| 68 | +# following command line executions using Python and installer program `pip` |
| 69 | +# for the latest version of Matplotlib and its dependencies. This will compile |
| 70 | +# the library from the current directory on your machine. |
66 | 71 | #
|
67 |
| -# `python -m pip install -U pip` |
68 |
| -# `python -m pip install -U matplotlib` |
| 72 | +# `python -m pip install matplotlib` |
69 | 73 | #
|
70 | 74 | # Interactive environments
|
71 | 75 | # ------------------------
|
72 | 76 | #
|
73 |
| -# The Matplotlib community suggests using `IPython <https://ipython.org/>`_ as |
74 |
| -# the primary interactive environment. |
| 77 | +# The Matplotlib community suggests using `IPython <https://ipython.org/>`_ |
| 78 | +# through `Jupyter <https://jupyter.org/index.html>`_ as the primary |
| 79 | +# interactive environment. |
75 | 80 |
|
76 | 81 | ##############################################################################
|
77 | 82 | #
|
|
91 | 96 | # area.
|
92 | 97 | #
|
93 | 98 | # These are the two common strategies for creating plots with Matplotlib.
|
94 |
| -# - Stateful: The programming is designed to remember preceding events or |
95 |
| -# interactions. Matplotlib automatically manages figures and axes. |
96 |
| -# - `pyplot`, most similar to MATLAB and convenient for interactive |
97 |
| -# environments. |
98 |
| -# - Stateless: Code has explicit references to objects. Users create objects |
99 |
| -# for specific figures and axes and call on methods for manipulating data. |
100 |
| -# - Object-oriented programming (OOP), robust control and useful for |
101 |
| -# generalized code. |
| 99 | +# |
| 100 | +# * Stateful: The programming is designed to remember preceding events or |
| 101 | +# interactions. Matplotlib automatically manages figures and axes. |
| 102 | +# * `pyplot`, most similar to MATLAB and convenient for interactive |
| 103 | +# environments. |
| 104 | +# * Stateless: Code has explicit references to objects. Users create objects |
| 105 | +# for specific figures and axes and call on methods for manipulating data. |
| 106 | +# * Object-oriented programming (OOP), robust control and useful for |
| 107 | +# generalized code. |
102 | 108 | #
|
103 | 109 | # .. note::
|
104 | 110 | #
|
|
138 | 144 | #
|
139 | 145 | # .. note::
|
140 | 146 | #
|
141 |
| -# Other containers, such as `pandas` data objects, may not work as intended. |
| 147 | +# Other containers, such as `pandas` data objects, may not work as |
| 148 | +# intended. |
142 | 149 | #
|
143 | 150 | # Stateful: `pyplot`
|
144 | 151 | # ------------------
|
|
179 | 186 | # of the `pyplot` module to unpack a set or sets of explicit figure and axes.
|
180 | 187 | # Each axes has its own methods to plot data. In addition, each axes also
|
181 | 188 | # uses separate methods to create and manage parts of a figure. These methods
|
182 |
| -# are different from those using stateful programming. |
| 189 | +# are different from those of the stateful programming approach. |
183 | 190 |
|
184 | 191 | # Stateless programming with OOP
|
185 | 192 |
|
|
200 | 207 | #
|
201 | 208 | # For the OOP example, the figure and axes are unpacked from the module using
|
202 | 209 | # a single instance of `pyplot`. This convention uses `plt.subplots()` and
|
203 |
| -# defaults to one figure,`fig`, and one axes, `ax`. The section below on |
| 210 | +# defaults to one figure, `fig`, and one axes, `ax`. The section below on |
204 | 211 | # customizations contains additional information about multiple visulizations
|
205 | 212 | # and other modifications.
|
206 | 213 | #
|
207 | 214 | # Using the OOP approach allows for `fig` and `ax` to use separate methods to
|
208 |
| -# manipulate the visualization. Instead of using the module `pyplot` for each |
209 |
| -# instance of managing the objects, the specfic axes refers to OOP usage and |
210 |
| -# manages data |
| 215 | +# manipulate the visualization. Instead of using the module `pyplot` for all |
| 216 | +# instances of managing objects, the specfic axes refers to OOP usage and |
| 217 | +# manages the respective data. |
211 | 218 | #
|
212 | 219 | # .. note::
|
213 | 220 | #
|
214 |
| -# The names and spelling for methods may be similar for both `pyplot` and OOP |
215 |
| -# approaches. Errors may occur when using the wrong corresponding method. |
216 |
| -# Confirm with documentation API for specific method names. |
| 221 | +# The names and spelling for methods may be similar for both `pyplot` and |
| 222 | +# OOP approaches. Errors may occur when using the wrong corresponding |
| 223 | +# method. Confirm with the documentation API for specific method names |
| 224 | +# according to your programming. |
217 | 225 |
|
218 | 226 | ##############################################################################
|
219 | 227 | #
|
|
226 | 234 | # Components of Matplotlib Figure
|
227 | 235 | # -------------------------------
|
228 | 236 | #
|
229 |
| -# This |
| 237 | +# The image below depicts each visible element of a Matplotlib graph. |
| 238 | +# |
| 239 | +# * Figure |
| 240 | +# * Axes |
| 241 | +# * Axis |
| 242 | +# * Artist(s) |
0 commit comments