Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6a80fc4

Browse files
authored
Merge branch 'main' into pie-example
2 parents cce3b64 + 9c48e4b commit 6a80fc4

File tree

282 files changed

+986
-935
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

282 files changed

+986
-935
lines changed

.flake8

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ per-file-ignores =
8484
tutorials/introductory/quick_start.py: E703
8585
tutorials/introductory/animation_tutorial.py: E501
8686
tutorials/text/annotations.py: E402, E501
87+
tutorials/text/mathtext.py: E501
8788
tutorials/text/text_intro.py: E402
8889
tutorials/text/text_props.py: E501
8990
tutorials/text/usetex.py: E501

doc/devel/documenting_mpl.rst

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -812,9 +812,15 @@ to create a gallery of images in the :file:`/doc/gallery` and
812812
:file:`/doc/tutorials` directories respectively. To exclude an example
813813
from having an plot generated insert "sgskip" somewhere in the filename.
814814

815+
816+
Formatting the example
817+
----------------------
818+
815819
The format of these files is relatively straightforward. Properly
816820
formatted comment blocks are treated as ReST_ text, the code is
817-
displayed, and figures are put into the built page.
821+
displayed, and figures are put into the built page. Matplotlib uses the
822+
``# %%`` section separator so that IDEs will identify "code cells" to make
823+
it easy to re-run sub-sections of the example.
818824

819825
For instance the example :doc:`/gallery/lines_bars_and_markers/simple_plot`
820826
example is generated from
@@ -853,7 +859,7 @@ Tutorials are made with the exact same mechanism, except they are longer, and
853859
typically have more than one comment block (i.e.
854860
:doc:`/tutorials/introductory/quick_start`). The first comment block
855861
can be the same as the example above. Subsequent blocks of ReST text
856-
are delimited by a line of ``###`` characters:
862+
are delimited by the line ``# %%`` :
857863

858864
.. code-block:: python
859865
@@ -868,7 +874,7 @@ are delimited by a line of ``###`` characters:
868874
ax.grid()
869875
plt.show()
870876
871-
##########################################################################
877+
# %%
872878
# Second plot
873879
# ===========
874880
#
@@ -887,7 +893,7 @@ bottom as follows
887893

888894
.. code-block:: python
889895
890-
###############################################################################
896+
# %%
891897
#
892898
# .. admonition:: References
893899
#

doc/sphinxext/gallery_order.py

Lines changed: 47 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,52 @@
66
from sphinx_gallery.sorting import ExplicitOrder
77

88
# Gallery sections shall be displayed in the following order.
9-
# Non-matching sections are inserted at UNSORTED
10-
explicit_order_folders = [
11-
'../examples/lines_bars_and_markers',
12-
'../examples/images_contours_and_fields',
13-
'../examples/subplots_axes_and_figures',
14-
'../examples/statistics',
15-
'../examples/pie_and_polar_charts',
16-
'../examples/text_labels_and_annotations',
17-
'../examples/pyplots',
18-
'../examples/color',
19-
'../examples/shapes_and_collections',
20-
'../examples/style_sheets',
21-
'../examples/axes_grid1',
22-
'../examples/axisartist',
23-
'../examples/showcase',
24-
'../tutorials/introductory',
25-
'../tutorials/intermediate',
26-
'../tutorials/advanced',
27-
'../plot_types/basic',
28-
'../plot_types/arrays',
29-
'../plot_types/stats',
30-
'../plot_types/unstructured',
31-
'../plot_types/3D',
32-
'UNSORTED',
33-
'../examples/userdemo',
34-
'../tutorials/provisional',
35-
]
9+
# Non-matching sections are inserted at the unsorted position
10+
11+
UNSORTED = "unsorted"
12+
13+
examples_order = [
14+
'../examples/lines_bars_and_markers',
15+
'../examples/images_contours_and_fields',
16+
'../examples/subplots_axes_and_figures',
17+
'../examples/statistics',
18+
'../examples/pie_and_polar_charts',
19+
'../examples/text_labels_and_annotations',
20+
'../examples/pyplots',
21+
'../examples/color',
22+
'../examples/shapes_and_collections',
23+
'../examples/style_sheets',
24+
'../examples/axes_grid1',
25+
'../examples/axisartist',
26+
'../examples/showcase',
27+
UNSORTED,
28+
'../examples/userdemo',
29+
]
30+
31+
tutorials_order = [
32+
'../tutorials/introductory',
33+
'../tutorials/intermediate',
34+
'../tutorials/advanced',
35+
UNSORTED,
36+
'../tutorials/provisional'
37+
]
38+
39+
plot_types_order = [
40+
'../plot_types/basic',
41+
'../plot_types/arrays',
42+
'../plot_types/stats',
43+
'../plot_types/unstructured',
44+
'../plot_types/3D',
45+
UNSORTED
46+
]
47+
48+
folder_lists = [examples_order, tutorials_order, plot_types_order]
49+
50+
explicit_order_folders = [fd for folders in folder_lists
51+
for fd in folders[:folders.index(UNSORTED)]]
52+
explicit_order_folders.append(UNSORTED)
53+
explicit_order_folders.extend([fd for folders in folder_lists
54+
for fd in folders[folders.index(UNSORTED):]])
3655

