|
131 | 131 | # Coding styles
|
132 | 132 | # =============
|
133 | 133 | #
|
134 |
| -# The explicit and the implicit approach of programming |
135 |
| -# ----------------------------------------------------- |
| 134 | +# The object-oriented and the pyplot interfaces |
| 135 | +# --------------------------------------------- |
136 | 136 | #
|
137 | 137 | # As noted above, there are essentially two ways to use Matplotlib:
|
138 | 138 | #
|
139 |
| -# - Explicitly create Figures and Axes, and call methods on them (the explicit |
140 |
| -# or "object oriented programming (OOP) style"). |
| 139 | +# - Explicitly create Figures and Axes, and call methods on them (the |
| 140 | +# "object-oriented (OO) style"). |
141 | 141 | # - Rely on pyplot to automatically create and manage the Figures and Axes, and
|
142 |
| -# use pyplot functions for plotting (the implicit style). |
| 142 | +# use pyplot functions for plotting. |
143 | 143 | #
|
144 |
| -# So one can use the explicit style |
| 144 | +# So one can use the OO-style |
145 | 145 |
|
146 | 146 | x = np.linspace(0, 2, 100) # Sample data.
|
147 | 147 |
|
148 |
| -# Note that even in the explicit style, we use `.pyplot.figure` to create the |
149 |
| -# Figure. |
| 148 | +# Note that even in the OO-style, we use `.pyplot.figure` to create the Figure. |
150 | 149 | fig, ax = plt.subplots(figsize=(5, 2.7), layout='constrained')
|
151 | 150 | ax.plot(x, x, label='linear') # Plot some data on the axes.
|
152 | 151 | ax.plot(x, x**2, label='quadratic') # Plot more data on the axes...
|
|
157 | 156 | ax.legend(); # Add a legend.
|
158 | 157 |
|
159 | 158 | ###############################################################################
|
160 |
| -# or the implicit style: |
| 159 | +# or the pyplot-style: |
161 | 160 |
|
162 | 161 | x = np.linspace(0, 2, 100) # Sample data.
|
163 | 162 |
|
|
176 | 175 | # figure creation. See the corresponding section in the gallery for more info:
|
177 | 176 | # :ref:`user_interfaces`.)
|
178 | 177 | #
|
179 |
| -# Matplotlib's documentation and examples use both the explicit and the |
180 |
| -# implicit styles. In general, we suggest using the explicit style, |
181 |
| -# particularly for complicated plots, and functions and scripts that are |
182 |
| -# intended to be reused as part of a larger project. However, the implicit |
183 |
| -# style can be very convenient for quick interactive work. |
| 178 | +# Matplotlib's documentation and examples use both the OO and the pyplot |
| 179 | +# styles. In general, we suggest using the OO style, particularly for |
| 180 | +# complicated plots, and functions and scripts that are intended to be reused |
| 181 | +# as part of a larger project. However, the pyplot style can be very convenient |
| 182 | +# for quick interactive work. |
184 | 183 | #
|
185 | 184 | # .. note::
|
186 | 185 | #
|
|
0 commit comments