1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
"""
Configuration for the order of gallery sections and examples.
Paths are relative to the conf.py file.
"""
from sphinx_gallery.sorting import ExplicitOrder
# Gallery sections shall be displayed in the following order.
# Non-matching sections are inserted at the unsorted position
UNSORTED = "unsorted"
examples_order = [
'../galleries/examples/lines_bars_and_markers',
'../galleries/examples/images_contours_and_fields',
'../galleries/examples/subplots_axes_and_figures',
'../galleries/examples/statistics',
'../galleries/examples/pie_and_polar_charts',
'../galleries/examples/text_labels_and_annotations',
'../galleries/examples/color',
'../galleries/examples/shapes_and_collections',
'../galleries/examples/style_sheets',
'../galleries/examples/pyplots',
'../galleries/examples/axes_grid1',
'../galleries/examples/axisartist',
'../galleries/examples/showcase',
UNSORTED,
'../galleries/examples/userdemo',
]
tutorials_order = [
'../galleries/tutorials/introductory',
'../galleries/tutorials/intermediate',
'../galleries/tutorials/advanced',
UNSORTED,
'../galleries/tutorials/provisional'
]
plot_types_order = [
'../galleries/plot_types/basic',
'../galleries/plot_types/stats',
'../galleries/plot_types/arrays',
'../galleries/plot_types/unstructured',
'../galleries/plot_types/3D',
UNSORTED
]
folder_lists = [examples_order, tutorials_order, plot_types_order]
explicit_order_folders = [fd for folders in folder_lists
for fd in folders[:folders.index(UNSORTED)]]
explicit_order_folders.append(UNSORTED)
explicit_order_folders.extend([fd for folders in folder_lists
for fd in folders[folders.index(UNSORTED):]])
class MplExplicitOrder(ExplicitOrder):
"""For use within the 'subsection_order' key."""
def __call__(self, item):
"""Return a string determining the sort order."""
if item in self.ordered_list:
return f"{self.ordered_list.index(item):04d}"
else:
return f"{self.ordered_list.index(UNSORTED):04d}{item}"
# Subsection order:
# Subsections are ordered by filename, unless they appear in the following
# lists in which case the list order determines the order within the section.
# Examples/tutorials that do not appear in a list will be appended.
list_all = [
# **Tutorials**
# introductory
"quick_start", "pyplot", "images", "lifecycle", "customizing",
# intermediate
"artists", "legend_guide", "color_cycle",
"constrainedlayout_guide", "tight_layout_guide",
# advanced
# text
"text_intro", "text_props",
# colors
"colors",
# **Examples**
# color
"color_demo",
# pies
"pie_features", "pie_demo2",
# scales
"scales", # Scales overview
# **Plot Types
# Basic
"plot", "scatter_plot", "bar", "stem", "step", "fill_between",
# Arrays
"imshow", "pcolormesh", "contour", "contourf",
"barbs", "quiver", "streamplot",
# Stats
"hist_plot", "boxplot_plot", "errorbar_plot", "violin",
"eventplot", "hist2d", "hexbin", "pie",
# Unstructured
"tricontour", "tricontourf", "tripcolor", "triplot",
# Spines
"spines", "spine_placement_demo", "spines_dropped",
"multiple_yaxis_with_spines", "centered_spines_with_arrows",
]
explicit_subsection_order = [item + ".py" for item in list_all]
class MplExplicitSubOrder(ExplicitOrder):
"""For use within the 'within_subsection_order' key."""
def __init__(self, src_dir):
self.src_dir = src_dir # src_dir is unused here
self.ordered_list = explicit_subsection_order
def __call__(self, item):
"""Return a string determining the sort order."""
if item in self.ordered_list:
return f"{self.ordered_list.index(item):04d}"
else:
# ensure not explicitly listed items come last.
return "zzz" + item
# Provide the above classes for use in conf.py
sectionorder = MplExplicitOrder(explicit_order_folders)
subsectionorder = MplExplicitSubOrder
|