|
5 | 5 |
|
6 | 6 | Matplotlib's primary and universal API is the :ref:`Axes interface <api_interfaces>`. |
7 | 7 | While it is clearly structured and powerful, it can sometimes feel overly verbose and |
8 | | -thus cumbersome to write. This page collects patterns how to condense the code |
9 | | -of the Axes-based API and achieve the same results with less typing for many simpler |
| 8 | +thus cumbersome to write. This page collects patterns for condensing the code |
| 9 | +of the Axes-based API and achieving the same results with less typing for many simpler |
10 | 10 | plots. |
11 | 11 |
|
12 | 12 | .. note:: |
13 | 13 |
|
14 | 14 | The :ref:`pyplot interface <pyplot_interface>` is an alternative more compact |
15 | | - interface, and was historically modeled to be similar to MATLAB. It's remains a |
| 15 | + interface, and was historically modeled to be similar to MATLAB. It remains a |
16 | 16 | valid approach for those who want to use it. However, it has the disadvantage that |
17 | | - it achieves the brevity through implicit assumptions that you have to understand. |
| 17 | + it achieves its brevity through implicit assumptions that you have to understand. |
18 | 18 |
|
19 | 19 | Since it follows a different paradigm, switching between the Axes interface and |
20 | 20 | the pyplot interface requires a shift of the mental model, and some code rewrite, |
|
45 | 45 |
|
46 | 46 | # %% |
47 | 47 | # Note that we've included ``plt.show()`` here. This is needed to show the plot window |
48 | | -# when running from a commandline or in a python script. If you run a jupyter notebook, |
| 48 | +# when running from a command line or in a Python script. If you run a Jupyter notebook, |
49 | 49 | # this command is automatically executed at the end of each cell. |
50 | 50 | # |
51 | 51 | # For the rest of the tutorial, we'll assume that we are in a notebook and leave this |
|
57 | 57 | # Collect Axes properties into a single ``set()`` call |
58 | 58 | # ==================================================== |
59 | 59 | # |
60 | | -# The properties of Matplotlib Artists can be modified through the respective |
| 60 | +# The properties of Matplotlib Artists can be modified through their respective |
61 | 61 | # ``set_*()`` methods. Artists additionally have a generic ``set()`` method, that takes |
62 | 62 | # keyword arguments and is equivalent to calling all the respective ``set_*()`` methods. |
63 | 63 | # :: |
|
148 | 148 | # |
149 | 149 | # Using implicit figure creation |
150 | 150 | # ============================== |
151 | | -# You can go even further by taping into the pyplot logic and use `.pyplot.axes` to |
| 151 | +# You can go even further by tapping into the pyplot logic and use `.pyplot.axes` to |
152 | 152 | # create the axes: |
153 | 153 |
|
154 | 154 | ax = plt.axes(xlabel="day", ylabel="daylight hours", title="London") |
|
164 | 164 | # Not storing a reference to the Axes |
165 | 165 | # =================================== |
166 | 166 | # If you only need to visualize one dataset, you can append the plot command |
167 | | -# directly to the Axes creation. This may be useful e.g. in notebooks notebooks, |
| 167 | +# directly to the Axes creation. This may be useful e.g. in notebooks, |
168 | 168 | # where you want to create a plot with some configuration, but as little distracting |
169 | 169 | # code as possible: |
170 | 170 |
|
|
0 commit comments