.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_interactive_arxiv_ml_widgets.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_plot_interactive_arxiv_ml_widgets.py: Interactive ArXiv ML with Custom Widget Layout ---------------------------------------------- Demonstrating the widget system with custom widget placement using the ArXiv ML data map. This example shows how to: - Use widget classes to create custom layouts - Place widgets in corners and drawers - Create a custom layout for data exploration For a full size version see https://lmcinnes.github.io/datamapplot_examples/ArXiv_data_map_example.html .. GENERATED FROM PYTHON SOURCE LINES 16-78 .. raw:: html


.. code-block:: Python import numpy as np import datamapplot from datamapplot import TitleWidget, SearchWidget, LogoWidget # Load the data arxivml_data_map = np.load("arxiv_ml_data_map.npz")["arr_0"] arxivml_label_layers = [] for layer_num in range(5): arxivml_label_layers.append( np.load(f"arxiv_ml_layer{layer_num}_cluster_labels.npz", allow_pickle=True)[ "arr_0" ] ) arxivml_hover_data = np.load("arxiv_ml_hover_data.npz", allow_pickle=True)["arr_0"] # Define custom widget layout # - Title in top-left corner # - Search in left drawer (accessible via Ctrl+[ or clicking left edge) # - Logo in bottom-right corner # # Widgets are created using widget classes with location parameter to control placement. # Note: darkmode=True should be passed to widgets that need to adapt their colors. widgets = [ TitleWidget( title="ArXiv ML Landscape", sub_title="Explore ML papers with custom widget layout", title_font_size=32, location="top-left", order=0, darkmode=True, # Match the plot's darkmode setting ), SearchWidget( search_field="hover_text", location="drawer-left", order=0, ), LogoWidget( logo="https://upload.wikimedia.org/wikipedia/commons/thumb/b/bc/ArXiv_logo_2022.svg/512px-ArXiv_logo_2022.svg.png", logo_width=128, location="bottom-right", order=0, ), ] plot = datamapplot.create_interactive_plot( arxivml_data_map, arxivml_label_layers[0], arxivml_label_layers[2], arxivml_label_layers[4], hover_text=arxivml_hover_data, initial_zoom_fraction=0.999, font_family="Playfair Display SC", on_click='window.open(`http://google.com/search?q="{hover_text}"`)', darkmode=True, widgets=widgets, inline_data=True, offline_data_prefix="arxivml_widgets_gallery", ) plot.save("arxiv_ml_widgets.html") plot .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.480 seconds) .. _sphx_glr_download_auto_examples_plot_interactive_arxiv_ml_widgets.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_interactive_arxiv_ml_widgets.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_interactive_arxiv_ml_widgets.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_interactive_arxiv_ml_widgets.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_