Note
Go to the end to download the full example code.
Tooltips#
Show tooltips on all graphics

/opt/hostedtoolcache/Python/3.12.10/x64/lib/python3.12/site-packages/pygfx/objects/_ruler.py:270: RuntimeWarning: divide by zero encountered in divide
screen_full = (ndc_full[:, :2] / ndc_full[:, 3:4]) * half_canvas_size
/opt/hostedtoolcache/Python/3.12.10/x64/lib/python3.12/site-packages/pygfx/objects/_ruler.py:270: RuntimeWarning: invalid value encountered in divide
screen_full = (ndc_full[:, :2] / ndc_full[:, 3:4]) * half_canvas_size
/opt/hostedtoolcache/Python/3.12.10/x64/lib/python3.12/site-packages/pygfx/objects/_ruler.py:282: RuntimeWarning: invalid value encountered in divide
screen_sel = (ndc_sel[:, :2] / ndc_sel[:, 3:4]) * half_canvas_size
/home/runner/work/fastplotlib/fastplotlib/fastplotlib/graphics/features/_base.py:18: UserWarning: casting float64 array to float32
warn(f"casting {array.dtype} array to float32")
# test_example = false
import numpy as np
import imageio.v3 as iio
import fastplotlib as fpl
# get some data
scatter_data = np.random.rand(1_000, 3)
xs = np.linspace(0, 2 * np.pi, 100)
ys = np.sin(xs)
gray = iio.imread("imageio:camera.png")
rgb = iio.imread("imageio:astronaut.png")
# create a figure
figure = fpl.Figure(
cameras=["3d", "2d", "2d", "2d"],
controller_types=["orbit", "panzoom", "panzoom", "panzoom"],
size=(700, 560),
shape=(2, 2),
show_tooltips=True, # tooltip will display data value info for all graphics
)
# create graphics
scatter = figure[0, 0].add_scatter(scatter_data, sizes=3, colors="r")
line = figure[0, 1].add_line(np.column_stack([xs, ys]))
image = figure[1, 0].add_image(gray)
image_rgb = figure[1, 1].add_image(rgb)
figure.show()
# to hide tooltips for all graphics in an existing Figure
# figure.show_tooltips = False
# to show tooltips for all graphics in an existing Figure
# figure.show_tooltips = True
# NOTE: `if __name__ == "__main__"` is NOT how to use fastplotlib interactively
# please see our docs for using fastplotlib interactively in ipython and jupyter
if __name__ == "__main__":
print(__doc__)
fpl.loop.run()
Total running time of the script: (0 minutes 0.920 seconds)