Skip to content

Commit 817bf96

Browse files
committed
Resolving comments for getting_started.py
1 parent 56ae88e commit 817bf96

File tree

1 file changed

+53
-45
lines changed

1 file changed

+53
-45
lines changed

tutorials/introductory/getting_started.py

Lines changed: 53 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
# | Explicit, Object Oriented | Implicit, ``pyplot`` |
3333
# | Programming (OOP) | |
3434
# +====================================+====================================+
35-
# | Users explicitly create and manage | Automatically manages Figure and |
36-
# | all Figure elements. | Axes. |
35+
# | Users explicitly create and manage | The Matplotlib library implicitly |
36+
# | all Figure elements. | manages Figure and Axes. |
3737
# +------------------------------------+------------------------------------+
3838
# | Useful for repeated code use, | Helpful for quickly graphing data |
3939
# | generalization, robust | when using interactive |
@@ -55,7 +55,7 @@
5555
#
5656
# Implicit programming with ``pyplot`` is simpler. It is helpful for basic
5757
# plots and for interactive environments, such as Jupyter Notebooks. Users
58-
# familiar with MATLAB or wish to have Matplotlib create and manage parts of
58+
# familiar with MATLAB or wishing to have Matplotlib create and manage parts of
5959
# the visualization in state-based programming benefit from using ``pyplot``.
6060
# Using implicit programming acts as a convenient shortcut for generating
6161
# visualizations. New users to Matplotlib may experience difficulty
@@ -75,20 +75,21 @@
7575
# +====================================+====================================+
7676
# | :: | :: |
7777
# | | |
78-
# | fig, ax = plt.subplots() | plt.plot([1, 2, 3],[1, 2, 3]) |
79-
# | ax.plot([1, 2, 3],[1, 2, 3]) | |
78+
# | fig, ax = plt.subplots() | plt.plot([1, 2, 3], [1, 2, 3]) |
79+
# | ax.plot([1, 2, 3], [1, 2, 3]) | |
8080
# | | |
8181
# +------------------------------------+------------------------------------+
8282
# | `.pyplot.subplots` generates a | :mod:`matplotlib.pyplot` creates |
8383
# | `~.figure.Figure` and one or | implicit Figure and Axes if |
8484
# | more `~.axes.Axes` explicitly. | there are no pre-existing |
8585
# | `.Axes.plot` plots the data. | elements and `.pyplot.plot` plots |
86-
# | | the data. |
86+
# | | the data. This also plots over any |
87+
# | | existing Figure if applicable. |
8788
# +------------------------------------+------------------------------------+
8889
# | .. plot:: | .. plot:: |
8990
# | | |
90-
# | fig, ax = plt.subplots() | plt.plot([1,2,3],[1,2,3]) |
91-
# | ax.plot([1, 2, 3],[1, 2, 3]) | |
91+
# | fig, ax = plt.subplots() | plt.plot([1, 2, 3], [1, 2, 3]) |
92+
# | ax.plot([1, 2, 3], [1, 2, 3]) | |
9293
# | | |
9394
# +------------------------------------+------------------------------------+
9495
#
@@ -103,7 +104,7 @@
103104
# higher* is required. Depending on your operating system, Python may already
104105
# be installed on your machine.
105106
#
106-
# Installing Maptlotlib is required in order to generate graphs with the
107+
# Installing Matplotlib is required in order to generate graphs with the
107108
# library. Install Matplotlib for your own development environment manually or
108109
# use a third-party package distribution.
109110
#
@@ -140,7 +141,7 @@
140141
#
141142
# - The ``pyplot`` module in Matplotlib is a collection of functions. The
142143
# module's functions create, manage, and manipulate the current Figure and
143-
# the plotting area. The abbreviation as ``plt`` is the standard shortcut.
144+
# the plotting area. The ``plt`` abbreviation is the standard shortcut.
144145
#
145146

146147
import numpy as np
@@ -149,12 +150,14 @@
149150

