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