.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/features_hist.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_features_hist.py: Hisogram of features ==================== .. GENERATED FROM PYTHON SOURCE LINES 5-43 .. image-sg:: /auto_examples/images/sphx_glr_features_hist_001.png :alt: features hist :srcset: /auto_examples/images/sphx_glr_features_hist_001.png :class: sphx-glr-single-img .. code-block:: Python import napari import numpy as np import numpy.typing as npt from skimage.measure import regionprops_table # make a test label image label_image: npt.NDArray[np.uint16] = np.zeros((100, 100), dtype=np.uint16) label_image[10:20, 10:20] = 1 label_image[50:70, 50:70] = 2 feature_table_1 = regionprops_table( label_image, properties=("label", "area", "perimeter") ) feature_table_1["index"] = feature_table_1["label"] # make the points data n_points = 100 points_data = 100 * np.random.random((100, 2)) points_features = { "feature_0": np.random.random((n_points,)), "feature_1": np.random.random((n_points,)), "feature_2": np.random.random((n_points,)), } # create the viewer viewer = napari.Viewer() viewer.add_labels(label_image, features=feature_table_1) viewer.add_points(points_data, features=points_features) # make the widget viewer.window.add_plugin_dock_widget( plugin_name="napari-matplotlib", widget_name="FeaturesHistogram" ) if __name__ == "__main__": napari.run() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.062 seconds) .. _sphx_glr_download_auto_examples_features_hist.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: features_hist.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: features_hist.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_