150151
##############################################################################
151152
#
152-
# - NumPy is a common scientific Python library that benefits users with
153-
# additional tools for manipulating data.
153+
# - `NumPy <https://numpy.org/doc/stable/index.html#>`_ is a common scientific
154+
# Python library that benefits users working with numerical data.
154155
# - The ``functools`` module helps manage functions that act on or return
155156
# other functions. The `Pie Chart Examples`_ section note contains more
156157
# information about the purpose of this module.
157158
#
159+
#
160+
#
158161
# Two Approaches for Creating Graphs
159162
# ----------------------------------
160163
#
@@ -227,18 +230,19 @@
227230
# Explicit: Object Oriented Programming (OOP)
228231
# --------------------------------------------
229232
#
230-
# Explicit programming for Matplotlib involves calling the method ``subplots``
231-
# in the ``pyplot`` module once. This unpacks a group of an explicit Figure and
232-
# Axes. More than one Axes is configurable; however, each Axes only corresponds
233-
# to a single Figure.
233+
# Explicit programming for Matplotlib involves calling the function
234+
# `pyploy.subplots` in the ``pyplot`` module once. This returns a group of an
235+
# explicit Figure and Axes to be unpacked as part of variable assignment. More
236+
# than one Axes is configurable; however, each Axes only corresponds to a
237+
# single Figure.
234238
#
235239
# Each Axes has its own methods to graph data. In addition, each Axes
236-
# also uses separate methods to create and manage parts of a Figure. These
237-
# methods are different from those of the implicit programming approach.
240+
# also uses separate methods to create and manage objects within a Figure.
241+
# These methods are different from those of the implicit programming approach.
238242

239243
# Explicit programming with OOP
240244

241-
# Assigning sample data to labeled variables.
245+
# Assigning sample data to variables.
242246
x = months
243247
y1 = income
244248
y2 = chk_acct_09
@@ -266,24 +270,24 @@
266270

267271
##############################################################################
268272
#
269-
# The module ``pyplot`` for the OOP example unpacks the Figure and Axes.
270-
# This convention uses ``plt.subplots()`` and defaults to one Figure, ``fig``,
271-
# and one Axes, ``ax``. The variable names are common shorthand terms. Any
272-
# naming conventions also work.
273+
# The module ``pyplot`` for the explicit example uses a function that returns
274+
# the Figure and Axes. This convention uses ``plt.subplots()``. It defaults
275+
# to one Figure, ``fig``, and one Axes, ``ax``. The variable names are common
276+
# shorthand terms and any naming conventions also work.
273277
#
274278
# The `Configuration`_ section below contains additional information about
275279
# manipulating visuals, multiple visualizations, and other modifications.
276280
#
277281
# Using explicit programming allows for ``fig`` and ``ax`` to use separate
278-
# methods to manipulate the visualization. Specific Figures and Axes manage
279-
# data components with their own respective methods.
282+
# methods to manage objects within the visualization. Specific Figures and
283+
# Axes manage data components with their own respective methods.
280284
#
281285
#
282286
# Implicit: ``pyplot``
283287
# --------------------
284288
#
285289
# Implicit programming for Matplotlib centers around using the ``pyplot``
286-
# module. The module automatically generates Figure and Axes. Methods and
290+
# module. The module implicitly generates the Figure and Axes. Methods and
287291
# functions within the module take incoming data as arguments. Additional parts
288292
# of the Figure are also available through the module methods.
289293

@@ -307,7 +311,7 @@
307311

308312
##############################################################################
309313
#
310-
# In the example above, the ``pyplot`` module contains its own methods of
314+
# In the example above, the ``pyplot`` module contains its own functions of
311315
# actionable tasks for the data. The ``plt.plot`` plots data as a line graph
312316
# with various keyword arguments as customizable options. The module also
313317
# includes other methods for generating parts of the visualization. These parts
@@ -364,16 +368,20 @@
364368
#
365369
# :class:`~matplotlib.axes.Axes`
366370
#
367-
# Axes are subplots within the Figure. They contain Figure elements and
371+
# Axes are subplots within the Figure. They contain Matplotlib objects and
368372
# are responsible for plotting and configuring additional details. Each
369373
# Figure can contain multiple Axes, but each Axes is specific to one
370374
# Figure.
371375
#
372376
# In a Figure, each Axes contains any number of visual elements. Axes are
373377
# configurable for more than one type of visualization of data. From the
374378
# `Plotting`_ section above, the Axes in both explicit and implicit strategies
375-
# contain multiple types of visualizations of data on a single Axes. Each of
376-
# these types are specific to the Axes they are in.
379+
# contain multiple types of visualizations of data on a single Axes.
380+
381+
# Each of these types are specific to the Axes they are in. In the example, the
382+
# two plots each have one Axes. These Axes each have multiple plot lines. The
383+
# lines as objects are not shared between the two plots even though the data is
384+
# shared.
377385
#
378386
# Matplotlib Axes also integrate with other Python libraries. In Axes-based
379387
# interfaces, other libraries take an Axes object as input. Libraries such as
@@ -472,8 +480,8 @@
472480
# | | :doc:`/tutorials/text/annotations` |
473481
# +------------------------------+--------------------------------------------+
474482
#
475-
# For complete information about available methods for Artists, refer to the
476-
# table below.
483+
# For complete information about available methods for creating new Artists,
484+
# refer to the table below.
477485
#
478486
# +------------------------------------+------------------------------------+
479487
# | Explicit | Implicit |
@@ -594,7 +602,7 @@ def autopct_format(percent, group):
594602
#
595603
# The pie chart below adds configurations with keyword arguments for
596604
# ``explode``, ``autopct``, ``startangle``, and ``shadow``. These keyword
597-
# arguments help to manipulate the Artists.
605+
# arguments help to define the display of Artists.
598606

