|
206 | 206 | # You may find older examples that use the ``pylab`` interface,
|
207 | 207 | # via ``from pylab import *``. This approach is strongly deprecated.
|
208 | 208 | #
|
209 |
| -# Making a helper functions |
210 |
| -# ------------------------- |
| 209 | +# Making helper functions |
| 210 | +# ----------------------- |
211 | 211 | #
|
212 | 212 | # If you need to make the same plots over and over again with different data
|
213 | 213 | # sets, or want to easily wrap Matplotlib methods, use the recommended
|
@@ -558,8 +558,29 @@ def my_plotter(ax, data1, data2, param_dict):
|
558 | 558 | # control the size. Finally, the colorbar will have default locators
|
559 | 559 | # and formatters appropriate to the norm. These can be changed as for
|
560 | 560 | # other Axis objects.
|
| 561 | + |
| 562 | +# %% |
| 563 | +# Patches |
| 564 | +# ======= |
561 | 565 | #
|
562 |
| -# |
| 566 | +# Patches are Artists with a face color and an edge color, which can be used to |
| 567 | +# draw arbitrary two dimensional regions. In addition to the more general |
| 568 | +# Polygon, there are wrappers and helpers for common shapes like Rectangles, |
| 569 | +# Circles, Boxes, Ellipses, and more. |
| 570 | + |
| 571 | +fig, ax = plt.subplots() |
| 572 | + |
| 573 | +polygon = mpl.patches.Polygon(np.array([[1, 0], [0.5, 1.5], [2, 1]]), closed=True) |
| 574 | +ax.add_patch(polygon) |
| 575 | + |
| 576 | +circle = mpl.patches.Circle((2, 2), 0.5, facecolor='orange', edgecolor='black') |
| 577 | +ax.add_patch(circle) |
| 578 | + |
| 579 | +ax.set_xlim(0, 3) |
| 580 | +ax.set_ylim(0, 3) |
| 581 | +ax.set_box_aspect(1) |
| 582 | + |
| 583 | +# %% |
563 | 584 | # Working with multiple Figures and Axes
|
564 | 585 | # ======================================
|
565 | 586 | #
|
@@ -588,3 +609,6 @@ def my_plotter(ax, data1, data2, param_dict):
|
588 | 609 | # For more plot types see :doc:`Plot types </plot_types/index>` and the
|
589 | 610 | # :doc:`API reference </api/index>`, in particular the
|
590 | 611 | # :doc:`Axes API </api/axes_api>`.
|
| 612 | +# |
| 613 | +# For more information on coordinate systems and transformations, see the |
| 614 | +# :ref:`transforms_tutorial`. |
0 commit comments