.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_gallery/guis/imgui_colorbar.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__gallery_guis_imgui_colorbar.py: ImGUI Colorbar ============== Create an ImguiColorbar manually and add it to the right edge of each subplot. .. GENERATED FROM PYTHON SOURCE LINES 7-61 .. image-sg:: /_gallery/guis/images/sphx_glr_imgui_colorbar_001.webp :alt: imgui colorbar :srcset: /_gallery/guis/images/sphx_glr_imgui_colorbar_001.webp :class: sphx-glr-single-img .. code-block:: Python # test_example = false import numpy as np import fastplotlib as fpl import imageio.v3 as iio from fastplotlib.ui import ImguiColorbar # a grayscale image and an RGB image camera = iio.imread("imageio:camera.png") astronaut = iio.imread("imageio:astronaut.png") figure = fpl.Figure( shape=(2, 2), size=(900, 900), canvas_kwargs={"max_fps": 999, "vsync": False} ) # top row: a plain colorbar for each image # grayscale image displayed with a colormap camera_image = figure[0, 0].add_image(camera, cmap="viridis", name="camera") figure[0, 0].add_imgui_window( ImguiColorbar(graphics=camera_image), location="right", size=80 ) # RGB image, it has no colormap so its colorbar is drawn with "gray" astronaut_image = figure[0, 1].add_image(astronaut, name="astronaut") figure[0, 1].add_imgui_window( ImguiColorbar(graphics=astronaut_image), location="right", size=80 ) # bottom row: the same images, but with a precomputed 100-bin histogram on the colorbar camera_image2 = figure[1, 0].add_image(camera, cmap="viridis", name="camera") camera_histogram = np.histogram(camera, bins=100) figure[1, 0].add_imgui_window( ImguiColorbar(graphics=camera_image2, histogram=camera_histogram), location="right", size=100, ) astronaut_image2 = figure[1, 1].add_image(astronaut, name="astronaut") astronaut_histogram = np.histogram(astronaut, bins=100) figure[1, 1].add_imgui_window( ImguiColorbar(graphics=astronaut_image2, histogram=astronaut_histogram), location="right", size=100, ) figure.show() # NOTE: fpl.loop.run() should not be used for interactive sessions # See the "JupyterLab and IPython" section in the user guide if __name__ == "__main__": print(__doc__) fpl.loop.run() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.826 seconds) .. _sphx_glr_download__gallery_guis_imgui_colorbar.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: imgui_colorbar.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: imgui_colorbar.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_