Skip to content

Commit bbebb16

Browse files
committed
Additional text and references for customization
1 parent 1836d78 commit bbebb16

File tree

1 file changed

+49
-11
lines changed

1 file changed

+49
-11
lines changed

tutorials/introductory/getting_started.py

+49-11
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,9 @@
256256
# Implicit: ``pyplot``
257257
# --------------------
258258
#
259-
# To use implicit programming for Matplotlib involves using the ``pyplot``
259+
# Implicit programming for Matplotlib centers around using the ``pyplot``
260260
# module. The Figure and Axes are automatically generated by the module.
261-
# Pass data through as arguments using methods within the module.
261+
# The methods and functions within the module take incoming data as arguments.
262262
# Additional parts of the Figure are also available through the module
263263
# methods.
264264

@@ -303,25 +303,28 @@
303303
# ==============
304304
#
305305
# There are two main parts to building a visualization with Matplotlib, the
306-
# `Figure`_ and the `Axes`_.
306+
# ``Figure`` and the ``Axes``.
307307
#
308308
# Components of Matplotlib Figure
309309
# -------------------------------
310310
#
311-
# The image below depicts each visible element of a Matplotlib graph.
312-
# **Note**: ``Figure`` and ``Axes`` identify empty regions of the diagram;
313-
# however, these elements are foundational in operation.
311+
# The image below depicts each visible element of a Matplotlib graph. The
312+
# graphic uses Matplotlib to display and highlight each individual part of the
313+
# visualization. The source code is available as :ref:`Anatomy-of-a-figure`.
314+
#
315+
# .. note::
316+
#
317+
# ``Figure`` and ``Axes`` identify empty regions of the diagram;
318+
# however, these elements are foundational in operation.
314319
#
315320
# .. image:: ../../_static/anatomy.png
316321
#
317322
# :class:`~matplotlib.figure.Figure`
318-
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
319323
#
320324
# The Figure is the working space for the programming. All visible
321325
# objects on a graph are located within the Figure.
322326
#
323327
# :class:`~matplotlib.axes.Axes`
324-
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
325328
#
326329
# Axes are subplots within the Figure. They contain Figure elements and
327330
# are responsible for plotting and configuring additional details. Each
@@ -331,7 +334,7 @@
331334
# Other Components
332335
# ^^^^^^^^^^^^^^^^
333336
#
334-
# * :class:`~matplotlib.artist.Artist`
337+
# :class:`~matplotlib.artist.Artist`
335338
#
336339
# Artists are the visible elements when the Figure is rendered. They
337340
# correspond to a specific Axes and cannot be shared or transferred.
@@ -352,7 +355,7 @@
352355
# Axes involved.
353356
#
354357
# When looking for more complex solutions to multiple graphs within a Figure,
355-
# use the GridSpec module to organize the layout.
358+
# use the :class:`matplotlib.gridspec.GridSpec` module to organize the layout.
356359
#
357360
# Explicit
358361
# ^^^^^^^^
@@ -363,7 +366,7 @@
363366
sharey='row',
364367
figsize=[8, 4],
365368
constrained_layout=True)
366-
# Figure and two Axes unpacked from arguments (1, 2) as row & column
369+
# Figure and two Axes unpacked from arguments (1, 2) as row & column.
367370
# Keyword arguments provide additional details of sharing Y-axis, Figure size
368371
# and layout formatting.
369372

@@ -462,6 +465,41 @@
462465
# Matplotlib auotmatically manages the specific Axes so that each action of
463466
# plotting data does not interfere with the previous instance.
464467
#
468+
# .. note::
469+
#
470+
# There are limitations for customizing the implicit approach without
471+
# referencing specific Axes and Artists within the Figure. For more
472+
# advanced configurations, the explicit approach is recommended.
473+
#
474+
# Generalized Function Guidelines
475+
# -------------------------------
476+
#
477+
# For users with that have recurring plots and graphs, the Matplotlib
478+
# community recommends a signature function similar to the format below.
479+
480+
481+
def my_plotter(ax, data1, data2, param_dict):
482+
"""
483+
Parameters
484+
----------
485+
:param ax: Axes
486+
:param data1: array of X data
487+
:param data2: array of Y data
488+
:param param_dict: Dictionary of keyword arguments to pass to method
489+
490+
Returns
491+
-------
492+
:returns: out : list of artists added
493+
"""
494+
out = ax.plot(data1, data2, **param_dict)
495+
# Note: Other methods from Axes class are also applicable.
496+
return out
497+
498+
##############################################################################
499+
#
500+
# .. currentmodule:: getting_started
501+
# .. autofunction:: my_plotter
502+
#
465503
# Additional Resources
466504
# ====================
467505
#

0 commit comments

Comments
 (0)