Skip to content

Commit 9c48e4b

Browse files
authored
Merge pull request matplotlib#25021 from tacaswell/doc/sg_splitter
Doc: sg section separator
2 parents be7ea76 + e5f0066 commit 9c48e4b

File tree

272 files changed

+835
-829
lines changed

Some content is hidden

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

272 files changed

+835
-829
lines changed

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
#

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])

examples/axes_grid1/scatter_hist_locatable_axes.py

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

6464
plt.show()
6565

66-
#############################################################################
66+
# %%
6767
#
6868
# .. admonition:: References
6969
#

examples/axes_grid1/simple_axes_divider1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def label_axes(ax, text):
1818
left=False, labelleft=False)
1919

2020

21-
##############################################################################
21+
# %%
2222
# Fixed axes sizes; fixed paddings.
2323

2424
fig = plt.figure(figsize=(6, 6))
@@ -42,7 +42,7 @@ def label_axes(ax, text):
4242
ax4 = fig.add_axes(rect, axes_locator=div.new_locator(nx=2, nx1=4, ny=0))
4343
label_axes(ax4, "nx=2, nx1=4, ny=0")
4444

45-
##############################################################################
45+
# %%
4646
# Axes sizes that scale with the figure size; fixed paddings.
4747

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

examples/axisartist/demo_floating_axes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def setup_axes3(fig, rect):
145145
return ax1, aux_ax
146146

147147

148-
##########################################################
148+
# %%
149149
fig = plt.figure(figsize=(8, 4))
150150
fig.subplots_adjust(wspace=0.3, left=0.05, right=0.95)
151151

0 commit comments

Comments
 (0)