diff --git a/altair/sphinxext/altairgallery.py b/altair/sphinxext/altairgallery.py index dfb1bd985..0c0166b40 100644 --- a/altair/sphinxext/altairgallery.py +++ b/altair/sphinxext/altairgallery.py @@ -160,6 +160,7 @@ class AltairMiniGalleryDirective(Directive): has_content = False option_spec = {'size': int, + 'names': str, 'indices': lambda x: list(map(int, x.split())), 'shuffle': flag, 'seed': int, @@ -168,6 +169,7 @@ class AltairMiniGalleryDirective(Directive): def run(self): size = self.options.get('size', 15) + names = [name.strip() for name in self.options.get('names', '').split(',')] indices = self.options.get('indices', []) shuffle = 'shuffle' in self.options seed = self.options.get('seed', 42) @@ -181,13 +183,20 @@ def run(self): examples = populate_examples() - if indices: - examples = [examples[i] for i in indices] - if shuffle: - random.seed(seed) - random.shuffle(examples) - if size: - examples = examples[:size] + if names: + if len(names) < size: + raise ValueError("altair-minigallery: if names are specified, " + "the list must be at least as long as size.") + mapping = {example['name']: example for example in examples} + examples = [mapping[name] for name in names] + else: + if indices: + examples = [examples[i] for i in indices] + if shuffle: + random.seed(seed) + random.shuffle(examples) + if size: + examples = examples[:size] include = MINIGALLERY_TEMPLATE.render(image_dir='/_static', gallery_dir=gallery_dir, diff --git a/altair/vegalite/v2/examples/mutli_series_line.py b/altair/vegalite/v2/examples/multi_series_line.py similarity index 100% rename from altair/vegalite/v2/examples/mutli_series_line.py rename to altair/vegalite/v2/examples/multi_series_line.py diff --git a/doc/index.rst b/doc/index.rst index 72293891d..bfdc8b70e 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -2,9 +2,8 @@ Altair: Declarative Visualization in Python =========================================== .. altair-minigallery:: + :names: one_dot_per_zipcode, horizon_graph, world_projections, candlestick_chart, falkensee, scatter_linked_brush, layered_heatmap_text, natural_disasters, streamgraph, multiline_tooltip, select_detail, choropleth, interactive_cross_highlight, seattle_weather_interactive, london_tube :size: 15 - :shuffle: - :seed: 31415 Altair is a declarative statistical visualization library for Python, based on Vega_ and Vega-Lite_, and the source is available on