matplotlib

Форк
0
/
gallery_order.py 
125 строк · 4.0 Кб
1
"""
2
Configuration for the order of gallery sections and examples.
3
Paths are relative to the conf.py file.
4
"""
5

6
from 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

11
UNSORTED = "unsorted"
12

13
examples_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',
27
    UNSORTED,
28
    '../galleries/examples/userdemo',
29
]
30

31
tutorials_order = [
32
    '../galleries/tutorials/introductory',
33
    '../galleries/tutorials/intermediate',
34
    '../galleries/tutorials/advanced',
35
    UNSORTED,
36
    '../galleries/tutorials/provisional'
37
]
38

39
plot_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',
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):]])
55

56

57
class MplExplicitOrder(ExplicitOrder):
58
    """For use within the 'subsection_order' key."""
59
    def __call__(self, item):
60
        """Return a string determining the sort order."""
61
        if item in self.ordered_list:
62
            return f"{self.ordered_list.index(item):04d}"
63
        else:
64
            return 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

71
list_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
    ]
105
explicit_subsection_order = [item + ".py" for item in list_all]
106

107

108
class MplExplicitSubOrder(ExplicitOrder):
109
    """For use within the 'within_subsection_order' key."""
110
    def __init__(self, src_dir):
111
        self.src_dir = src_dir  # src_dir is unused here
112
        self.ordered_list = explicit_subsection_order
113

114
    def __call__(self, item):
115
        """Return a string determining the sort order."""
116
        if item in self.ordered_list:
117
            return f"{self.ordered_list.index(item):04d}"
118
        else:
119
            # ensure not explicitly listed items come last.
120
            return "zzz" + item
121

122

123
# Provide the above classes for use in conf.py
124
sectionorder = MplExplicitOrder(explicit_order_folders)
125
subsectionorder = MplExplicitSubOrder
126

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.