599607
# Explicit
600608

@@ -603,7 +611,7 @@ def autopct_format(percent, group):
603611
# The explode keyword argument uses explode variable data to separate
604612
# respective wedges from center.
605613
# The autopct keyword argument takes formatting strings and functions to
606-
# generate text within wedge. '%1.1f%%' is the string formatter.
614+
# generate text within each wedge. '%1.1f%%' is the string formatter.
607615
# The startangle keyword argument changes where first wedge spans. Angles start
608616
# at 0 degrees on X-axis and move counterclockwise.
609617
# The shadow keyword argument toggles a shadow on the visual.
@@ -676,8 +684,8 @@ def autopct_format(percent, group):
676684
ax.set_title('Average Monthly Income Expenses')
677685
ax.axis('equal')
678686

679-
# The Figure method tight_layout() manages space between all Artists to
680-
# maximize visiblity on Figure. This method also contains various
687+
# The Figure method tight_layout() adjusts spacing between all Artists to
688+
# maximize visiblity on the Figure. This method also contains various
681689
# parameters for configuration.
682690
fig.tight_layout()
683691

@@ -759,18 +767,18 @@ def autopct_format(percent, group):
759767
# the explicit approach refers to an explicitly generated Axes after creating
760768
# both the Figure and Axes.
761769
#
762-
# In the unpacking process, numerous Axes are assigned to a single variable.
770+
# In the unpacking process, multiple Axes are assigned to a single variable.
763771
# To reference a specific Axes, indexing the location of the respective Axes
764772
# as a matrix through the single variable works as well.
765773
#
766774
# The code below demonstrates indexing multiple Axes::
767775
#
768-
# fig, ax = plt.subplots(2,2)
776+
# fig, ax = plt.subplots(2, 2)
769777
#
770-
# ax[0,0].bar([1,2,3],[1,2,3])
771-
# ax[0,1].plot([3,2,1],[3,2,1])
778+
# ax[0,0].bar([1, 2, 3], [1, 2, 3])
779+
# ax[0,1].plot([3, 2, 1], [3, 2, 1])
772780
# ax[1,0].hist(hist_data)
773-
# ax[1,1].imshow([[1,2], [2,1]])
781+
# ax[1,1].imshow([[1, 2], [2, 1]])
774782
#
775783
#
776784
# The method `matplotlib.figure.Figure.subplot_mosaic` also generates Axes in
@@ -783,10 +791,10 @@ def autopct_format(percent, group):
783791
# ax_dict = fig.subplot_mosaic([['bar', 'plot'],
784792
# ['hist', 'image']])
785793
#
786-
# ax_dict['bar'].bar([1,2,3],[1,2,3])
787-
# ax_dict['plot'].plot([3,2,1],[3,2,1])
794+
# ax_dict['bar'].bar([1, 2, 3], [1, 2, 3])
795+
# ax_dict['plot'].plot([3, 2, 1], [3, 2, 1])
788796
# ax_dict['hist'].hist(hist_data)
789-
# ax_dict['image'].imshow([[1,2], [2,1]])
797+
# ax_dict['image'].imshow([[1, 2], [2, 1]])
790798
#
791799
# Implicit
792800
# ^^^^^^^^
@@ -816,7 +824,7 @@ def my_plotter(ax, data1, data2, param_dict):
816824
X data
817825
data2 : array
818826
Y data
819-
param_dict : dict()
827+
param_dict : dict
820828
Dictionary of keyword arguments passes to method
821829
822830
Returns

0 commit comments

Comments
 (0)