3756

3857
class MplExplicitOrder(ExplicitOrder):
@@ -42,7 +61,7 @@ def __call__(self, item):
4261
if item in self.ordered_list:
4362
return f"{self.ordered_list.index(item):04d}"
4463
else:
45-
return f"{self.ordered_list.index('UNSORTED'):04d}{item}"
64+
return f"{self.ordered_list.index(UNSORTED):04d}{item}"
4665

4766
# Subsection order:
4867
# Subsections are ordered by filename, unless they appear in the following
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
pad_inches="layout" for savefig
2+
-------------------------------
3+
4+
When using constrained or compressed layout,
5+
6+
.. code-block:: python
7+
8+
savefig(filename, bbox_inches="tight", pad_inches="layout")
9+
10+
will now use the padding sizes defined on the layout engine.

examples/animation/animated_histogram.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
data = np.random.randn(1000)
2222
n, _ = np.histogram(data, HIST_BINS)
2323

24-
###############################################################################
24+
# %%
2525
# To animate the histogram, we need an ``animate`` function, which generates
2626
# a random set of numbers and updates the heights of rectangles. We utilize a
2727
# python closure to track an instance of `.BarContainer` whose `.Rectangle`
@@ -39,7 +39,7 @@ def animate(frame_number):
3939
return bar_container.patches
4040
return animate
4141

42-
###############################################################################
42+
# %%
4343
# Using :func:`~matplotlib.pyplot.hist` allows us to get an instance of
4444
# `.BarContainer`, which is a collection of `.Rectangle` instances. Calling
4545
# ``prepare_animation`` will define ``animate`` function working with supplied

examples/animation/multiple_axes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def animate(i):
7070

7171
plt.show()
7272

73-
#############################################################################
73+
# %%
7474
#
7575
# .. admonition:: References
7676
#

examples/axes_grid1/demo_axes_hbox_divider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
plt.show()
3535

36-
###############################################################################
36+
# %%
3737
# Using a `.VBoxDivider` to arrange subplots.
3838
#
3939
# Note that both axes' location are adjusted so that they have

examples/axes_grid1/demo_fixed_size_axes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from mpl_toolkits.axes_grid1 import Divider, Size
1010

11-
###############################################################################
11+
# %%
1212

1313

1414
fig = plt.figure(figsize=(6, 6))
@@ -26,7 +26,7 @@
2626

2727
ax.plot([1, 2, 3])
2828

29-
###############################################################################
29+
# %%
3030

3131

3232
fig = plt.figure(figsize=(6, 6))

examples/axes_grid1/inset_locator_demo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
"""
77

8-
###############################################################################
8+
# %%
99
# The `.inset_locator`'s `~.inset_locator.inset_axes` allows
1010
# easily placing insets in the corners of the axes by specifying a width and
1111
# height and optionally a location (loc) that accepts locations as codes,
@@ -43,7 +43,7 @@
4343
plt.show()
4444

4545

46-
###############################################################################
46+
# %%
4747
# The parameters *bbox_to_anchor* and *bbox_transform* can be used for a more
4848
# fine-grained control over the inset position and size or even to position
4949
# the inset at completely arbitrary positions.
@@ -100,7 +100,7 @@
100100
plt.show()
101101

102102

103-
###############################################################################
103+
# %%
104104
# In the above the axes transform together with 4-tuple bounding boxes has been
105105
# used as it mostly is useful to specify an inset relative to the axes it is
106106
# an inset to. However, other use cases are equally possible. The following

examples/axes_grid1/make_room_for_ylabel_using_axesgrid.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
make_axes_area_auto_adjustable(ax)
1919

20-
###############################################################################
20+
# %%
2121

2222
fig = plt.figure()
2323
ax1 = fig.add_axes([0, 0, 1, 0.5])
@@ -31,7 +31,7 @@
3131
make_axes_area_auto_adjustable(ax1, pad=0.1, use_axes=[ax1, ax2])
3232
make_axes_area_auto_adjustable(ax2, pad=0.1, use_axes=[ax1, ax2])
3333

34-
###############################################################################
34+
# %%
3535

3636
fig = plt.figure()
3737
ax1 = fig.add_axes([0, 0, 1, 1])

0 commit comments

Comments
 (0)