From 22e1c8532bebd1dc31538f7b0c5b5880b72784bc Mon Sep 17 00:00:00 2001 From: Caitlin Lewis Date: Wed, 29 May 2024 17:23:18 -0400 Subject: [PATCH 01/32] start sphinx gallery --- docs/source/conf.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index f681a8101..4884f9e94 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -3,6 +3,15 @@ # For the full list of built-in configuration values, see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html import fastplotlib +from pygfx.utils.gallery_scraper import find_examples_for_gallery +from pathlib import Path +import sys +import os + +ROOT_DIR = Path(__file__).parents[1].parents[0] # repo root +EXAMPLES_DIR = ROOT_DIR / "examples" / "desktop" + +sys.path.insert(0, str(ROOT_DIR)) # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information @@ -15,6 +24,9 @@ # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration +# Force offscreen rendering +os.environ["WGPU_FORCE_OFFSCREEN"] = "true" + extensions = [ "sphinx.ext.napoleon", "sphinx.ext.autodoc", @@ -24,8 +36,21 @@ "sphinx_copybutton", "sphinx_design", "nbsphinx", + "sphinx_gallery.gen_gallery" ] +sphinx_gallery_conf = { + "gallery_dirs": "_gallery", + "backreferences_dir": "_gallery/backreferences", + "doc_module": ("fastplotlib",), + "image_scrapers": ("pygfx",), + "remove_config_comments": True, + "ignore_pattern": r'__init__\.py', +} + +extra_conf = find_examples_for_gallery(EXAMPLES_DIR) +sphinx_gallery_conf.update(extra_conf) + autosummary_generate = True templates_path = ["_templates"] @@ -52,7 +77,7 @@ intersphinx_mapping = { "python": ("https://docs.python.org/3", None), "numpy": ("https://numpy.org/doc/stable/", None), - "pygfx": ("https://pygfx.readthedocs.io/en/latest", None), + "pygfx": ("https://pygfx.com/stable/", None), "wgpu": ("https://wgpu-py.readthedocs.io/en/latest", None), } From 71c1eafdf4ec88f7ccf736f606eff97cbba466c6 Mon Sep 17 00:00:00 2001 From: Caitlin Lewis Date: Wed, 29 May 2024 17:35:05 -0400 Subject: [PATCH 02/32] relevant file changes --- docs/source/index.rst | 6 ++++++ examples/README.rst | 2 ++ examples/desktop/gridplot/README.rst | 2 ++ examples/desktop/gridplot/gridplot.py | 10 ++++++++-- examples/desktop/gridplot/gridplot_non_square.py | 10 ++++++++-- setup.py | 1 + 6 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 examples/README.rst create mode 100644 examples/desktop/gridplot/README.rst diff --git a/docs/source/index.rst b/docs/source/index.rst index 0bca839b9..8d84b7083 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -13,6 +13,12 @@ Welcome to fastplotlib's documentation! GPU Info +.. toctree:: + :caption: Gallery + :maxdepth: 1 + + Gallery <_gallery/index> + .. toctree:: :maxdepth: 1 :caption: API diff --git a/examples/README.rst b/examples/README.rst new file mode 100644 index 000000000..138ec748b --- /dev/null +++ b/examples/README.rst @@ -0,0 +1,2 @@ +Examples that use fastplotlib +============================= diff --git a/examples/desktop/gridplot/README.rst b/examples/desktop/gridplot/README.rst new file mode 100644 index 000000000..486e708e7 --- /dev/null +++ b/examples/desktop/gridplot/README.rst @@ -0,0 +1,2 @@ +GridPlot Examples +================= diff --git a/examples/desktop/gridplot/gridplot.py b/examples/desktop/gridplot/gridplot.py index 2669dd49b..f740109c2 100644 --- a/examples/desktop/gridplot/gridplot.py +++ b/examples/desktop/gridplot/gridplot.py @@ -5,12 +5,16 @@ """ # test_example = true +# sphinx_gallery_pygfx_docs = 'screenshot' import fastplotlib as fpl import imageio.v3 as iio +from wgpu.gui.auto import WgpuCanvas +canvas = WgpuCanvas(size=(800, 800)) -fig = fpl.Figure(shape=(2, 2)) + +fig = fpl.Figure(shape=(2, 2), canvas=canvas) im = iio.imread("imageio:clock.png") im2 = iio.imread("imageio:astronaut.png") @@ -22,9 +26,11 @@ fig[1, 0].add_image(data=im3) fig[1, 1].add_image(data=im4) +#canvas = fig.canvas + fig.show() -fig.canvas.set_logical_size(800, 800) +#fig.canvas.set_logical_size(800, 800) for subplot in fig: subplot.auto_scale() diff --git a/examples/desktop/gridplot/gridplot_non_square.py b/examples/desktop/gridplot/gridplot_non_square.py index ea93096dc..cd4e359b7 100644 --- a/examples/desktop/gridplot/gridplot_non_square.py +++ b/examples/desktop/gridplot/gridplot_non_square.py @@ -5,12 +5,15 @@ """ # test_example = true +# sphinx_gallery_pygfx_docs = 'screenshot' import fastplotlib as fpl import imageio.v3 as iio +from wgpu.gui.auto import WgpuCanvas +canvas = WgpuCanvas(size=(800, 800)) -fig = fpl.Figure(shape=(2, 2), controller_ids="sync") +fig = fpl.Figure(shape=(2, 2), controller_ids="sync", canvas=canvas) im = iio.imread("imageio:clock.png") im2 = iio.imread("imageio:astronaut.png") @@ -22,7 +25,10 @@ fig.show() -fig.canvas.set_logical_size(800, 800) +renderer = fig.renderer +#canvas = fig.canvas + +#fig.canvas.set_logical_size(800, 800) for subplot in fig: subplot.auto_scale() diff --git a/setup.py b/setup.py index b50a6a9bf..7a842fa6d 100644 --- a/setup.py +++ b/setup.py @@ -12,6 +12,7 @@ extras_require = { "docs": [ "sphinx", + "sphinx-gallery", "furo", "glfw", "jupyter-rfb>=0.4.1", # required so ImageWidget docs show up From c8eb15d0543ce251c2d2c5379245f2e37f03e43f Mon Sep 17 00:00:00 2001 From: Caitlin Lewis Date: Thu, 30 May 2024 15:09:58 -0400 Subject: [PATCH 03/32] progress --- docs/source/conf.py | 23 +++++++++++++++---- docs/source/index.rst | 12 +++++----- examples/desktop/README.rst | 0 examples/desktop/gridplot/gridplot.py | 11 ++++----- .../desktop/gridplot/gridplot_non_square.py | 11 ++++----- examples/desktop/heatmap/README.rst | 2 ++ examples/desktop/heatmap/heatmap.py | 5 +++- examples/desktop/heatmap/heatmap_cmap.py | 5 +++- examples/desktop/heatmap/heatmap_data.py | 5 +++- examples/desktop/heatmap/heatmap_vmin_vmax.py | 5 +++- examples/desktop/image/README.rst | 2 ++ examples/desktop/image/image_cmap.py | 9 ++++++-- examples/desktop/image/image_rgb.py | 10 +++++--- examples/desktop/image/image_rgbvminvmax.py | 10 +++++--- examples/desktop/image/image_simple.py | 8 +++++-- examples/desktop/image/image_vminvmax.py | 10 +++++--- examples/desktop/image/image_widget.py | 7 +++++- examples/desktop/line/README.rst | 2 ++ examples/desktop/line/line.py | 10 +++++--- examples/desktop/line/line_cmap.py | 10 +++++--- examples/desktop/line/line_colorslice.py | 10 +++++--- examples/desktop/line/line_dataslice.py | 10 +++++--- examples/desktop/line/line_present_scaling.py | 10 +++++--- examples/desktop/line_collection/README.rst | 2 ++ .../line_collection/line_collection.py | 11 ++++++--- .../line_collection_cmap_values.py | 10 +++++--- ...line_collection_cmap_values_qualitative.py | 10 +++++--- .../line_collection/line_collection_colors.py | 9 ++++++-- .../desktop/line_collection/line_stack.py | 8 +++++-- examples/desktop/scatter/README.rst | 2 ++ examples/desktop/scatter/scatter.py | 4 ++++ examples/desktop/scatter/scatter_cmap.py | 5 +++- .../desktop/scatter/scatter_colorslice.py | 4 ++++ examples/desktop/scatter/scatter_dataslice.py | 4 ++++ examples/desktop/scatter/scatter_present.py | 5 +++- examples/desktop/scatter/scatter_size.py | 5 ++++ 36 files changed, 194 insertions(+), 72 deletions(-) create mode 100644 examples/desktop/README.rst create mode 100644 examples/desktop/heatmap/README.rst create mode 100644 examples/desktop/image/README.rst create mode 100644 examples/desktop/line/README.rst create mode 100644 examples/desktop/line_collection/README.rst create mode 100644 examples/desktop/scatter/README.rst diff --git a/docs/source/conf.py b/docs/source/conf.py index 4884f9e94..b12500da5 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -2,11 +2,17 @@ # # For the full list of built-in configuration values, see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html + +# Force offscreen rendering +import os + +os.environ["WGPU_FORCE_OFFSCREEN"] = "1" + import fastplotlib from pygfx.utils.gallery_scraper import find_examples_for_gallery from pathlib import Path import sys -import os +from sphinx_gallery.sorting import ExplicitOrder ROOT_DIR = Path(__file__).parents[1].parents[0] # repo root EXAMPLES_DIR = ROOT_DIR / "examples" / "desktop" @@ -24,9 +30,6 @@ # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration -# Force offscreen rendering -os.environ["WGPU_FORCE_OFFSCREEN"] = "true" - extensions = [ "sphinx.ext.napoleon", "sphinx.ext.autodoc", @@ -45,6 +48,16 @@ "doc_module": ("fastplotlib",), "image_scrapers": ("pygfx",), "remove_config_comments": True, + "subsection_order": ExplicitOrder( + [ + "../../examples/desktop/image", + "../../examples/desktop/gridplot", + "../../examples/desktop/line", + "../../examples/desktop/line_collection", + "../../examples/desktop/scatter", + "../../examples/desktop/heatmap" + ] + ), "ignore_pattern": r'__init__\.py', } @@ -71,6 +84,8 @@ autoclass_content = "both" add_module_names = False +nbsphinx_allow_errors = True + autodoc_typehints = "description" autodoc_typehints_description_target = "documented_params" diff --git a/docs/source/index.rst b/docs/source/index.rst index 8d84b7083..521e7926f 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -13,12 +13,6 @@ Welcome to fastplotlib's documentation! GPU Info -.. toctree:: - :caption: Gallery - :maxdepth: 1 - - Gallery <_gallery/index> - .. toctree:: :maxdepth: 1 :caption: API @@ -32,6 +26,12 @@ Welcome to fastplotlib's documentation! Utils GPU +.. toctree:: + :caption: Gallery + :maxdepth: 2 + + Gallery <_gallery/index> + Summary ======= diff --git a/examples/desktop/README.rst b/examples/desktop/README.rst new file mode 100644 index 000000000..e69de29bb diff --git a/examples/desktop/gridplot/gridplot.py b/examples/desktop/gridplot/gridplot.py index f740109c2..2b318d6a5 100644 --- a/examples/desktop/gridplot/gridplot.py +++ b/examples/desktop/gridplot/gridplot.py @@ -9,12 +9,8 @@ import fastplotlib as fpl import imageio.v3 as iio -from wgpu.gui.auto import WgpuCanvas -canvas = WgpuCanvas(size=(800, 800)) - - -fig = fpl.Figure(shape=(2, 2), canvas=canvas) +fig = fpl.Figure(shape=(2, 2)) im = iio.imread("imageio:clock.png") im2 = iio.imread("imageio:astronaut.png") @@ -26,11 +22,12 @@ fig[1, 0].add_image(data=im3) fig[1, 1].add_image(data=im4) -#canvas = fig.canvas +# set canvas variable for sphinx_gallery to properly generate examples +canvas = fig.canvas fig.show() -#fig.canvas.set_logical_size(800, 800) +fig.canvas.set_logical_size(800, 800) for subplot in fig: subplot.auto_scale() diff --git a/examples/desktop/gridplot/gridplot_non_square.py b/examples/desktop/gridplot/gridplot_non_square.py index cd4e359b7..6ef9d403a 100644 --- a/examples/desktop/gridplot/gridplot_non_square.py +++ b/examples/desktop/gridplot/gridplot_non_square.py @@ -9,11 +9,8 @@ import fastplotlib as fpl import imageio.v3 as iio -from wgpu.gui.auto import WgpuCanvas -canvas = WgpuCanvas(size=(800, 800)) - -fig = fpl.Figure(shape=(2, 2), controller_ids="sync", canvas=canvas) +fig = fpl.Figure(shape=(2, 2), controller_ids="sync") im = iio.imread("imageio:clock.png") im2 = iio.imread("imageio:astronaut.png") @@ -25,10 +22,10 @@ fig.show() -renderer = fig.renderer -#canvas = fig.canvas +# set canvas variable for sphinx_gallery to properly generate examples +canvas = fig.canvas -#fig.canvas.set_logical_size(800, 800) +fig.canvas.set_logical_size(800, 800) for subplot in fig: subplot.auto_scale() diff --git a/examples/desktop/heatmap/README.rst b/examples/desktop/heatmap/README.rst new file mode 100644 index 000000000..64294f46f --- /dev/null +++ b/examples/desktop/heatmap/README.rst @@ -0,0 +1,2 @@ +Heatmap Examples +================ diff --git a/examples/desktop/heatmap/heatmap.py b/examples/desktop/heatmap/heatmap.py index fa5ec6715..22bfaae2c 100644 --- a/examples/desktop/heatmap/heatmap.py +++ b/examples/desktop/heatmap/heatmap.py @@ -5,12 +5,15 @@ """ # test_example = true +# sphinx_gallery_pygfx_docs = 'screenshot' import fastplotlib as fpl import numpy as np +from wgpu.gui.offscreen import WgpuCanvas +canvas = WgpuCanvas() -fig = fpl.Figure() +fig = fpl.Figure(canvas=canvas) xs = np.linspace(0, 1_000, 10_000) diff --git a/examples/desktop/heatmap/heatmap_cmap.py b/examples/desktop/heatmap/heatmap_cmap.py index a1434bb0e..c86e7c647 100644 --- a/examples/desktop/heatmap/heatmap_cmap.py +++ b/examples/desktop/heatmap/heatmap_cmap.py @@ -5,12 +5,15 @@ """ # test_example = true +# sphinx_gallery_pygfx_docs = 'screenshot' import fastplotlib as fpl import numpy as np +from wgpu.gui.offscreen import WgpuCanvas +canvas = WgpuCanvas() -fig = fpl.Figure() +fig = fpl.Figure(canvas=canvas) xs = np.linspace(0, 1_000, 10_000) diff --git a/examples/desktop/heatmap/heatmap_data.py b/examples/desktop/heatmap/heatmap_data.py index 67aee1668..6df37ba4b 100644 --- a/examples/desktop/heatmap/heatmap_data.py +++ b/examples/desktop/heatmap/heatmap_data.py @@ -5,12 +5,15 @@ """ # test_example = true +# sphinx_gallery_pygfx_docs = 'screenshot' import fastplotlib as fpl import numpy as np +from wgpu.gui.offscreen import WgpuCanvas +canvas = WgpuCanvas() -fig = fpl.Figure() +fig = fpl.Figure(canvas=canvas) xs = np.linspace(0, 1_000, 10_000) diff --git a/examples/desktop/heatmap/heatmap_vmin_vmax.py b/examples/desktop/heatmap/heatmap_vmin_vmax.py index 6fe8a08b8..db3629124 100644 --- a/examples/desktop/heatmap/heatmap_vmin_vmax.py +++ b/examples/desktop/heatmap/heatmap_vmin_vmax.py @@ -5,12 +5,15 @@ """ # test_example = true +# sphinx_gallery_pygfx_docs = 'screenshot' import fastplotlib as fpl import numpy as np +from wgpu.gui.offscreen import WgpuCanvas +canvas = WgpuCanvas() -fig = fpl.Figure() +fig = fpl.Figure(canvas=canvas) xs = np.linspace(0, 1_000, 10_000) diff --git a/examples/desktop/image/README.rst b/examples/desktop/image/README.rst new file mode 100644 index 000000000..028e85ec5 --- /dev/null +++ b/examples/desktop/image/README.rst @@ -0,0 +1,2 @@ +Image Examples +============== diff --git a/examples/desktop/image/image_cmap.py b/examples/desktop/image/image_cmap.py index bb8e9f9d8..fd7a27d62 100644 --- a/examples/desktop/image/image_cmap.py +++ b/examples/desktop/image/image_cmap.py @@ -1,10 +1,12 @@ """ -Simple Plot -============ +Image colormap +============== + Example showing simple plot creation and subsequent cmap change with Standard image from imageio. """ # test_example = true +# sphinx_gallery_pygfx_docs = 'screenshot' import fastplotlib as fpl import imageio.v3 as iio @@ -18,6 +20,9 @@ fig.show() +# set canvas variable for sphinx_gallery to properly generate examples +canvas = fig.canvas + fig.canvas.set_logical_size(800, 800) fig[0, 0].auto_scale() diff --git a/examples/desktop/image/image_rgb.py b/examples/desktop/image/image_rgb.py index ce7e151d0..e82fd536d 100644 --- a/examples/desktop/image/image_rgb.py +++ b/examples/desktop/image/image_rgb.py @@ -1,15 +1,16 @@ """ -Simple Plot -============ +RGB Image +========= + Example showing the simple plot creation with 512 x 512 2D RGB image. """ # test_example = true +# sphinx_gallery_pygfx_docs = 'screenshot' import fastplotlib as fpl import imageio.v3 as iio - im = iio.imread("imageio:astronaut.png") fig = fpl.Figure() @@ -19,6 +20,9 @@ fig.show() +# set canvas variable for sphinx_gallery to properly generate examples +canvas = fig.canvas + fig.canvas.set_logical_size(800, 800) fig[0, 0].auto_scale() diff --git a/examples/desktop/image/image_rgbvminvmax.py b/examples/desktop/image/image_rgbvminvmax.py index 9725c038a..807aeedb1 100644 --- a/examples/desktop/image/image_rgbvminvmax.py +++ b/examples/desktop/image/image_rgbvminvmax.py @@ -1,15 +1,16 @@ """ -Simple Plot -============ +RGB Image Vmin/Vmax +=================== + Example showing the simple plot followed by changing the vmin/vmax with 512 x 512 2D RGB image. """ # test_example = true +# sphinx_gallery_pygfx_docs = 'screenshot' import fastplotlib as fpl import imageio.v3 as iio - im = iio.imread("imageio:astronaut.png") fig = fpl.Figure() @@ -19,6 +20,9 @@ fig.show() +# set canvas variable for sphinx_gallery to properly generate examples +canvas = fig.canvas + fig.canvas.set_logical_size(800, 800) fig[0, 0].auto_scale() diff --git a/examples/desktop/image/image_simple.py b/examples/desktop/image/image_simple.py index a640974ed..811cc41cb 100644 --- a/examples/desktop/image/image_simple.py +++ b/examples/desktop/image/image_simple.py @@ -1,15 +1,16 @@ """ -Simple Plot +Simple Image ============ + Example showing the simple plot creation with Standard imageio image. """ # test_example = true +# sphinx_gallery_pygfx_docs = 'screenshot' import fastplotlib as fpl import imageio.v3 as iio - fig = fpl.Figure() data = iio.imread("imageio:camera.png") @@ -19,6 +20,9 @@ fig.show() +# set canvas variable for sphinx_gallery to properly generate examples +canvas = fig.canvas + fig.canvas.set_logical_size(800, 800) fig[0, 0].auto_scale() diff --git a/examples/desktop/image/image_vminvmax.py b/examples/desktop/image/image_vminvmax.py index 3c8607aef..ed712eacd 100644 --- a/examples/desktop/image/image_vminvmax.py +++ b/examples/desktop/image/image_vminvmax.py @@ -1,15 +1,16 @@ """ -Simple Plot -============ +Image Vmin/Vmax +=============== + Example showing the simple plot creation followed by changing the vmin/vmax with Standard imageio image. """ # test_example = true +# sphinx_gallery_pygfx_docs = 'screenshot' import fastplotlib as fpl import imageio.v3 as iio - fig = fpl.Figure() data = iio.imread("imageio:astronaut.png") @@ -19,6 +20,9 @@ fig.show() +# set canvas variable for sphinx_gallery to properly generate examples +canvas = fig.canvas + fig.canvas.set_logical_size(800, 800) fig[0, 0].auto_scale() diff --git a/examples/desktop/image/image_widget.py b/examples/desktop/image/image_widget.py index 80aafe0b1..8f3dd5698 100644 --- a/examples/desktop/image/image_widget.py +++ b/examples/desktop/image/image_widget.py @@ -1,18 +1,23 @@ """ Image widget ============ + Example showing the image widget in action. When run in a notebook, or with the Qt GUI backend, sliders are also shown. """ +# sphinx_gallery_pygfx_docs = 'hidden' + import fastplotlib as fpl import imageio.v3 as iio # not a fastplotlib dependency, only used for examples - a = iio.imread("imageio:camera.png") iw = fpl.ImageWidget(data=a, cmap="viridis") iw.show() +# set canvas variable for sphinx_gallery to properly generate examples +canvas = iw.figure.canvas + if __name__ == "__main__": print(__doc__) diff --git a/examples/desktop/line/README.rst b/examples/desktop/line/README.rst new file mode 100644 index 000000000..b9970c543 --- /dev/null +++ b/examples/desktop/line/README.rst @@ -0,0 +1,2 @@ +Line Examples +============= diff --git a/examples/desktop/line/line.py b/examples/desktop/line/line.py index 56575a810..2aa62841d 100644 --- a/examples/desktop/line/line.py +++ b/examples/desktop/line/line.py @@ -1,16 +1,20 @@ """ -Line Plot -============ +Simple Line Plot +================ + Example showing cosine, sine, sinc lines. """ # test_example = true +# sphinx_gallery_pygfx_docs = 'screenshot' import fastplotlib as fpl import numpy as np +from wgpu.gui.offscreen import WgpuCanvas +canvas = WgpuCanvas() -fig = fpl.Figure() +fig = fpl.Figure(canvas=canvas) xs = np.linspace(-10, 10, 100) # sine wave diff --git a/examples/desktop/line/line_cmap.py b/examples/desktop/line/line_cmap.py index 7d8e1e7d6..23cf70887 100644 --- a/examples/desktop/line/line_cmap.py +++ b/examples/desktop/line/line_cmap.py @@ -1,16 +1,20 @@ """ -Line Plot -============ +Line Plot Colormap +================== + Example showing cosine, sine, sinc lines. """ # test_example = true +# sphinx_gallery_pygfx_docs = 'screenshot' import fastplotlib as fpl import numpy as np +from wgpu.gui.offscreen import WgpuCanvas +canvas = WgpuCanvas() -fig = fpl.Figure() +fig = fpl.Figure(canvas=canvas) xs = np.linspace(-10, 10, 100) # sine wave diff --git a/examples/desktop/line/line_colorslice.py b/examples/desktop/line/line_colorslice.py index 4df666531..8e479e9b5 100644 --- a/examples/desktop/line/line_colorslice.py +++ b/examples/desktop/line/line_colorslice.py @@ -1,16 +1,20 @@ """ -Line Plot -============ +Line Plot Color Slicing +======================= + Example showing color slicing with cosine, sine, sinc lines. """ # test_example = true +# sphinx_gallery_pygfx_docs = 'screenshot' import fastplotlib as fpl import numpy as np +from wgpu.gui.offscreen import WgpuCanvas +canvas = WgpuCanvas() -fig = fpl.Figure() +fig = fpl.Figure(canvas=canvas) xs = np.linspace(-10, 10, 100) # sine wave diff --git a/examples/desktop/line/line_dataslice.py b/examples/desktop/line/line_dataslice.py index 12a5f0f04..7eb802b12 100644 --- a/examples/desktop/line/line_dataslice.py +++ b/examples/desktop/line/line_dataslice.py @@ -1,16 +1,20 @@ """ -Line Plot -============ +Line Plot Data Slicing +====================== + Example showing data slicing with cosine, sine, sinc lines. """ # test_example = true +# sphinx_gallery_pygfx_docs = 'screenshot' import fastplotlib as fpl import numpy as np +from wgpu.gui.offscreen import WgpuCanvas +canvas = WgpuCanvas() -fig = fpl.Figure() +fig = fpl.Figure(canvas=canvas) xs = np.linspace(-10, 10, 100) # sine wave diff --git a/examples/desktop/line/line_present_scaling.py b/examples/desktop/line/line_present_scaling.py index d334e6fbd..6f49f6daa 100644 --- a/examples/desktop/line/line_present_scaling.py +++ b/examples/desktop/line/line_present_scaling.py @@ -1,16 +1,20 @@ """ -Line Plot -============ +Line Plot Present & Scaling +=========================== + Example showing present and scaling feature for lines. """ # test_example = true +# sphinx_gallery_pygfx_docs = 'screenshot' import fastplotlib as fpl import numpy as np +from wgpu.gui.offscreen import WgpuCanvas +canvas = WgpuCanvas() -fig = fpl.Figure() +fig = fpl.Figure(canvas=canvas) xs = np.linspace(-10, 10, 100) # sine wave diff --git a/examples/desktop/line_collection/README.rst b/examples/desktop/line_collection/README.rst new file mode 100644 index 000000000..3dbe05f7f --- /dev/null +++ b/examples/desktop/line_collection/README.rst @@ -0,0 +1,2 @@ +LineCollection Examples +======================= diff --git a/examples/desktop/line_collection/line_collection.py b/examples/desktop/line_collection/line_collection.py index dd6f3ca33..2fd1531c9 100644 --- a/examples/desktop/line_collection/line_collection.py +++ b/examples/desktop/line_collection/line_collection.py @@ -1,14 +1,19 @@ """ -Line Plot -============ +Line Collection Simple +====================== + Example showing how to plot line collections """ # test_example = true +# sphinx_gallery_pygfx_docs = 'screenshot' from itertools import product import numpy as np import fastplotlib as fpl +from wgpu.gui.offscreen import WgpuCanvas + +canvas = WgpuCanvas() def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray: @@ -27,7 +32,7 @@ def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray: pos_xy = np.vstack(circles) -fig = fpl.Figure() +fig = fpl.Figure(canvas=canvas) fig[0, 0].add_line_collection(circles, cmap="jet", thickness=5) diff --git a/examples/desktop/line_collection/line_collection_cmap_values.py b/examples/desktop/line_collection/line_collection_cmap_values.py index 9eeef40f8..8b6db5849 100644 --- a/examples/desktop/line_collection/line_collection_cmap_values.py +++ b/examples/desktop/line_collection/line_collection_cmap_values.py @@ -1,15 +1,19 @@ """ -Line Plot -============ +Line Plot Colormap Values +========================= + Example showing how to plot line collections """ # test_example = true +# sphinx_gallery_pygfx_docs = 'screenshot' from itertools import product import numpy as np import fastplotlib as fpl +from wgpu.gui.offscreen import WgpuCanvas +canvas = WgpuCanvas() def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray: theta = np.linspace(0, 2 * np.pi, n_points) @@ -33,7 +37,7 @@ def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray: # highest values, lowest values, mid-high values, mid values cmap_values = [10] * 4 + [0] * 4 + [7] * 4 + [5] * 4 -fig = fpl.Figure() +fig = fpl.Figure(canvas=canvas) fig[0, 0].add_line_collection( circles, diff --git a/examples/desktop/line_collection/line_collection_cmap_values_qualitative.py b/examples/desktop/line_collection/line_collection_cmap_values_qualitative.py index 85f0724d8..099be2a6d 100644 --- a/examples/desktop/line_collection/line_collection_cmap_values_qualitative.py +++ b/examples/desktop/line_collection/line_collection_cmap_values_qualitative.py @@ -1,15 +1,19 @@ """ -Line Plot -============ +Line Collection Qualitative Colormap +==================================== + Example showing how to plot line collections """ # test_example = true +# sphinx_gallery_pygfx_docs = 'screenshot' from itertools import product import numpy as np import fastplotlib as fpl +from wgpu.gui.offscreen import WgpuCanvas +canvas = WgpuCanvas() def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray: theta = np.linspace(0, 2 * np.pi, n_points) @@ -39,7 +43,7 @@ def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray: 1, 1, 1, 5 ] -fig = fpl.Figure() +fig = fpl.Figure(canvas=canvas) fig[0, 0].add_line_collection( circles, diff --git a/examples/desktop/line_collection/line_collection_colors.py b/examples/desktop/line_collection/line_collection_colors.py index d53afcd5b..621c5fe75 100644 --- a/examples/desktop/line_collection/line_collection_colors.py +++ b/examples/desktop/line_collection/line_collection_colors.py @@ -1,10 +1,12 @@ """ -Line Plot -============ +Line Collection Colors +====================== + Example showing how to plot line collections """ # test_example = true +# sphinx_gallery_pygfx_docs = 'screenshot' from itertools import product import numpy as np @@ -33,6 +35,9 @@ def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray: fig = fpl.Figure() +# set canvas variable for sphinx_gallery to properly generate examples +canvas = fig.canvas + fig[0, 0].add_line_collection(circles, colors=colors, thickness=10) fig.show() diff --git a/examples/desktop/line_collection/line_stack.py b/examples/desktop/line_collection/line_stack.py index cf5d933e3..a78061056 100644 --- a/examples/desktop/line_collection/line_stack.py +++ b/examples/desktop/line_collection/line_stack.py @@ -1,10 +1,11 @@ """ -Line Plot -============ +Line Stack +========== Example showing how to plot line collections """ # test_example = true +# sphinx_gallery_pygfx_docs = 'screenshot' import numpy as np import fastplotlib as fpl @@ -19,6 +20,9 @@ fig = fpl.Figure() +# set canvas variable for sphinx_gallery to properly generate examples +canvas = fig.canvas + # line stack takes all the same arguments as line collection and behaves similarly fig[0, 0].add_line_stack(data, cmap="jet") diff --git a/examples/desktop/scatter/README.rst b/examples/desktop/scatter/README.rst new file mode 100644 index 000000000..278170fb4 --- /dev/null +++ b/examples/desktop/scatter/README.rst @@ -0,0 +1,2 @@ +Scatter Examples +================ diff --git a/examples/desktop/scatter/scatter.py b/examples/desktop/scatter/scatter.py index c47306722..11cb5b3ff 100644 --- a/examples/desktop/scatter/scatter.py +++ b/examples/desktop/scatter/scatter.py @@ -5,6 +5,7 @@ """ # test_example = true +# sphinx_gallery_pygfx_docs = 'hidden' import fastplotlib as fpl import numpy as np @@ -20,6 +21,9 @@ scatter_graphic = fig[0, 0].add_scatter(data=data[:, :-1], sizes=6, alpha=0.7, colors=colors) +# set canvas variable for sphinx_gallery to properly generate examples +canvas = fig.canvas + fig.show() fig.canvas.set_logical_size(800, 800) diff --git a/examples/desktop/scatter/scatter_cmap.py b/examples/desktop/scatter/scatter_cmap.py index f1bba98c3..a01e7daf2 100644 --- a/examples/desktop/scatter/scatter_cmap.py +++ b/examples/desktop/scatter/scatter_cmap.py @@ -5,13 +5,13 @@ """ # test_example = true +# sphinx_gallery_pygfx_docs = 'hidden' import fastplotlib as fpl import numpy as np from pathlib import Path from sklearn.cluster import AgglomerativeClustering - fig = fpl.Figure() data_path = Path(__file__).parent.parent.joinpath("data", "iris.npy") @@ -24,6 +24,9 @@ data=data[:, :-1], sizes=15, alpha=0.7, cmap="Set1", cmap_values=agg.labels_ ) +# set canvas variable for sphinx_gallery to properly generate examples +canvas = fig.canvas + fig.show() fig.canvas.set_logical_size(800, 800) diff --git a/examples/desktop/scatter/scatter_colorslice.py b/examples/desktop/scatter/scatter_colorslice.py index 43f405b06..fdf4b25eb 100644 --- a/examples/desktop/scatter/scatter_colorslice.py +++ b/examples/desktop/scatter/scatter_colorslice.py @@ -5,6 +5,7 @@ """ # test_example = true +# sphinx_gallery_pygfx_docs = 'hidden' import fastplotlib as fpl import numpy as np @@ -23,6 +24,9 @@ fig.show() +# set canvas variable for sphinx_gallery to properly generate examples +canvas = fig.canvas + fig.canvas.set_logical_size(800, 800) fig[0, 0].auto_scale() diff --git a/examples/desktop/scatter/scatter_dataslice.py b/examples/desktop/scatter/scatter_dataslice.py index 989b7c21c..dfbfa8fc2 100644 --- a/examples/desktop/scatter/scatter_dataslice.py +++ b/examples/desktop/scatter/scatter_dataslice.py @@ -5,6 +5,7 @@ """ # test_example = true +# sphinx_gallery_pygfx_docs = 'hidden' import fastplotlib as fpl import numpy as np @@ -21,6 +22,9 @@ scatter_graphic = fig[0, 0].add_scatter(data=data[:, :-1], sizes=6, alpha=0.7, colors=colors) +# set canvas variable for sphinx_gallery to properly generate examples +canvas = fig.canvas + fig.show() fig.canvas.set_logical_size(800, 800) diff --git a/examples/desktop/scatter/scatter_present.py b/examples/desktop/scatter/scatter_present.py index 5da4610bd..6f46fe7ac 100644 --- a/examples/desktop/scatter/scatter_present.py +++ b/examples/desktop/scatter/scatter_present.py @@ -5,12 +5,12 @@ """ # test_example = true +# sphinx_gallery_pygfx_docs = 'hidden' import fastplotlib as fpl import numpy as np from pathlib import Path - fig = fpl.Figure() data_path = Path(__file__).parent.parent.joinpath("data", "iris.npy") @@ -26,6 +26,9 @@ fig.show() +# set canvas variable for sphinx_gallery to properly generate examples +canvas = fig.canvas + fig.canvas.set_logical_size(800, 800) fig[0, 0].auto_scale() diff --git a/examples/desktop/scatter/scatter_size.py b/examples/desktop/scatter/scatter_size.py index 41a97ad53..d2731be1c 100644 --- a/examples/desktop/scatter/scatter_size.py +++ b/examples/desktop/scatter/scatter_size.py @@ -5,6 +5,8 @@ """ # test_example = true +# sphinx_gallery_pygfx_docs = 'screenshot' + import numpy as np import fastplotlib as fpl @@ -24,6 +26,9 @@ data = np.column_stack([x_values, y_values]) +# set canvas variable for sphinx_gallery to properly generate examples +canvas = fig.canvas + fig["scalar_size"].add_scatter( data=data, sizes=5, colors="blue" ) # add a set of scalar sizes From e97f37b907508865104baedf0a6303a130d4068d Mon Sep 17 00:00:00 2001 From: Caitlin Lewis Date: Thu, 30 May 2024 16:05:55 -0400 Subject: [PATCH 04/32] edit setup.py to include missing dependencies --- setup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.py b/setup.py index 7a842fa6d..832b8fc9d 100644 --- a/setup.py +++ b/setup.py @@ -23,6 +23,8 @@ "pandoc", "jupyterlab", "sidecar", + "imageio", + "matplotlib" ], "notebook": [ "jupyterlab", From 5e0d08c58f658a4355ae3bcdb163b04dd8964eef Mon Sep 17 00:00:00 2001 From: Caitlin Lewis Date: Thu, 30 May 2024 16:40:42 -0400 Subject: [PATCH 05/32] attempt to fix rtd --- docs/source/conf.py | 2 -- fastplotlib/layouts/_figure.py | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index b12500da5..ca559526a 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -84,8 +84,6 @@ autoclass_content = "both" add_module_names = False -nbsphinx_allow_errors = True - autodoc_typehints = "description" autodoc_typehints_description_target = "documented_params" diff --git a/fastplotlib/layouts/_figure.py b/fastplotlib/layouts/_figure.py index 1c7439613..bb2f5de24 100644 --- a/fastplotlib/layouts/_figure.py +++ b/fastplotlib/layouts/_figure.py @@ -477,7 +477,7 @@ def show( subplot.auto_scale(maintain_aspect=_maintain_aspect, zoom=0.95) # used for generating images in docs using nbsphinx - if "NB_SNAPSHOT" in os.environ.keys(): + if "NB_SNAPSHOT" in os.environ.keys() and "WGPU_FORCE_OFFSCREEN" not in os.environ.keys(): if os.environ["NB_SNAPSHOT"] == "1": return self.canvas.snapshot() From 1acbbfbd3798cadc564566b98b91345427e0275c Mon Sep 17 00:00:00 2001 From: Caitlin Lewis Date: Thu, 30 May 2024 16:46:52 -0400 Subject: [PATCH 06/32] remove large heatmap example that breaks rtd --- examples/desktop/heatmap/heatmap_data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/desktop/heatmap/heatmap_data.py b/examples/desktop/heatmap/heatmap_data.py index 6df37ba4b..bd724c53a 100644 --- a/examples/desktop/heatmap/heatmap_data.py +++ b/examples/desktop/heatmap/heatmap_data.py @@ -5,7 +5,7 @@ """ # test_example = true -# sphinx_gallery_pygfx_docs = 'screenshot' +# sphinx_gallery_pygfx_docs = 'hidden' import fastplotlib as fpl import numpy as np From 372e466332347299d77572b09b62ed3971532017 Mon Sep 17 00:00:00 2001 From: Caitlin Lewis Date: Thu, 30 May 2024 17:05:29 -0400 Subject: [PATCH 07/32] fix linter, attempt to fix quickstart bug --- docs/source/quickstart.ipynb | 14 +++++++++++++- fastplotlib/layouts/_figure.py | 5 ++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/docs/source/quickstart.ipynb b/docs/source/quickstart.ipynb index 6a892399e..6157b3f04 100644 --- a/docs/source/quickstart.ipynb +++ b/docs/source/quickstart.ipynb @@ -48,6 +48,18 @@ "import imageio.v3 as iio" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "46a9a80b-0481-4788-975b-4ff364a03033", + "metadata": {}, + "outputs": [], + "source": [ + "### For the purpose of rendering our documentation, we need to manually make sure that offscreen rendering is not being used!\n", + "import os\n", + "os.environ[\"WGPU_FORCE_OFFSCREEN\"] = \"false\"" + ] + }, { "cell_type": "code", "execution_count": null, @@ -1665,7 +1677,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.3" + "version": "3.12.3" } }, "nbformat": 4, diff --git a/fastplotlib/layouts/_figure.py b/fastplotlib/layouts/_figure.py index bb2f5de24..b67ae3e77 100644 --- a/fastplotlib/layouts/_figure.py +++ b/fastplotlib/layouts/_figure.py @@ -477,7 +477,10 @@ def show( subplot.auto_scale(maintain_aspect=_maintain_aspect, zoom=0.95) # used for generating images in docs using nbsphinx - if "NB_SNAPSHOT" in os.environ.keys() and "WGPU_FORCE_OFFSCREEN" not in os.environ.keys(): + if ( + "NB_SNAPSHOT" in os.environ.keys() + and "WGPU_FORCE_OFFSCREEN" not in os.environ.keys() + ): if os.environ["NB_SNAPSHOT"] == "1": return self.canvas.snapshot() From b4dbc942f760f11d921c23f980e34dcbf07d13a6 Mon Sep 17 00:00:00 2001 From: Caitlin Date: Mon, 3 Jun 2024 11:44:39 -0400 Subject: [PATCH 08/32] fix gridplot examples and gallery structure --- docs/source/conf.py | 2 ++ docs/source/index.rst | 2 +- examples/desktop/gridplot/gridplot.py | 3 ++- examples/desktop/gridplot/gridplot_non_square.py | 5 +++-- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index ca559526a..755901204 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -59,6 +59,8 @@ ] ), "ignore_pattern": r'__init__\.py', + "nested_sections": False, + "thumbnail_size": (250, 250) } extra_conf = find_examples_for_gallery(EXAMPLES_DIR) diff --git a/docs/source/index.rst b/docs/source/index.rst index 521e7926f..a4d99268a 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -28,7 +28,7 @@ Welcome to fastplotlib's documentation! .. toctree:: :caption: Gallery - :maxdepth: 2 + :maxdepth: 1 Gallery <_gallery/index> diff --git a/examples/desktop/gridplot/gridplot.py b/examples/desktop/gridplot/gridplot.py index 2b318d6a5..8eabc7e4e 100644 --- a/examples/desktop/gridplot/gridplot.py +++ b/examples/desktop/gridplot/gridplot.py @@ -1,6 +1,7 @@ """ GridPlot Simple -============ +=============== + Example showing simple 2x2 GridPlot with Standard images from imageio. """ diff --git a/examples/desktop/gridplot/gridplot_non_square.py b/examples/desktop/gridplot/gridplot_non_square.py index 6ef9d403a..15888c766 100644 --- a/examples/desktop/gridplot/gridplot_non_square.py +++ b/examples/desktop/gridplot/gridplot_non_square.py @@ -1,6 +1,7 @@ """ -GridPlot Simple -============ +GridPlot Non-Square Example +=========================== + Example showing simple 2x2 GridPlot with Standard images from imageio. """ From 0fc05dd880f0e0ff4a1bf900ab5c3819e8d0baf9 Mon Sep 17 00:00:00 2001 From: Caitlin Date: Tue, 4 Jun 2024 11:18:07 -0400 Subject: [PATCH 09/32] remove nbsphinx --- docs/source/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 755901204..c95496ac8 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -38,7 +38,7 @@ "sphinx.ext.viewcode", "sphinx_copybutton", "sphinx_design", - "nbsphinx", + # "nbsphinx", "sphinx_gallery.gen_gallery" ] From 2856365c149c95a2656a4968bcd437708250a223 Mon Sep 17 00:00:00 2001 From: Caitlin Date: Tue, 4 Jun 2024 13:02:06 -0400 Subject: [PATCH 10/32] remove nbsphinx and quickstart.ipynb from docs --- docs/source/conf.py | 1 - docs/source/index.rst | 6 - docs/source/quickstart.ipynb | 1685 ---------------------------------- setup.py | 1 - 4 files changed, 1693 deletions(-) delete mode 100644 docs/source/quickstart.ipynb diff --git a/docs/source/conf.py b/docs/source/conf.py index c95496ac8..2ab374fe4 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -38,7 +38,6 @@ "sphinx.ext.viewcode", "sphinx_copybutton", "sphinx_design", - # "nbsphinx", "sphinx_gallery.gen_gallery" ] diff --git a/docs/source/index.rst b/docs/source/index.rst index a4d99268a..6385c2aee 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -1,12 +1,6 @@ Welcome to fastplotlib's documentation! ======================================= -.. toctree:: - :caption: Quick Start - :maxdepth: 2 - - quickstart - .. toctree:: :caption: User Guide :maxdepth: 2 diff --git a/docs/source/quickstart.ipynb b/docs/source/quickstart.ipynb deleted file mode 100644 index 6157b3f04..000000000 --- a/docs/source/quickstart.ipynb +++ /dev/null @@ -1,1685 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "id": "93740a09-9111-4777-ad57-173e9b80a2f0", - "metadata": { - "tags": [] - }, - "source": [ - "# Quick Start Guide 🚀\n", - "\n", - "This notebook goes through the basic components of the `fastplotlib` API, images, image updates, line plots, scatter plots, and grid plots.\n", - "\n", - "**NOTE: This quick start guide in the docs is NOT interactive. Download the examples from the repo and try them on your own computer. You can run the desktop examples directly if you have `glfw` installed, or try the notebook demos:** https://github.com/kushalkolar/fastplotlib/tree/master/examples\n", - "\n", - "It will not be possible to have live demos on the docs until someone can figure out how to get [pygfx](https://github.com/pygfx/pygfx) to work with `wgpu` in the browser, perhaps through [pyodide](https://github.com/pyodide/pyodide) or something :D." - ] - }, - { - "cell_type": "markdown", - "id": "5d21c330-89cd-49ab-9069-4e3652d4286b", - "metadata": {}, - "source": [ - "**The example images are from `imageio` so you will need to install it for this example notebook. But `imageio` is not required to use `fasptlotlib`**" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "07f064bb-025a-4794-9b05-243810edaf60", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "!pip install imageio" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "5f842366-bd39-47de-ad00-723b2be707e4", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "import imageio.v3 as iio" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "46a9a80b-0481-4788-975b-4ff364a03033", - "metadata": {}, - "outputs": [], - "source": [ - "### For the purpose of rendering our documentation, we need to manually make sure that offscreen rendering is not being used!\n", - "import os\n", - "os.environ[\"WGPU_FORCE_OFFSCREEN\"] = \"false\"" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "fb57c3d3-f20d-4d88-9e7a-04b9309bc637", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "import fastplotlib as fpl\n", - "from ipywidgets import VBox, HBox, IntSlider\n", - "import numpy as np" - ] - }, - { - "cell_type": "markdown", - "id": "a9b386ac-9218-4f8f-97b3-f29b4201ef55", - "metadata": {}, - "source": [ - "## Images" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "237823b7-e2c0-4e2f-9ee8-e3fc2b4453c4", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "# create a `Figure` instance\n", - "fig = fpl.Figure()\n", - "\n", - "# get a grayscale image\n", - "data = iio.imread(\"imageio:camera.png\")\n", - "\n", - "# plot the image data\n", - "image_graphic = fig[0, 0].add_image(data=data, name=\"sample-image\")\n", - "\n", - "# show the plot\n", - "fig.show()" - ] - }, - { - "cell_type": "markdown", - "id": "be5b408f-dd91-4e36-807a-8c22c8d7d216", - "metadata": {}, - "source": [ - "**In live notebooks or desktop applications, you can use the handle on the bottom right corner of the _canvas_ to resize it. You can also pan and zoom using your mouse!**" - ] - }, - { - "cell_type": "markdown", - "id": "9ba07ec1-a0cb-4461-87c6-c7b64d4a882b", - "metadata": {}, - "source": [ - "This is how you can take a snapshot of the canvas. Snapshots are shown throughout this doc page for the purposes of documentation, they are NOT necessary for real interactive usage. Download the notebooks to run live demos." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "b64ba135-e753-43a9-ad1f-adcc7310792d", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "fig.canvas.snapshot()" - ] - }, - { - "cell_type": "markdown", - "id": "ac5f5e75-9aa4-441f-9a41-66c22cd53de8", - "metadata": {}, - "source": [ - "Changing graphic **\"features\"**" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "d3541d1d-0819-450e-814c-588ffc8e7ed5", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "image_graphic.cmap = \"viridis\"" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "ab544719-9187-45bd-8127-aac79eea30e4", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "fig.canvas.snapshot()" - ] - }, - { - "cell_type": "markdown", - "id": "9693cf94-11e9-46a6-a5b7-b0fbed42ad81", - "metadata": {}, - "source": [ - "### Slicing data\n", - "\n", - "**Most features, such as `data` support slicing!**\n", - "\n", - "Out image data is of shape [n_rows, n_cols]" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "330a47b5-50b1-4e6a-b8ab-d55d92af2042", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "image_graphic.data().shape" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "601f46d9-7f32-4a43-9090-4674218800ea", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "image_graphic.data[::15, :] = 1\n", - "image_graphic.data[:, ::15] = 1" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "3443948f-9ac9-484a-a4bf-3a06c1ce5658", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "fig.canvas.snapshot()" - ] - }, - { - "cell_type": "markdown", - "id": "53125b3b-3ce2-43c5-b2e3-7cd37cec7d7d", - "metadata": {}, - "source": [ - "**Fancy indexing**" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "7344cbbe-40c3-4d9e-ae75-7abe3ddaeeeb", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "image_graphic.data[data > 175] = 255" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "ef113d79-5d86-4be0-868e-30f82f8ab528", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "fig.canvas.snapshot()" - ] - }, - { - "cell_type": "markdown", - "id": "4df5296e-2a18-403f-82f1-acb8eaf280e3", - "metadata": {}, - "source": [ - "Adjust vmin vmax" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "28af88d1-0518-47a4-ab73-431d6aaf9cb8", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "image_graphic.cmap.vmin = 50\n", - "image_graphic.cmap.vmax = 150" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "e3dfb827-c812-447d-b413-dc15653160b1", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "fig.canvas.snapshot()" - ] - }, - { - "cell_type": "markdown", - "id": "19a1b56b-fdca-40c5-91c9-3c9486fd8a21", - "metadata": {}, - "source": [ - "**Set the entire data array again**\n", - "\n", - "Note: The shape of the new data array must match the current data shown in the Graphic." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "4dc3d0e4-b128-42cd-a53e-76846fc9b8a8", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "new_data = iio.imread(\"imageio:astronaut.png\")\n", - "new_data.shape" - ] - }, - { - "cell_type": "markdown", - "id": "3bd06068-fe3f-404d-ba4a-a72a2105904f", - "metadata": {}, - "source": [ - "This is an RGB image, convert to grayscale to maintain the shape of (512, 512)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "150047a6-a6ac-442d-a468-3e0c224a2b7e", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "gray = new_data.dot([0.3, 0.6, 0.1])\n", - "gray.shape" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "bf24576b-d336-4754-9992-9649ccaa4d1e", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "image_graphic.data = gray" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "67d810c2-4020-4769-a5ba-0d4a972ee243", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "fig.canvas.snapshot()" - ] - }, - { - "cell_type": "markdown", - "id": "2fe82654-e554-4be6-92a0-ecdee0ef8519", - "metadata": {}, - "source": [ - "reset vmin vmax" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "0be6e4bb-cf9a-4155-9f6a-8106e66e6132", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "image_graphic.cmap.reset_vmin_vmax()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "bd51936c-ad80-4b33-b855-23565265a430", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "fig.canvas.snapshot()" - ] - }, - { - "cell_type": "markdown", - "id": "a6c1f3fb-a3a7-4175-bd8d-bb3203740771", - "metadata": {}, - "source": [ - "### Indexing plots" - ] - }, - { - "cell_type": "markdown", - "id": "3fc38694-aca6-4f56-97ac-3435059a6be7", - "metadata": {}, - "source": [ - "**Plots are indexable and give you their graphics by name**" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "8a547138-0f7d-470b-9925-8df479c3979e", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "fig" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "5551861f-9860-4515-8222-2f1c6d6a3220", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "fig[0, 0][\"sample-image\"]" - ] - }, - { - "cell_type": "markdown", - "id": "0c29b36e-0eb4-4bb3-a8db-add58c303ee8", - "metadata": {}, - "source": [ - "**You can also use numerical indexing on `plot.graphics`**" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "ce6adbb0-078a-4e74-b189-58f860ee5df5", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "fig[0, 0].graphics" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "119bd6af-c486-4378-bc23-79b1759aa3a4", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "fig[0, 0].graphics[0]" - ] - }, - { - "cell_type": "markdown", - "id": "6b8e3f0d-56f8-447f-bf26-b52629d06e95", - "metadata": {}, - "source": [ - "The `Graphic` instance is also returned when you call `plot.add_`." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "967c0cbd-287c-4d99-9891-9baf18f7b56a", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "image_graphic" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "5da72e26-3536-47b8-839c-53452dd94f7a", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "image_graphic is fig[0, 0][\"sample-image\"]" - ] - }, - { - "cell_type": "markdown", - "id": "2b5ee18b-e61b-415d-902a-688b1c9c03b8", - "metadata": {}, - "source": [ - "### RGB images\n", - "\n", - "`cmap` arguments are ignored for rgb images, but vmin vmax still works" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "1f7143ec-8ee1-47d2-b017-d0a8efc69fc6", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "fig_rgb = fpl.Figure()\n", - "\n", - "fig_rgb[0, 0].add_image(new_data, name=\"rgb-image\")\n", - "\n", - "fig_rgb.show()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "a47b1eaf-3638-470a-88a5-0026c81d7e2b", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "fig_rgb.canvas.snapshot()" - ] - }, - { - "cell_type": "markdown", - "id": "4848a929-4f3b-46d7-921b-ebfe8de0ebb5", - "metadata": {}, - "source": [ - "vmin and vmax are still applicable to rgb images" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "ffe50132-8dd0-433c-b9c6-9ead8c3d48de", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "fig_rgb[0, 0][\"rgb-image\"].cmap.vmin = 100" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "161468ba-b836-4021-8d11-8dfc140b94eb", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "fig_rgb.canvas.snapshot()" - ] - }, - { - "cell_type": "markdown", - "id": "1cb03f42-1029-4b16-a16b-35447d9e2955", - "metadata": { - "tags": [] - }, - "source": [ - "## Image updates\n", - "\n", - "This examples show how you can define animation functions that run on every render cycle." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "aadd757f-6379-4f52-a709-46aa57c56216", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "# create another `Figure` instance\n", - "fig_vid = fpl.Figure()\n", - "\n", - "# make some random data again\n", - "data = np.random.rand(512, 512)\n", - "\n", - "# plot the data\n", - "fig_vid[0, 0].add_image(data=data, name=\"random-image\")\n", - "\n", - "# a function to update the image_graphic\n", - "# a subplot will pass its instance to the animation function as an argument\n", - "def update_data(subplot):\n", - " new_data = np.random.rand(512, 512)\n", - " subplot[\"random-image\"].data = new_data\n", - "\n", - "#add this as an animation function to the subplot\n", - "fig_vid[0, 0].add_animations(update_data)\n", - "\n", - "# show the plot\n", - "fig_vid.show()" - ] - }, - { - "cell_type": "markdown", - "id": "b313eda1-6e6c-466f-9fd5-8b70c1d3c110", - "metadata": {}, - "source": [ - "**Share controllers across plots**\n", - "\n", - "This example creates a new plot, but it synchronizes the pan-zoom controller" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "86e70b1e-4328-4035-b992-70dff16d2a69", - "metadata": {}, - "outputs": [], - "source": [ - "fig_sync = fpl.Figure(controllers=fig_vid.controllers)\n", - "\n", - "data = np.random.rand(512, 512)\n", - "\n", - "image_graphic_instance = fig_sync[0, 0].add_image(data=data, cmap=\"viridis\")\n", - "\n", - "# you will need to define a new animation function for this graphic\n", - "def update_data_2():\n", - " new_data = np.random.rand(512, 512)\n", - " # alternatively, you can use the stored reference to the graphic as well instead of indexing the Plot\n", - " image_graphic_instance.data = new_data\n", - "\n", - "# add the animation function to the figure instead of the subplot\n", - "fig_sync.add_animations(update_data_2)\n", - "\n", - "fig_sync.show()" - ] - }, - { - "cell_type": "markdown", - "id": "f226c9c2-8d0e-41ab-9ab9-1ae31fd91de5", - "metadata": {}, - "source": [ - "Keeping a reference to the Graphic instance, as shown above `image_graphic_instance`, is useful if you're creating something where you need flexibility in the naming of the graphics" - ] - }, - { - "cell_type": "markdown", - "id": "d11fabb7-7c76-4e94-893d-80ed9ee3be3d", - "metadata": {}, - "source": [ - "You can also use `ipywidgets.VBox` and `HBox` to stack plots. See the `gridplot` notebooks for a proper gridplot interface for more automated subplotting\n", - "\n", - "Not shown in the docs, try the live demo for this feature" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "ef9743b3-5f81-4b79-9502-fa5fca08e56d", - "metadata": {}, - "outputs": [], - "source": [ - "#VBox([plot_v.canvas, plot_sync.show()])" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "11839d95-8ff7-444c-ae13-6b072c3112c5", - "metadata": {}, - "outputs": [], - "source": [ - "#HBox([plot_v.show(), plot_sync.show()])" - ] - }, - { - "cell_type": "markdown", - "id": "e7859338-8162-408b-ac72-37e606057045", - "metadata": { - "tags": [] - }, - "source": [ - "## Line plots\n", - "\n", - "2D line plots\n", - "\n", - "This example plots a sine wave, cosine wave, and ricker wavelet and demonstrates how **Graphic Features** can be modified by slicing!" - ] - }, - { - "cell_type": "markdown", - "id": "a6fee1c2-4a24-4325-bca2-26e5a4bf6338", - "metadata": {}, - "source": [ - "Generate some data." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "8e8280da-b421-43a5-a1a6-2a196a408e9a", - "metadata": {}, - "outputs": [], - "source": [ - "# linspace, create 100 evenly spaced x values from -10 to 10\n", - "xs = np.linspace(-10, 10, 100)\n", - "# sine wave\n", - "ys = np.sin(xs)\n", - "sine = np.dstack([xs, ys])[0]\n", - "\n", - "# cosine wave\n", - "ys = np.cos(xs) + 5\n", - "cosine = np.dstack([xs, ys])[0]\n", - "\n", - "# sinc function\n", - "a = 0.5\n", - "ys = np.sinc(xs) * 3 + 8\n", - "sinc = np.dstack([xs, ys])[0]" - ] - }, - { - "cell_type": "markdown", - "id": "fbb806e5-1565-4189-936c-b7cf147a59ee", - "metadata": {}, - "source": [ - "Plot all of it on the same plot. Each line plot will be an individual Graphic, you can have any combination of graphics on a plot." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "93a5d1e6-d019-4dd0-a0d1-25d1704ab7a7", - "metadata": {}, - "outputs": [], - "source": [ - "# Create a plot instance\n", - "fig_line = fpl.Figure()\n", - "\n", - "# plot sine wave, use a single color\n", - "sine_graphic = fig_line[0, 0].add_line(data=sine, thickness=5, colors=\"magenta\")\n", - "\n", - "# you can also use colormaps for lines!\n", - "cosine_graphic = fig_line[0, 0].add_line(data=cosine, thickness=12, cmap=\"autumn\")\n", - "\n", - "# or a list of colors for each datapoint\n", - "colors = [\"r\"] * 25 + [\"purple\"] * 25 + [\"y\"] * 25 + [\"b\"] * 25\n", - "sinc_graphic = fig_line[0, 0].add_line(data=sinc, thickness=5, colors = colors)\n", - "\n", - "fig_line.show()" - ] - }, - { - "cell_type": "markdown", - "id": "22dde600-0f56-4370-b017-c8f23a6c01aa", - "metadata": {}, - "source": [ - "\"stretching\" the camera, useful for large timeseries data\n", - "\n", - "Set `maintain_aspect = False` on a camera, and then use the right mouse button and move the mouse to stretch and squeeze the view!\n", - "\n", - "You can also click the **`1:1`** button to toggle this." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "2695f023-f6ce-4e26-8f96-4fbed5510d1d", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "fig_line[0, 0].camera.maintain_aspect = False" - ] - }, - { - "cell_type": "markdown", - "id": "1651e965-f750-47ac-bf53-c23dae84cc98", - "metadata": {}, - "source": [ - "reset the plot area" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "ba50a6ed-0f1b-4795-91dd-a7c3e40b8e3c", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "fig_line[0, 0].auto_scale(maintain_aspect=True)" - ] - }, - { - "cell_type": "markdown", - "id": "dcd68796-c190-4c3f-8519-d73b98ff6367", - "metadata": {}, - "source": [ - "Graphic features support slicing! :D " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "cb0d13ed-ef07-46ff-b19e-eeca4c831037", - "metadata": {}, - "outputs": [], - "source": [ - "# indexing of colors\n", - "cosine_graphic.colors[:15] = \"magenta\"\n", - "cosine_graphic.colors[90:] = \"red\"\n", - "cosine_graphic.colors[60] = \"w\"\n", - "\n", - "# indexing to assign colormaps to entire lines or segments\n", - "sinc_graphic.cmap[10:50] = \"gray\"\n", - "sine_graphic.cmap = \"seismic\"\n", - "\n", - "# more complex indexing, set the blue value directly from an array\n", - "cosine_graphic.colors[65:90, 0] = np.linspace(0, 1, 90-65)" - ] - }, - { - "cell_type": "markdown", - "id": "bfe14ed3-e81f-4058-96a7-e2720b6d2f45", - "metadata": {}, - "source": [ - "Make a snapshot of the canvas after slicing" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "a061a888-d732-406e-a9c2-8cc632fbc368", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "fig_line.canvas.snapshot()" - ] - }, - { - "cell_type": "markdown", - "id": "c9689887-cdf3-4a4d-948f-7efdb09bde4e", - "metadata": {}, - "source": [ - "**You can capture changes to a graphic feature as events**" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "cfa001f6-c640-4f91-beb0-c19b030e503f", - "metadata": {}, - "outputs": [], - "source": [ - "def callback_func(event_data):\n", - " print(event_data)\n", - "\n", - "# Will print event data when the color changes\n", - "cosine_graphic.colors.add_event_handler(callback_func)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "bb8a0f95-0063-4cd4-a117-e3d62c6e120d", - "metadata": {}, - "outputs": [], - "source": [ - "# more complex indexing of colors\n", - "# from point 15 - 30, set every 3rd point as \"cyan\"\n", - "cosine_graphic.colors[15:50:3] = \"cyan\"" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "3da9a43b-35bd-4b56-9cc7-967536aac967", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "fig_line.canvas.snapshot()" - ] - }, - { - "cell_type": "markdown", - "id": "c29f81f9-601b-49f4-b20c-575c56e58026", - "metadata": {}, - "source": [ - "Graphic `data` is also indexable" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "d1a4314b-5723-43c7-94a0-b4cbb0e44d60", - "metadata": {}, - "outputs": [], - "source": [ - "cosine_graphic.data[10:50:5, :2] = sine[10:50:5]\n", - "cosine_graphic.data[90:, 1] = 7" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "682db47b-8c7a-4934-9be4-2067e9fb12d5", - "metadata": {}, - "outputs": [], - "source": [ - "cosine_graphic.data[0] = np.array([[-10, 0, 0]])" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "f779cba0-7ee2-4795-8da8-9a9593d3893e", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "fig_line.canvas.snapshot()" - ] - }, - { - "cell_type": "markdown", - "id": "3f6d264b-1b03-407e-9d83-cd6cfb02e706", - "metadata": {}, - "source": [ - "Toggle the presence of a graphic within the scene" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "fcba75b7-9a1e-4aae-9dec-715f7f7456c3", - "metadata": {}, - "outputs": [], - "source": [ - "sinc_graphic.present = False" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "a5e22d0f-a244-47e2-9a2d-1eaf79eda1d9", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "fig_line.canvas.snapshot()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "763b9943-53a4-4e2a-b47a-4e9e5c9d7be3", - "metadata": {}, - "outputs": [], - "source": [ - "sinc_graphic.present = True" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "b22a8660-26b3-4c73-b87a-df9d7cb4353a", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "fig_line.canvas.snapshot()" - ] - }, - { - "cell_type": "markdown", - "id": "86f4e535-ce88-415a-b8d2-53612a2de7b9", - "metadata": {}, - "source": [ - "You can create callbacks to `present` too, for example to re-scale the plot w.r.t. graphics that are present in the scene" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "64a20a16-75a5-4772-a849-630ade9be4ff", - "metadata": {}, - "outputs": [], - "source": [ - "sinc_graphic.present.add_event_handler(fig_line[0, 0].auto_scale)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "fb093046-c94c-4085-86b4-8cd85cb638ff", - "metadata": {}, - "outputs": [], - "source": [ - "sinc_graphic.present = False" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "f9dd6a54-3460-4fb7-bffb-82fd9288902f", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "fig_line.canvas.snapshot()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "f05981c3-c768-4631-ae62-6a8407b20c4c", - "metadata": {}, - "outputs": [], - "source": [ - "sinc_graphic.present = True" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "cb5bf73e-b015-4b4f-82a0-c3ae8cc39ef7", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "fig_line.canvas.snapshot()" - ] - }, - { - "cell_type": "markdown", - "id": "05f93e93-283b-45d8-ab31-8d15a7671dd2", - "metadata": {}, - "source": [ - "You can set the z-positions of graphics to have them appear under or over other graphics" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "6bb33406-5bef-455b-86ea-358a7d3ffa94", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "img = np.random.rand(20, 100)\n", - "\n", - "fig_line[0, 0].add_image(img, name=\"image\", cmap=\"gray\")\n", - "\n", - "# z axis position -1 so it is below all the lines\n", - "fig_line[0, 0][\"image\"].position_z = -1\n", - "fig_line[0, 0][\"image\"].position_x = -50" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "5b586a89-ca3e-4e88-a801-bdd665384f59", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "fig_line.canvas.snapshot()" - ] - }, - { - "cell_type": "markdown", - "id": "2c90862e-2f2a-451f-a468-0cf6b857e87a", - "metadata": {}, - "source": [ - "### 3D line plot" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "9c51229f-13a2-4653-bff3-15d43ddbca7b", - "metadata": {}, - "outputs": [], - "source": [ - "# just set the camera as \"3d\", the rest is basically the same :D \n", - "fig_line_3d = fpl.Figure(cameras='3d')\n", - "\n", - "# create a spiral\n", - "phi = np.linspace(0, 30, 200)\n", - "\n", - "xs = phi * np.cos(phi)\n", - "ys = phi * np.sin(phi)\n", - "zs = phi\n", - "\n", - "# use 3D data\n", - "# note: you usually mix 3D and 2D graphics on the same plot\n", - "spiral = np.dstack([xs, ys, zs])[0]\n", - "\n", - "fig_line_3d[0, 0].add_line(data=spiral, thickness=2, cmap='winter')\n", - "\n", - "fig_line_3d.show()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "28eb7014-4773-4a34-8bfc-bd3a46429012", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "fig_line_3d[0, 0].auto_scale(maintain_aspect=True)" - ] - }, - { - "cell_type": "markdown", - "id": "a202b3d0-2a0b-450a-93d4-76d0a1129d1d", - "metadata": {}, - "source": [ - "## Scatter plots\n", - "\n", - "Plot tens of thousands or millions of points\n", - "\n", - "There might be a small delay for a few seconds before the plot shows, this is due to shaders being compiled and a few other things. The plot should be very fast and responsive once it is displayed and future modifications should also be fast!" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "39252df5-9ae5-4132-b97b-2785c5fa92ea", - "metadata": {}, - "outputs": [], - "source": [ - "# create a random distribution\n", - "# only 1,000 points shown here in the docs, but it can be millions\n", - "n_points = 1_000\n", - "\n", - "# if you have a good GPU go for 1.5 million points :D \n", - "# this is multiplied by 3\n", - "#n_points = 500_000\n", - "\n", - "# dimensions always have to be [n_points, xyz]\n", - "dims = (n_points, 3)\n", - "\n", - "clouds_offset = 15\n", - "\n", - "# create some random clouds\n", - "normal = np.random.normal(size=dims, scale=5)\n", - "# stack the data into a single array\n", - "cloud = np.vstack(\n", - " [\n", - " normal - clouds_offset,\n", - " normal,\n", - " normal + clouds_offset,\n", - " ]\n", - ")\n", - "\n", - "# color each of them separately\n", - "colors = [\"yellow\"] * n_points + [\"cyan\"] * n_points + [\"magenta\"] * n_points\n", - "\n", - "# create plot\n", - "fig_scatter = fpl.Figure()\n", - "\n", - "# use an alpha value since this will be a lot of points\n", - "scatter_graphic = fig_scatter[0, 0].add_scatter(data=cloud, sizes=3, colors=colors, alpha=0.7)\n", - "\n", - "fig_scatter.show()" - ] - }, - { - "cell_type": "markdown", - "id": "b6e4a704-ee6b-4316-956e-acb4dcc1c6f2", - "metadata": {}, - "source": [ - "**Scatter graphic features work similarly to line graphic**" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "8fa46ec0-8680-44f5-894c-559de3145932", - "metadata": {}, - "outputs": [], - "source": [ - "# half of the first cloud's points to red\n", - "scatter_graphic.colors[:n_points:2] = \"r\"" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "293a4793-44b9-4d18-ae6a-68e7c6f91acc", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "fig_scatter.canvas.snapshot()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "e4dc71e4-5144-436f-a464-f2a29eee8f0b", - "metadata": {}, - "outputs": [], - "source": [ - "# set the green value directly\n", - "scatter_graphic.colors[n_points:n_points * 2, 1] = 0.3" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "5ea7852d-fdae-401b-83b6-b6cfd975f64f", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "fig_scatter.canvas.snapshot()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "5b637a29-cd5e-4011-ab81-3f91490d9ecd", - "metadata": {}, - "outputs": [], - "source": [ - "# set color values directly using an array\n", - "scatter_graphic.colors[n_points * 2:] = np.repeat([[1, 1, 0, 0.5]], n_points, axis=0)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "02c19f51-6436-4601-976e-04326df0de81", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "fig_scatter.canvas.snapshot()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "a4084fce-78a2-48b3-9a0d-7b57c165c3c1", - "metadata": {}, - "outputs": [], - "source": [ - "# change the data, change y-values\n", - "scatter_graphic.data[n_points:n_points * 2, 1] += 15" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "2ec43f58-4710-4603-9358-682c4af3f701", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "fig_scatter.canvas.snapshot()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "f486083e-7c58-4255-ae1a-3fe5d9bfaeed", - "metadata": {}, - "outputs": [], - "source": [ - "# set x values directly but using an array\n", - "scatter_graphic.data[n_points:n_points * 2, 0] = np.linspace(-40, 0, n_points)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "6bcb3bc3-4b75-4bbc-b8ca-f8a3219ec3d7", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "fig_scatter.canvas.snapshot()" - ] - }, - { - "cell_type": "markdown", - "id": "d9e554de-c436-4684-a46a-ce8a33d409ac", - "metadata": {}, - "source": [ - "## ipywidget layouts\n", - "\n", - "This just plots everything from these examples in a single output cell" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "01a6f70b-c81b-4ee5-8a6b-d979b87227eb", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "# row1 = HBox([plot.show(), plot_v.show(), plot_sync.show()])\n", - "# row2 = HBox([plot_l.show(), plot_l3d.show(), plot_s.show()])\n", - "\n", - "# VBox([row1, row2])" - ] - }, - { - "cell_type": "markdown", - "id": "a26c0063-b7e0-4f36-bb14-db06bafa31aa", - "metadata": {}, - "source": [ - "## More subplots" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "6b7e1129-ae8e-4a0f-82dc-bd8fb65871fc", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "# Figure of shape 2 x 3 with all controllers synced\n", - "figure_grid = fpl.Figure(shape=(2, 3), controller_ids=\"sync\")\n", - "\n", - "# Make a random image graphic for each subplot\n", - "for subplot in figure_grid:\n", - " # create image data\n", - " data = np.random.rand(512, 512)\n", - " # add an image to the subplot\n", - " subplot.add_image(data, name=\"rand-img\")\n", - "\n", - "# Define a function to update the image graphics with new data\n", - "# add_animations will pass the gridplot to the animation function\n", - "def update_data(f):\n", - " for subplot in f:\n", - " new_data = np.random.rand(512, 512)\n", - " # index the image graphic by name and set the data\n", - " subplot[\"rand-img\"].data = new_data\n", - " \n", - "# add the animation function\n", - "figure_grid.add_animations(update_data)\n", - "\n", - "# show the gridplot \n", - "figure_grid.show()" - ] - }, - { - "cell_type": "markdown", - "id": "f4f71c34-3925-442f-bd76-60dd57d09f48", - "metadata": {}, - "source": [ - "### Slicing GridPlot" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "d8194c9e-9a99-4d4a-8984-a4cfcab0c42c", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "# positional indexing\n", - "# row 0 and col 0\n", - "figure_grid[0, 0]" - ] - }, - { - "cell_type": "markdown", - "id": "d626640f-bc93-4883-9bf4-47b825bbc663", - "metadata": {}, - "source": [ - "You can get the graphics within a subplot, just like with simple `Plot`" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "bffec80c-e81b-4945-85a2-c2c5e8395677", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "figure_grid[0, 1].graphics" - ] - }, - { - "cell_type": "markdown", - "id": "a4e3184f-c86a-4a7e-b803-31632cc163b0", - "metadata": {}, - "source": [ - "and change their properties" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "04b616fb-6644-42ba-8683-0589ce7d165e", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "figure_grid[0, 1].graphics[0].vmax = 0.5" - ] - }, - { - "cell_type": "markdown", - "id": "28f7362c-d1b9-43ef-85c5-4d68f70f459c", - "metadata": {}, - "source": [ - "more slicing with `GridPlot`" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "920e6365-bb50-4882-9b0d-8367dc485360", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "# you can give subplots human-readable string names\n", - "figure_grid[0, 2].name = \"top-right-plot\"" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "73300d2c-3e70-43ad-b5a2-40341b701ac8", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "figure_grid[\"top-right-plot\"]" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "834d9905-35e9-4711-9375-5b1828c80ee2", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "# view its position\n", - "figure_grid[\"top-right-plot\"].position" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "9aa61efa-c6a5-4611-a03b-1b8da66b19f0", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "# these are really the same\n", - "figure_grid[\"top-right-plot\"] is figure_grid[0, 2]" - ] - }, - { - "cell_type": "markdown", - "id": "28c8b145-86cb-4445-92be-b7537a87f7ca", - "metadata": {}, - "source": [ - "Indexing with subplot name and graphic name" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "2b7b73a3-5335-4bd5-bbef-c7d3cfbb3ca7", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "figure_grid[\"top-right-plot\"][\"rand-img\"].vmin = 0.5" - ] - }, - { - "cell_type": "markdown", - "id": "6a5b4368-ae4d-442c-a11f-45c70267339b", - "metadata": {}, - "source": [ - "## Figure subplot customization" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "175d45a6-3351-4b75-8ff3-08797fe0a389", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "# 2 rows and 3 columns\n", - "shape = (2, 3)\n", - "\n", - "# pan-zoom controllers for each view\n", - "# views are synced if they have the \n", - "# same controller ID\n", - "controller_ids = [\n", - " [0, 3, 1], # id each controller with an integer\n", - " [2, 2, 3]\n", - "]\n", - "\n", - "\n", - "# you can give string names for each subplot within the gridplot\n", - "names = [\n", - " [\"subplot0\", \"subplot1\", \"subplot2\"],\n", - " [\"subplot3\", \"subplot4\", \"subplot5\"]\n", - "]\n", - "\n", - "# Create the grid plot\n", - "figure_grid = fpl.Figure(\n", - " shape=shape,\n", - " controller_ids=controller_ids,\n", - " names=names,\n", - ")\n", - "\n", - "\n", - "# Make a random image graphic for each subplot\n", - "for subplot in figure_grid:\n", - " data = np.random.rand(512, 512)\n", - " # create and add an ImageGraphic\n", - " subplot.add_image(data=data, name=\"rand-image\")\n", - " \n", - "\n", - "# Define a function to update the image graphics \n", - "# with new randomly generated data\n", - "def set_random_frame(gp):\n", - " for subplot in gp:\n", - " new_data = np.random.rand(512, 512)\n", - " subplot[\"rand-image\"].data = new_data\n", - "\n", - "# add the animation\n", - "figure_grid.add_animations(set_random_frame)\n", - "figure_grid.show()" - ] - }, - { - "cell_type": "markdown", - "id": "4224f1c2-5e61-4894-8d72-0519598a3cef", - "metadata": {}, - "source": [ - "Indexing the gridplot to access subplots" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "d88dd9b2-9359-42e8-9dfb-96dcbbb34b95", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "# can access subplot by name\n", - "figure_grid[\"subplot0\"]" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "a14df7ea-14c3-4a8a-84f2-2e2194236d9e", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "# can access subplot by index\n", - "figure_grid[0, 0]" - ] - }, - { - "cell_type": "markdown", - "id": "5f8a3427-7949-40a4-aec2-38d5d95ef156", - "metadata": {}, - "source": [ - "**subplots also support indexing!**\n", - "\n", - "this can be used to get graphics if they are named" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "8c99fee0-ce46-4f18-8300-af025c9a967c", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "# can access graphic directly via name\n", - "figure_grid[\"subplot0\"][\"rand-image\"]" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "ed4eebb7-826d-4856-bbb8-db2de966a0c3", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "figure_grid[\"subplot0\"][\"rand-image\"].vmin = 0.6\n", - "figure_grid[\"subplot0\"][\"rand-image\"].vmax = 0.8" - ] - }, - { - "cell_type": "markdown", - "id": "ad322f6f-e7de-4eb3-a1d9-cf28701a2eae", - "metadata": {}, - "source": [ - "positional indexing also works event if subplots have string names" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "759d3966-d92b-460f-ba48-e57adabbf163", - "metadata": { - "tags": [] - }, - "outputs": [], - "source": [ - "figure_grid[1, 0][\"rand-image\"].vim = 0.1\n", - "figure_grid[1, 0][\"rand-image\"].vmax = 0.3" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.12.3" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} diff --git a/setup.py b/setup.py index 832b8fc9d..5120d9dff 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,6 @@ "ipywidgets>=8.0.0,<9", "sphinx-copybutton", "sphinx-design", - "nbsphinx", "pandoc", "jupyterlab", "sidecar", From dacc382e729e7f6fd7488faadcce534a48928e4c Mon Sep 17 00:00:00 2001 From: Caitlin Date: Tue, 4 Jun 2024 13:53:24 -0400 Subject: [PATCH 11/32] remove init files from examples --- examples/desktop/gridplot/__init__.py | 0 examples/desktop/heatmap/__init__.py | 0 examples/desktop/image/__init__.py | 0 examples/desktop/line/__init__.py | 0 examples/desktop/line_collection/__init__.py | 0 examples/desktop/scatter/__init__.py | 0 6 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 examples/desktop/gridplot/__init__.py delete mode 100644 examples/desktop/heatmap/__init__.py delete mode 100644 examples/desktop/image/__init__.py delete mode 100644 examples/desktop/line/__init__.py delete mode 100644 examples/desktop/line_collection/__init__.py delete mode 100644 examples/desktop/scatter/__init__.py diff --git a/examples/desktop/gridplot/__init__.py b/examples/desktop/gridplot/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/examples/desktop/heatmap/__init__.py b/examples/desktop/heatmap/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/examples/desktop/image/__init__.py b/examples/desktop/image/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/examples/desktop/line/__init__.py b/examples/desktop/line/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/examples/desktop/line_collection/__init__.py b/examples/desktop/line_collection/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/examples/desktop/scatter/__init__.py b/examples/desktop/scatter/__init__.py deleted file mode 100644 index e69de29bb..000000000 From 985eb2ed3965583a6d28f0f7088663d412d537ca Mon Sep 17 00:00:00 2001 From: Caitlin Date: Wed, 5 Jun 2024 11:16:26 -0400 Subject: [PATCH 12/32] update examples and conf.py --- docs/source/conf.py | 12 ++++++++++-- examples/desktop/gridplot/gridplot.py | 3 +++ examples/desktop/gridplot/gridplot_non_square.py | 3 +++ examples/desktop/heatmap/heatmap.py | 11 +++++++---- examples/desktop/heatmap/heatmap_cmap.py | 11 +++++++---- examples/desktop/heatmap/heatmap_data.py | 14 ++++++++------ examples/desktop/heatmap/heatmap_vmin_vmax.py | 11 +++++++---- examples/desktop/image/image_cmap.py | 3 +++ examples/desktop/image/image_rgb.py | 4 +++- examples/desktop/image/image_rgbvminvmax.py | 4 +++- examples/desktop/image/image_simple.py | 3 +++ examples/desktop/image/image_vminvmax.py | 4 +++- examples/desktop/image/image_widget.py | 6 ++---- examples/desktop/line/line.py | 12 +++++++----- examples/desktop/line/line_cmap.py | 11 +++++++---- examples/desktop/line/line_colorslice.py | 12 +++++++----- examples/desktop/line/line_dataslice.py | 12 +++++++----- examples/desktop/line/line_present_scaling.py | 12 +++++++----- .../desktop/line_collection/line_collection.py | 11 +++++++---- .../line_collection/line_collection_cmap_values.py | 11 +++++++---- .../line_collection_cmap_values_qualitative.py | 11 +++++++---- .../line_collection/line_collection_colors.py | 3 +++ examples/desktop/line_collection/line_stack.py | 9 ++++++--- examples/desktop/misc/animation.py | 0 examples/desktop/scatter/scatter.py | 9 ++++++--- examples/desktop/scatter/scatter_cmap.py | 9 ++++++--- examples/desktop/scatter/scatter_colorslice.py | 9 ++++++--- examples/desktop/scatter/scatter_dataslice.py | 9 ++++++--- examples/desktop/scatter/scatter_present.py | 9 ++++++--- examples/desktop/scatter/scatter_size.py | 3 +++ 30 files changed, 160 insertions(+), 81 deletions(-) create mode 100644 examples/desktop/misc/animation.py diff --git a/docs/source/conf.py b/docs/source/conf.py index 2ab374fe4..df0287c3e 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -3,9 +3,10 @@ # For the full list of built-in configuration values, see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html -# Force offscreen rendering import os +# need to force offscreen rendering before importing fpl +# otherwise fpl tries to select glfw canvas os.environ["WGPU_FORCE_OFFSCREEN"] = "1" import fastplotlib @@ -13,9 +14,10 @@ from pathlib import Path import sys from sphinx_gallery.sorting import ExplicitOrder +import imageio.v3 as iio ROOT_DIR = Path(__file__).parents[1].parents[0] # repo root -EXAMPLES_DIR = ROOT_DIR / "examples" / "desktop" +EXAMPLES_DIR = Path.joinpath(ROOT_DIR, "examples", "desktop") sys.path.insert(0, str(ROOT_DIR)) @@ -65,6 +67,12 @@ extra_conf = find_examples_for_gallery(EXAMPLES_DIR) sphinx_gallery_conf.update(extra_conf) +# download imageio examples for the gallery +iio.imread("imageio:clock.png") +iio.imread("imageio:astronaut.png") +iio.imread("imageio:coffee.png") +iio.imread("imageio:hubble_deep_field.png") + autosummary_generate = True templates_path = ["_templates"] diff --git a/examples/desktop/gridplot/gridplot.py b/examples/desktop/gridplot/gridplot.py index 8eabc7e4e..919255e20 100644 --- a/examples/desktop/gridplot/gridplot.py +++ b/examples/desktop/gridplot/gridplot.py @@ -24,6 +24,7 @@ fig[1, 1].add_image(data=im4) # set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users canvas = fig.canvas fig.show() @@ -33,6 +34,8 @@ for subplot in fig: subplot.auto_scale() +# 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.run() diff --git a/examples/desktop/gridplot/gridplot_non_square.py b/examples/desktop/gridplot/gridplot_non_square.py index 15888c766..d2db7be32 100644 --- a/examples/desktop/gridplot/gridplot_non_square.py +++ b/examples/desktop/gridplot/gridplot_non_square.py @@ -24,6 +24,7 @@ fig.show() # set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users canvas = fig.canvas fig.canvas.set_logical_size(800, 800) @@ -31,6 +32,8 @@ for subplot in fig: subplot.auto_scale() +# 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.run() diff --git a/examples/desktop/heatmap/heatmap.py b/examples/desktop/heatmap/heatmap.py index 22bfaae2c..f6a209197 100644 --- a/examples/desktop/heatmap/heatmap.py +++ b/examples/desktop/heatmap/heatmap.py @@ -9,11 +9,8 @@ import fastplotlib as fpl import numpy as np -from wgpu.gui.offscreen import WgpuCanvas -canvas = WgpuCanvas() - -fig = fpl.Figure(canvas=canvas) +fig = fpl.Figure() xs = np.linspace(0, 1_000, 10_000) @@ -30,10 +27,16 @@ fig.show() +# set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users +canvas = fig.canvas + fig.canvas.set_logical_size(1500, 1500) fig[0, 0].auto_scale() +# 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.run() diff --git a/examples/desktop/heatmap/heatmap_cmap.py b/examples/desktop/heatmap/heatmap_cmap.py index c86e7c647..176782fd6 100644 --- a/examples/desktop/heatmap/heatmap_cmap.py +++ b/examples/desktop/heatmap/heatmap_cmap.py @@ -9,11 +9,8 @@ import fastplotlib as fpl import numpy as np -from wgpu.gui.offscreen import WgpuCanvas -canvas = WgpuCanvas() - -fig = fpl.Figure(canvas=canvas) +fig = fpl.Figure() xs = np.linspace(0, 1_000, 10_000) @@ -30,12 +27,18 @@ fig.show() +# set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users +canvas = fig.canvas + fig.canvas.set_logical_size(1500, 1500) fig[0, 0].auto_scale() heatmap_graphic.cmap = "viridis" +# 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.run() diff --git a/examples/desktop/heatmap/heatmap_data.py b/examples/desktop/heatmap/heatmap_data.py index bd724c53a..f3717a881 100644 --- a/examples/desktop/heatmap/heatmap_data.py +++ b/examples/desktop/heatmap/heatmap_data.py @@ -5,15 +5,12 @@ """ # test_example = true -# sphinx_gallery_pygfx_docs = 'hidden' +# sphinx_gallery_pygfx_docs = 'screenshot' import fastplotlib as fpl import numpy as np -from wgpu.gui.offscreen import WgpuCanvas -canvas = WgpuCanvas() - -fig = fpl.Figure(canvas=canvas) +fig = fpl.Figure() xs = np.linspace(0, 1_000, 10_000) @@ -30,6 +27,10 @@ fig.show() +# set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users +canvas = fig.canvas + fig.canvas.set_logical_size(1500, 1500) fig[0, 0].auto_scale() @@ -37,7 +38,8 @@ heatmap_graphic.data[:5_000] = sine heatmap_graphic.data[5_000:] = cosine - +# 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.run() diff --git a/examples/desktop/heatmap/heatmap_vmin_vmax.py b/examples/desktop/heatmap/heatmap_vmin_vmax.py index db3629124..2053e6a3e 100644 --- a/examples/desktop/heatmap/heatmap_vmin_vmax.py +++ b/examples/desktop/heatmap/heatmap_vmin_vmax.py @@ -9,11 +9,8 @@ import fastplotlib as fpl import numpy as np -from wgpu.gui.offscreen import WgpuCanvas -canvas = WgpuCanvas() - -fig = fpl.Figure(canvas=canvas) +fig = fpl.Figure() xs = np.linspace(0, 1_000, 10_000) @@ -30,6 +27,10 @@ fig.show() +# set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users +canvas = fig.canvas + fig.canvas.set_logical_size(1500, 1500) fig[0, 0].auto_scale() @@ -37,6 +38,8 @@ heatmap_graphic.cmap.vmin = -0.5 heatmap_graphic.cmap.vmax = 0.5 +# 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.run() diff --git a/examples/desktop/image/image_cmap.py b/examples/desktop/image/image_cmap.py index fd7a27d62..33ef49d2f 100644 --- a/examples/desktop/image/image_cmap.py +++ b/examples/desktop/image/image_cmap.py @@ -21,6 +21,7 @@ fig.show() # set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users canvas = fig.canvas fig.canvas.set_logical_size(800, 800) @@ -29,6 +30,8 @@ image_graphic.cmap = "viridis" +# 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.run() diff --git a/examples/desktop/image/image_rgb.py b/examples/desktop/image/image_rgb.py index e82fd536d..020c29812 100644 --- a/examples/desktop/image/image_rgb.py +++ b/examples/desktop/image/image_rgb.py @@ -21,13 +21,15 @@ fig.show() # set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users canvas = fig.canvas fig.canvas.set_logical_size(800, 800) fig[0, 0].auto_scale() - +# 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.run() diff --git a/examples/desktop/image/image_rgbvminvmax.py b/examples/desktop/image/image_rgbvminvmax.py index 807aeedb1..42eef4eb3 100644 --- a/examples/desktop/image/image_rgbvminvmax.py +++ b/examples/desktop/image/image_rgbvminvmax.py @@ -21,6 +21,7 @@ fig.show() # set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users canvas = fig.canvas fig.canvas.set_logical_size(800, 800) @@ -30,7 +31,8 @@ image_graphic.cmap.vmin = 0.5 image_graphic.cmap.vmax = 0.75 - +# 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.run() diff --git a/examples/desktop/image/image_simple.py b/examples/desktop/image/image_simple.py index 811cc41cb..90268f945 100644 --- a/examples/desktop/image/image_simple.py +++ b/examples/desktop/image/image_simple.py @@ -21,12 +21,15 @@ fig.show() # set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users canvas = fig.canvas fig.canvas.set_logical_size(800, 800) fig[0, 0].auto_scale() +# 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.run() diff --git a/examples/desktop/image/image_vminvmax.py b/examples/desktop/image/image_vminvmax.py index ed712eacd..1600ca457 100644 --- a/examples/desktop/image/image_vminvmax.py +++ b/examples/desktop/image/image_vminvmax.py @@ -21,6 +21,7 @@ fig.show() # set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users canvas = fig.canvas fig.canvas.set_logical_size(800, 800) @@ -30,7 +31,8 @@ image_graphic.cmap.vmin = 0.5 image_graphic.cmap.vmax = 0.75 - +# 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.run() diff --git a/examples/desktop/image/image_widget.py b/examples/desktop/image/image_widget.py index 8f3dd5698..de1d27de1 100644 --- a/examples/desktop/image/image_widget.py +++ b/examples/desktop/image/image_widget.py @@ -15,10 +15,8 @@ iw = fpl.ImageWidget(data=a, cmap="viridis") iw.show() -# set canvas variable for sphinx_gallery to properly generate examples -canvas = iw.figure.canvas - - +# 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.run() diff --git a/examples/desktop/line/line.py b/examples/desktop/line/line.py index 2aa62841d..c9c96c049 100644 --- a/examples/desktop/line/line.py +++ b/examples/desktop/line/line.py @@ -10,11 +10,8 @@ import fastplotlib as fpl import numpy as np -from wgpu.gui.offscreen import WgpuCanvas -canvas = WgpuCanvas() - -fig = fpl.Figure(canvas=canvas) +fig = fpl.Figure() xs = np.linspace(-10, 10, 100) # sine wave @@ -41,11 +38,16 @@ fig.show() +# set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users +canvas = fig.canvas + fig.canvas.set_logical_size(800, 800) fig[0, 0].auto_scale() - +# 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.run() diff --git a/examples/desktop/line/line_cmap.py b/examples/desktop/line/line_cmap.py index 23cf70887..973eb16d3 100644 --- a/examples/desktop/line/line_cmap.py +++ b/examples/desktop/line/line_cmap.py @@ -10,11 +10,8 @@ import fastplotlib as fpl import numpy as np -from wgpu.gui.offscreen import WgpuCanvas -canvas = WgpuCanvas() - -fig = fpl.Figure(canvas=canvas) +fig = fpl.Figure() xs = np.linspace(-10, 10, 100) # sine wave @@ -44,8 +41,14 @@ fig.show() +# set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users +canvas = fig.canvas + fig.canvas.set_logical_size(800, 800) +# 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.run() diff --git a/examples/desktop/line/line_colorslice.py b/examples/desktop/line/line_colorslice.py index 8e479e9b5..0795644ea 100644 --- a/examples/desktop/line/line_colorslice.py +++ b/examples/desktop/line/line_colorslice.py @@ -10,11 +10,8 @@ import fastplotlib as fpl import numpy as np -from wgpu.gui.offscreen import WgpuCanvas -canvas = WgpuCanvas() - -fig = fpl.Figure(canvas=canvas) +fig = fpl.Figure() xs = np.linspace(-10, 10, 100) # sine wave @@ -41,6 +38,10 @@ fig.show() +# set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users +canvas = fig.canvas + # indexing of colors cosine_graphic.colors[:15] = "magenta" cosine_graphic.colors[90:] = "red" @@ -64,7 +65,8 @@ fig[0, 0].auto_scale() - +# 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.run() diff --git a/examples/desktop/line/line_dataslice.py b/examples/desktop/line/line_dataslice.py index 7eb802b12..9ec64c5c2 100644 --- a/examples/desktop/line/line_dataslice.py +++ b/examples/desktop/line/line_dataslice.py @@ -10,11 +10,8 @@ import fastplotlib as fpl import numpy as np -from wgpu.gui.offscreen import WgpuCanvas -canvas = WgpuCanvas() - -fig = fpl.Figure(canvas=canvas) +fig = fpl.Figure() xs = np.linspace(-10, 10, 100) # sine wave @@ -41,6 +38,10 @@ fig.show() +# set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users +canvas = fig.canvas + cosine_graphic.data[10:50:5, :2] = sine[10:50:5] cosine_graphic.data[90:, 1] = 7 cosine_graphic.data[0] = np.array([[-10, 0, 0]]) @@ -53,7 +54,8 @@ fig[0, 0].auto_scale() - +# 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.run() diff --git a/examples/desktop/line/line_present_scaling.py b/examples/desktop/line/line_present_scaling.py index 6f49f6daa..e46bbffc8 100644 --- a/examples/desktop/line/line_present_scaling.py +++ b/examples/desktop/line/line_present_scaling.py @@ -10,11 +10,8 @@ import fastplotlib as fpl import numpy as np -from wgpu.gui.offscreen import WgpuCanvas -canvas = WgpuCanvas() - -fig = fpl.Figure(canvas=canvas) +fig = fpl.Figure() xs = np.linspace(-10, 10, 100) # sine wave @@ -41,13 +38,18 @@ fig.show() +# set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users +canvas = fig.canvas + sinc_graphic.present = False fig.canvas.set_logical_size(800, 800) fig[0, 0].auto_scale() - +# 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.run() diff --git a/examples/desktop/line_collection/line_collection.py b/examples/desktop/line_collection/line_collection.py index 2fd1531c9..9ea2cab18 100644 --- a/examples/desktop/line_collection/line_collection.py +++ b/examples/desktop/line_collection/line_collection.py @@ -11,9 +11,6 @@ from itertools import product import numpy as np import fastplotlib as fpl -from wgpu.gui.offscreen import WgpuCanvas - -canvas = WgpuCanvas() def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray: @@ -32,7 +29,11 @@ def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray: pos_xy = np.vstack(circles) -fig = fpl.Figure(canvas=canvas) +fig = fpl.Figure() + +# set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users +canvas = fig.canvas fig[0, 0].add_line_collection(circles, cmap="jet", thickness=5) @@ -40,6 +41,8 @@ def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray: fig.canvas.set_logical_size(800, 800) +# 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.run() diff --git a/examples/desktop/line_collection/line_collection_cmap_values.py b/examples/desktop/line_collection/line_collection_cmap_values.py index 8b6db5849..3b14e6e2f 100644 --- a/examples/desktop/line_collection/line_collection_cmap_values.py +++ b/examples/desktop/line_collection/line_collection_cmap_values.py @@ -11,9 +11,6 @@ from itertools import product import numpy as np import fastplotlib as fpl -from wgpu.gui.offscreen import WgpuCanvas - -canvas = WgpuCanvas() def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray: theta = np.linspace(0, 2 * np.pi, n_points) @@ -37,7 +34,7 @@ def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray: # highest values, lowest values, mid-high values, mid values cmap_values = [10] * 4 + [0] * 4 + [7] * 4 + [5] * 4 -fig = fpl.Figure(canvas=canvas) +fig = fpl.Figure() fig[0, 0].add_line_collection( circles, @@ -48,8 +45,14 @@ def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray: fig.show() +# set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users +canvas = fig.canvas + fig.canvas.set_logical_size(800, 800) +# 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.run() diff --git a/examples/desktop/line_collection/line_collection_cmap_values_qualitative.py b/examples/desktop/line_collection/line_collection_cmap_values_qualitative.py index 099be2a6d..da04afd05 100644 --- a/examples/desktop/line_collection/line_collection_cmap_values_qualitative.py +++ b/examples/desktop/line_collection/line_collection_cmap_values_qualitative.py @@ -11,9 +11,6 @@ from itertools import product import numpy as np import fastplotlib as fpl -from wgpu.gui.offscreen import WgpuCanvas - -canvas = WgpuCanvas() def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray: theta = np.linspace(0, 2 * np.pi, n_points) @@ -43,7 +40,7 @@ def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray: 1, 1, 1, 5 ] -fig = fpl.Figure(canvas=canvas) +fig = fpl.Figure() fig[0, 0].add_line_collection( circles, @@ -54,8 +51,14 @@ def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray: fig.show() +# set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users +canvas = fig.canvas + fig.canvas.set_logical_size(800, 800) +# 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.run() diff --git a/examples/desktop/line_collection/line_collection_colors.py b/examples/desktop/line_collection/line_collection_colors.py index 621c5fe75..d63dbe2a0 100644 --- a/examples/desktop/line_collection/line_collection_colors.py +++ b/examples/desktop/line_collection/line_collection_colors.py @@ -36,6 +36,7 @@ def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray: fig = fpl.Figure() # set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users canvas = fig.canvas fig[0, 0].add_line_collection(circles, colors=colors, thickness=10) @@ -44,6 +45,8 @@ def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray: fig.canvas.set_logical_size(800, 800) +# 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.run() diff --git a/examples/desktop/line_collection/line_stack.py b/examples/desktop/line_collection/line_stack.py index a78061056..cd1c5c331 100644 --- a/examples/desktop/line_collection/line_stack.py +++ b/examples/desktop/line_collection/line_stack.py @@ -20,16 +20,19 @@ fig = fpl.Figure() -# set canvas variable for sphinx_gallery to properly generate examples -canvas = fig.canvas - # line stack takes all the same arguments as line collection and behaves similarly fig[0, 0].add_line_stack(data, cmap="jet") fig.show(maintain_aspect=False) +# set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users +canvas = fig.canvas + fig.canvas.set_logical_size(900, 600) +# 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.run() diff --git a/examples/desktop/misc/animation.py b/examples/desktop/misc/animation.py new file mode 100644 index 000000000..e69de29bb diff --git a/examples/desktop/scatter/scatter.py b/examples/desktop/scatter/scatter.py index 11cb5b3ff..79b843eaf 100644 --- a/examples/desktop/scatter/scatter.py +++ b/examples/desktop/scatter/scatter.py @@ -5,15 +5,16 @@ """ # test_example = true -# sphinx_gallery_pygfx_docs = 'hidden' +# sphinx_gallery_pygfx_docs = 'screenshot' import fastplotlib as fpl import numpy as np from pathlib import Path +import os fig = fpl.Figure() -data_path = Path(__file__).parent.parent.joinpath("data", "iris.npy") +data_path = Path(os.getcwd()).parent.joinpath("data", "iris.npy") data = np.load(data_path) n_points = 50 @@ -22,6 +23,7 @@ scatter_graphic = fig[0, 0].add_scatter(data=data[:, :-1], sizes=6, alpha=0.7, colors=colors) # set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users canvas = fig.canvas fig.show() @@ -30,7 +32,8 @@ fig[0, 0].auto_scale() - +# 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.run() diff --git a/examples/desktop/scatter/scatter_cmap.py b/examples/desktop/scatter/scatter_cmap.py index a01e7daf2..8b1df4b0c 100644 --- a/examples/desktop/scatter/scatter_cmap.py +++ b/examples/desktop/scatter/scatter_cmap.py @@ -5,16 +5,17 @@ """ # test_example = true -# sphinx_gallery_pygfx_docs = 'hidden' +# sphinx_gallery_pygfx_docs = 'screenshot' import fastplotlib as fpl import numpy as np from pathlib import Path from sklearn.cluster import AgglomerativeClustering +import os fig = fpl.Figure() -data_path = Path(__file__).parent.parent.joinpath("data", "iris.npy") +data_path = Path(os.getcwd()).parent.joinpath("data", "iris.npy") data = np.load(data_path) agg = AgglomerativeClustering(n_clusters=3) @@ -25,6 +26,7 @@ ) # set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users canvas = fig.canvas fig.show() @@ -35,7 +37,8 @@ scatter_graphic.cmap = "tab10" - +# 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.run() diff --git a/examples/desktop/scatter/scatter_colorslice.py b/examples/desktop/scatter/scatter_colorslice.py index fdf4b25eb..f9f32160f 100644 --- a/examples/desktop/scatter/scatter_colorslice.py +++ b/examples/desktop/scatter/scatter_colorslice.py @@ -5,16 +5,17 @@ """ # test_example = true -# sphinx_gallery_pygfx_docs = 'hidden' +# sphinx_gallery_pygfx_docs = 'screenshot' import fastplotlib as fpl import numpy as np from pathlib import Path +import os fig = fpl.Figure() -data_path = Path(__file__).parent.parent.joinpath("data", "iris.npy") +data_path = Path(os.getcwd()).parent.joinpath("data", "iris.npy") data = np.load(data_path) n_points = 50 @@ -25,6 +26,7 @@ fig.show() # set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users canvas = fig.canvas fig.canvas.set_logical_size(800, 800) @@ -35,7 +37,8 @@ scatter_graphic.colors[75:150] = "white" scatter_graphic.colors[::2] = "blue" - +# 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.run() diff --git a/examples/desktop/scatter/scatter_dataslice.py b/examples/desktop/scatter/scatter_dataslice.py index dfbfa8fc2..d633eb613 100644 --- a/examples/desktop/scatter/scatter_dataslice.py +++ b/examples/desktop/scatter/scatter_dataslice.py @@ -5,16 +5,17 @@ """ # test_example = true -# sphinx_gallery_pygfx_docs = 'hidden' +# sphinx_gallery_pygfx_docs = 'screenshot' import fastplotlib as fpl import numpy as np from pathlib import Path +import os fig = fpl.Figure() -data_path = Path(__file__).parent.parent.joinpath("data", "iris.npy") +data_path = Path(os.getcwd()).parent.joinpath("data", "iris.npy") data = np.load(data_path) n_points = 50 @@ -23,6 +24,7 @@ scatter_graphic = fig[0, 0].add_scatter(data=data[:, :-1], sizes=6, alpha=0.7, colors=colors) # set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users canvas = fig.canvas fig.show() @@ -38,7 +40,8 @@ scatter_graphic.data[10:15] = scatter_graphic.data[0:5] + np.array([1, 1, 1]) scatter_graphic.data[50:100:2] = scatter_graphic.data[100:150:2] + np.array([1, 1, 0]) - +# 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.run() diff --git a/examples/desktop/scatter/scatter_present.py b/examples/desktop/scatter/scatter_present.py index 6f46fe7ac..85ec9ef87 100644 --- a/examples/desktop/scatter/scatter_present.py +++ b/examples/desktop/scatter/scatter_present.py @@ -5,15 +5,16 @@ """ # test_example = true -# sphinx_gallery_pygfx_docs = 'hidden' +# sphinx_gallery_pygfx_docs = 'screenshot' import fastplotlib as fpl import numpy as np from pathlib import Path +import os fig = fpl.Figure() -data_path = Path(__file__).parent.parent.joinpath("data", "iris.npy") +data_path = Path(os.getcwd()).parent.joinpath("data", "iris.npy") data = np.load(data_path) n_points = 50 @@ -27,6 +28,7 @@ fig.show() # set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users canvas = fig.canvas fig.canvas.set_logical_size(800, 800) @@ -35,7 +37,8 @@ scatter_graphic.present = False - +# 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.run() diff --git a/examples/desktop/scatter/scatter_size.py b/examples/desktop/scatter/scatter_size.py index d2731be1c..6f43b5dff 100644 --- a/examples/desktop/scatter/scatter_size.py +++ b/examples/desktop/scatter/scatter_size.py @@ -27,6 +27,7 @@ data = np.column_stack([x_values, y_values]) # set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users canvas = fig.canvas fig["scalar_size"].add_scatter( @@ -41,6 +42,8 @@ fig.show() +# 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.run() From 79b6e7f134a4c629fa8bdf03769df065959e22b8 Mon Sep 17 00:00:00 2001 From: Caitlin Date: Wed, 5 Jun 2024 11:52:14 -0400 Subject: [PATCH 13/32] add animation examples, edit conf.py, fix scatter examples --- docs/source/conf.py | 5 +- examples/desktop/misc/README.rst | 2 + examples/desktop/misc/animation.py | 0 examples/desktop/misc/image_animation.py | 42 +++++++++++++ examples/desktop/misc/line_animation.py | 55 ++++++++++++++++ examples/desktop/misc/scatter_animation.py | 63 +++++++++++++++++++ examples/desktop/scatter/scatter.py | 6 +- examples/desktop/scatter/scatter_cmap.py | 6 +- .../desktop/scatter/scatter_colorslice.py | 6 +- examples/desktop/scatter/scatter_dataslice.py | 6 +- examples/desktop/scatter/scatter_present.py | 6 +- 11 files changed, 185 insertions(+), 12 deletions(-) create mode 100644 examples/desktop/misc/README.rst delete mode 100644 examples/desktop/misc/animation.py create mode 100644 examples/desktop/misc/image_animation.py create mode 100644 examples/desktop/misc/line_animation.py create mode 100644 examples/desktop/misc/scatter_animation.py diff --git a/docs/source/conf.py b/docs/source/conf.py index df0287c3e..e12223530 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -56,7 +56,8 @@ "../../examples/desktop/line", "../../examples/desktop/line_collection", "../../examples/desktop/scatter", - "../../examples/desktop/heatmap" + "../../examples/desktop/heatmap", + "../../examples/desktop/misc" ] ), "ignore_pattern": r'__init__\.py', @@ -104,7 +105,7 @@ } html_theme_options = { - "source_repository": "https://github.com/kushalkolar/fastplotlib", + "source_repository": "https://github.com/fastplotlib/fastplotlib", "source_branch": "main", "source_directory": "docs/", } diff --git a/examples/desktop/misc/README.rst b/examples/desktop/misc/README.rst new file mode 100644 index 000000000..cc51fd686 --- /dev/null +++ b/examples/desktop/misc/README.rst @@ -0,0 +1,2 @@ +Other Examples +============== diff --git a/examples/desktop/misc/animation.py b/examples/desktop/misc/animation.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/examples/desktop/misc/image_animation.py b/examples/desktop/misc/image_animation.py new file mode 100644 index 000000000..3ea656e29 --- /dev/null +++ b/examples/desktop/misc/image_animation.py @@ -0,0 +1,42 @@ +""" +Simple Image Update +=================== + +Example showing updating a single plot with new random 512x512 data. +""" + +# test_example = false +# sphinx_gallery_pygfx_docs = 'animate' + +import fastplotlib as fpl +import numpy as np + +data = np.random.rand(512, 512) + +fig = fpl.Figure() + +# plot the image data +image_graphic = fig[0, 0].add_image(data=data, name="random-image") + + +# a function to update the image_graphic +# a figure-level animation function will optionally take the figure as an argument +def update_data(figure_instance): + new_data = np.random.rand(512, 512) + figure_instance[0, 0]["random-image"].data = new_data + +fig.add_animations(update_data) + +fig.show() + +# set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users +canvas = fig.canvas + +fig.canvas.set_logical_size(800, 800) + +# 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.run() diff --git a/examples/desktop/misc/line_animation.py b/examples/desktop/misc/line_animation.py new file mode 100644 index 000000000..36fbb6c2f --- /dev/null +++ b/examples/desktop/misc/line_animation.py @@ -0,0 +1,55 @@ +""" +Simple Line Animation +===================== + +Example showing animation with lines. +""" + +# test_example = false +# sphinx_gallery_pygfx_docs = 'animate' + +import fastplotlib as fpl +import numpy as np + +# generate some data +start, stop = 0, 2 * np.pi +increment = (2 * np.pi) / 50 + +# make a simple sine wave +xs = np.linspace(start, stop, 100) +ys = np.sin(xs) + +fig = fpl.Figure() + +# plot the image data +sine = fig[0, 0].add_line(ys, name="sine", colors="r") + + +# increment along the x-axis on each render loop :D +def update_line(subplot): + global increment, start, stop + xs = np.linspace(start + increment, stop + increment, 100) + ys = np.sin(xs) + + start += increment + stop += increment + + # change only the y-axis values of the line + subplot["sine"].data[:, 1] = ys + + +fig[0, 0].add_animations(update_line) + +fig.show() + +# set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users +canvas = fig.canvas + +fig.canvas.set_logical_size(800, 800) + +# 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.run() \ No newline at end of file diff --git a/examples/desktop/misc/scatter_animation.py b/examples/desktop/misc/scatter_animation.py new file mode 100644 index 000000000..adf2b156b --- /dev/null +++ b/examples/desktop/misc/scatter_animation.py @@ -0,0 +1,63 @@ +""" +Scatter Animation +================= + +Example showing animation with a scatter plot. +""" + +# test_example = false +# sphinx_gallery_pygfx_docs = 'animate' + +import fastplotlib as fpl +import numpy as np + +# create a random distribution of 10,000 xyz coordinates +n_points = 10_000 + +# dimensions always have to be [n_points, xyz] +dims = (n_points, 3) + +clouds_offset = 15 + +# create some random clouds +normal = np.random.normal(size=dims, scale=5) +# stack the data into a single array +cloud = np.vstack( + [ + normal - clouds_offset, + normal, + normal + clouds_offset, + ] +) + +# color each of them separately +colors = ["yellow"] * n_points + ["cyan"] * n_points + ["magenta"] * n_points + +# create plot +fig_scatter = fpl.Figure() +subplot_scatter = fig_scatter[0, 0] +# use an alpha value since this will be a lot of points +scatter_graphic = subplot_scatter.add_scatter(data=cloud, sizes=3, colors=colors, alpha=0.6) + + +def update_points(subplot): + # move every point by a small amount + deltas = np.random.normal(size=scatter_graphic.data().shape, loc=0, scale=0.15) + scatter_graphic.data = scatter_graphic.data() + deltas + + +subplot_scatter.add_animations(update_points) + +fig_scatter.show() + +# set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users +canvas = fig_scatter.canvas + +fig_scatter.canvas.set_logical_size(800, 800) + +# 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.run() \ No newline at end of file diff --git a/examples/desktop/scatter/scatter.py b/examples/desktop/scatter/scatter.py index 79b843eaf..1a110605d 100644 --- a/examples/desktop/scatter/scatter.py +++ b/examples/desktop/scatter/scatter.py @@ -10,11 +10,13 @@ import fastplotlib as fpl import numpy as np from pathlib import Path -import os +import sys fig = fpl.Figure() -data_path = Path(os.getcwd()).parent.joinpath("data", "iris.npy") +current_file = Path(sys.argv[0]).resolve() + +data_path = Path(current_file.parent.parent.joinpath("data", "iris.npy")) data = np.load(data_path) n_points = 50 diff --git a/examples/desktop/scatter/scatter_cmap.py b/examples/desktop/scatter/scatter_cmap.py index 8b1df4b0c..4b8d1d315 100644 --- a/examples/desktop/scatter/scatter_cmap.py +++ b/examples/desktop/scatter/scatter_cmap.py @@ -11,11 +11,13 @@ import numpy as np from pathlib import Path from sklearn.cluster import AgglomerativeClustering -import os +import sys fig = fpl.Figure() -data_path = Path(os.getcwd()).parent.joinpath("data", "iris.npy") +current_file = Path(sys.argv[0]).resolve() + +data_path = Path(current_file.parent.parent.joinpath("data", "iris.npy")) data = np.load(data_path) agg = AgglomerativeClustering(n_clusters=3) diff --git a/examples/desktop/scatter/scatter_colorslice.py b/examples/desktop/scatter/scatter_colorslice.py index f9f32160f..c12c1a0c8 100644 --- a/examples/desktop/scatter/scatter_colorslice.py +++ b/examples/desktop/scatter/scatter_colorslice.py @@ -10,12 +10,14 @@ import fastplotlib as fpl import numpy as np from pathlib import Path -import os +import sys fig = fpl.Figure() -data_path = Path(os.getcwd()).parent.joinpath("data", "iris.npy") +current_file = Path(sys.argv[0]).resolve() + +data_path = Path(current_file.parent.parent.joinpath("data", "iris.npy")) data = np.load(data_path) n_points = 50 diff --git a/examples/desktop/scatter/scatter_dataslice.py b/examples/desktop/scatter/scatter_dataslice.py index d633eb613..313e24ff3 100644 --- a/examples/desktop/scatter/scatter_dataslice.py +++ b/examples/desktop/scatter/scatter_dataslice.py @@ -10,12 +10,14 @@ import fastplotlib as fpl import numpy as np from pathlib import Path -import os +import sys fig = fpl.Figure() -data_path = Path(os.getcwd()).parent.joinpath("data", "iris.npy") +current_file = Path(sys.argv[0]).resolve() + +data_path = Path(current_file.parent.parent.joinpath("data", "iris.npy")) data = np.load(data_path) n_points = 50 diff --git a/examples/desktop/scatter/scatter_present.py b/examples/desktop/scatter/scatter_present.py index 85ec9ef87..9402a4931 100644 --- a/examples/desktop/scatter/scatter_present.py +++ b/examples/desktop/scatter/scatter_present.py @@ -10,11 +10,13 @@ import fastplotlib as fpl import numpy as np from pathlib import Path -import os +import sys fig = fpl.Figure() -data_path = Path(os.getcwd()).parent.joinpath("data", "iris.npy") +current_file = Path(sys.argv[0]).resolve() + +data_path = Path(current_file.parent.parent.joinpath("data", "iris.npy")) data = np.load(data_path) n_points = 50 From 9c447debfbf090eb2da04b79fbfc3d1478731b8e Mon Sep 17 00:00:00 2001 From: Caitlin Date: Wed, 5 Jun 2024 11:59:05 -0400 Subject: [PATCH 14/32] add sklearn to docs, example needs it --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 5120d9dff..7da394541 100644 --- a/setup.py +++ b/setup.py @@ -24,6 +24,7 @@ "sidecar", "imageio", "matplotlib" + "sklearn" ], "notebook": [ "jupyterlab", From c92e5b728335f74cef5f46ac4df3285d6b7bb36d Mon Sep 17 00:00:00 2001 From: Caitlin Lewis <69729525+clewis7@users.noreply.github.com> Date: Wed, 5 Jun 2024 12:02:38 -0400 Subject: [PATCH 15/32] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 7da394541..3d793b75b 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ "jupyterlab", "sidecar", "imageio", - "matplotlib" + "matplotlib", "sklearn" ], "notebook": [ From 676a4812efe941e6e6c41c8ab4b0307922c0303e Mon Sep 17 00:00:00 2001 From: Caitlin Lewis <69729525+clewis7@users.noreply.github.com> Date: Wed, 5 Jun 2024 12:04:23 -0400 Subject: [PATCH 16/32] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 3d793b75b..503af8f99 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ "sidecar", "imageio", "matplotlib", - "sklearn" + "scikit-learn" ], "notebook": [ "jupyterlab", From 09acb24b34235b24d58e09148ac13697aac1be56 Mon Sep 17 00:00:00 2001 From: Caitlin Date: Wed, 5 Jun 2024 12:12:13 -0400 Subject: [PATCH 17/32] remove from gallery, kills readthedocs runner --- examples/desktop/heatmap/heatmap_data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/desktop/heatmap/heatmap_data.py b/examples/desktop/heatmap/heatmap_data.py index f3717a881..a1fa30fa0 100644 --- a/examples/desktop/heatmap/heatmap_data.py +++ b/examples/desktop/heatmap/heatmap_data.py @@ -5,7 +5,7 @@ """ # test_example = true -# sphinx_gallery_pygfx_docs = 'screenshot' +# sphinx_gallery_pygfx_docs = 'hidden' import fastplotlib as fpl import numpy as np From f749ef3c5c9ef918d6ec823cf74b41db8ad1ac2f Mon Sep 17 00:00:00 2001 From: Caitlin Date: Wed, 5 Jun 2024 12:48:01 -0400 Subject: [PATCH 18/32] update canvas size so thumbnails render better --- examples/desktop/gridplot/gridplot.py | 2 +- examples/desktop/gridplot/gridplot_non_square.py | 2 +- examples/desktop/heatmap/heatmap.py | 2 +- examples/desktop/heatmap/heatmap_cmap.py | 2 +- examples/desktop/heatmap/heatmap_data.py | 2 +- examples/desktop/heatmap/heatmap_vmin_vmax.py | 2 +- examples/desktop/image/image_cmap.py | 2 +- examples/desktop/image/image_rgb.py | 2 +- examples/desktop/image/image_rgbvminvmax.py | 2 +- examples/desktop/image/image_simple.py | 2 +- examples/desktop/image/image_vminvmax.py | 2 +- examples/desktop/line/line.py | 2 +- examples/desktop/line/line_cmap.py | 2 +- examples/desktop/line/line_colorslice.py | 2 +- examples/desktop/line/line_dataslice.py | 2 +- examples/desktop/line/line_present_scaling.py | 2 +- examples/desktop/line_collection/line_collection.py | 2 +- examples/desktop/line_collection/line_collection_cmap_values.py | 2 +- .../line_collection/line_collection_cmap_values_qualitative.py | 2 +- examples/desktop/line_collection/line_collection_colors.py | 2 +- examples/desktop/line_collection/line_stack.py | 2 +- examples/desktop/misc/image_animation.py | 2 +- examples/desktop/misc/line_animation.py | 2 +- examples/desktop/misc/scatter_animation.py | 2 +- examples/desktop/scatter/scatter.py | 2 +- examples/desktop/scatter/scatter_cmap.py | 2 +- examples/desktop/scatter/scatter_colorslice.py | 2 +- examples/desktop/scatter/scatter_dataslice.py | 2 +- examples/desktop/scatter/scatter_present.py | 2 +- examples/desktop/scatter/scatter_size.py | 2 ++ 30 files changed, 31 insertions(+), 29 deletions(-) diff --git a/examples/desktop/gridplot/gridplot.py b/examples/desktop/gridplot/gridplot.py index 919255e20..57d8a48fc 100644 --- a/examples/desktop/gridplot/gridplot.py +++ b/examples/desktop/gridplot/gridplot.py @@ -29,7 +29,7 @@ fig.show() -fig.canvas.set_logical_size(800, 800) +fig.canvas.set_logical_size(700, 560) for subplot in fig: subplot.auto_scale() diff --git a/examples/desktop/gridplot/gridplot_non_square.py b/examples/desktop/gridplot/gridplot_non_square.py index d2db7be32..a4aaadcea 100644 --- a/examples/desktop/gridplot/gridplot_non_square.py +++ b/examples/desktop/gridplot/gridplot_non_square.py @@ -27,7 +27,7 @@ # NOT required for users canvas = fig.canvas -fig.canvas.set_logical_size(800, 800) +fig.canvas.set_logical_size(700, 560) for subplot in fig: subplot.auto_scale() diff --git a/examples/desktop/heatmap/heatmap.py b/examples/desktop/heatmap/heatmap.py index f6a209197..d4ae48b18 100644 --- a/examples/desktop/heatmap/heatmap.py +++ b/examples/desktop/heatmap/heatmap.py @@ -31,7 +31,7 @@ # NOT required for users canvas = fig.canvas -fig.canvas.set_logical_size(1500, 1500) +fig.canvas.set_logical_size(700, 560) fig[0, 0].auto_scale() diff --git a/examples/desktop/heatmap/heatmap_cmap.py b/examples/desktop/heatmap/heatmap_cmap.py index 176782fd6..cd807d4d1 100644 --- a/examples/desktop/heatmap/heatmap_cmap.py +++ b/examples/desktop/heatmap/heatmap_cmap.py @@ -31,7 +31,7 @@ # NOT required for users canvas = fig.canvas -fig.canvas.set_logical_size(1500, 1500) +fig.canvas.set_logical_size(700, 560) fig[0, 0].auto_scale() diff --git a/examples/desktop/heatmap/heatmap_data.py b/examples/desktop/heatmap/heatmap_data.py index a1fa30fa0..3a5a47ec3 100644 --- a/examples/desktop/heatmap/heatmap_data.py +++ b/examples/desktop/heatmap/heatmap_data.py @@ -31,7 +31,7 @@ # NOT required for users canvas = fig.canvas -fig.canvas.set_logical_size(1500, 1500) +fig.canvas.set_logical_size(700, 560) fig[0, 0].auto_scale() diff --git a/examples/desktop/heatmap/heatmap_vmin_vmax.py b/examples/desktop/heatmap/heatmap_vmin_vmax.py index 2053e6a3e..505d6d0a1 100644 --- a/examples/desktop/heatmap/heatmap_vmin_vmax.py +++ b/examples/desktop/heatmap/heatmap_vmin_vmax.py @@ -31,7 +31,7 @@ # NOT required for users canvas = fig.canvas -fig.canvas.set_logical_size(1500, 1500) +fig.canvas.set_logical_size(700, 560) fig[0, 0].auto_scale() diff --git a/examples/desktop/image/image_cmap.py b/examples/desktop/image/image_cmap.py index 33ef49d2f..fb5228aaf 100644 --- a/examples/desktop/image/image_cmap.py +++ b/examples/desktop/image/image_cmap.py @@ -24,7 +24,7 @@ # NOT required for users canvas = fig.canvas -fig.canvas.set_logical_size(800, 800) +fig.canvas.set_logical_size(700, 560) fig[0, 0].auto_scale() diff --git a/examples/desktop/image/image_rgb.py b/examples/desktop/image/image_rgb.py index 020c29812..42b7ba7df 100644 --- a/examples/desktop/image/image_rgb.py +++ b/examples/desktop/image/image_rgb.py @@ -24,7 +24,7 @@ # NOT required for users canvas = fig.canvas -fig.canvas.set_logical_size(800, 800) +fig.canvas.set_logical_size(700, 560) fig[0, 0].auto_scale() diff --git a/examples/desktop/image/image_rgbvminvmax.py b/examples/desktop/image/image_rgbvminvmax.py index 42eef4eb3..39eae1558 100644 --- a/examples/desktop/image/image_rgbvminvmax.py +++ b/examples/desktop/image/image_rgbvminvmax.py @@ -24,7 +24,7 @@ # NOT required for users canvas = fig.canvas -fig.canvas.set_logical_size(800, 800) +fig.canvas.set_logical_size(700, 560) fig[0, 0].auto_scale() diff --git a/examples/desktop/image/image_simple.py b/examples/desktop/image/image_simple.py index 90268f945..731292bf0 100644 --- a/examples/desktop/image/image_simple.py +++ b/examples/desktop/image/image_simple.py @@ -24,7 +24,7 @@ # NOT required for users canvas = fig.canvas -fig.canvas.set_logical_size(800, 800) +fig.canvas.set_logical_size(700, 560) fig[0, 0].auto_scale() diff --git a/examples/desktop/image/image_vminvmax.py b/examples/desktop/image/image_vminvmax.py index 1600ca457..3b40dd7fe 100644 --- a/examples/desktop/image/image_vminvmax.py +++ b/examples/desktop/image/image_vminvmax.py @@ -24,7 +24,7 @@ # NOT required for users canvas = fig.canvas -fig.canvas.set_logical_size(800, 800) +fig.canvas.set_logical_size(700, 560) fig[0, 0].auto_scale() diff --git a/examples/desktop/line/line.py b/examples/desktop/line/line.py index c9c96c049..4717f6280 100644 --- a/examples/desktop/line/line.py +++ b/examples/desktop/line/line.py @@ -42,7 +42,7 @@ # NOT required for users canvas = fig.canvas -fig.canvas.set_logical_size(800, 800) +fig.canvas.set_logical_size(700, 560) fig[0, 0].auto_scale() diff --git a/examples/desktop/line/line_cmap.py b/examples/desktop/line/line_cmap.py index 973eb16d3..df5fff70b 100644 --- a/examples/desktop/line/line_cmap.py +++ b/examples/desktop/line/line_cmap.py @@ -45,7 +45,7 @@ # NOT required for users canvas = fig.canvas -fig.canvas.set_logical_size(800, 800) +fig.canvas.set_logical_size(700, 560) # NOTE: `if __name__ == "__main__"` is NOT how to use fastplotlib interactively # please see our docs for using fastplotlib interactively in ipython and jupyter diff --git a/examples/desktop/line/line_colorslice.py b/examples/desktop/line/line_colorslice.py index 0795644ea..4a14acca6 100644 --- a/examples/desktop/line/line_colorslice.py +++ b/examples/desktop/line/line_colorslice.py @@ -61,7 +61,7 @@ key2 = np.array([True, False, True, False, True, True, True, True]) cosine_graphic.colors[key2] = "Green" -fig.canvas.set_logical_size(800, 800) +fig.canvas.set_logical_size(700, 560) fig[0, 0].auto_scale() diff --git a/examples/desktop/line/line_dataslice.py b/examples/desktop/line/line_dataslice.py index 9ec64c5c2..5d175dc9f 100644 --- a/examples/desktop/line/line_dataslice.py +++ b/examples/desktop/line/line_dataslice.py @@ -50,7 +50,7 @@ key2 = np.array([True, False, True, False, True, True, True, True]) sinc_graphic.data[key2] = np.array([[5, 1, 2]]) -fig.canvas.set_logical_size(800, 800) +fig.canvas.set_logical_size(700, 560) fig[0, 0].auto_scale() diff --git a/examples/desktop/line/line_present_scaling.py b/examples/desktop/line/line_present_scaling.py index e46bbffc8..d35842ddf 100644 --- a/examples/desktop/line/line_present_scaling.py +++ b/examples/desktop/line/line_present_scaling.py @@ -44,7 +44,7 @@ sinc_graphic.present = False -fig.canvas.set_logical_size(800, 800) +fig.canvas.set_logical_size(700, 560) fig[0, 0].auto_scale() diff --git a/examples/desktop/line_collection/line_collection.py b/examples/desktop/line_collection/line_collection.py index 9ea2cab18..3b0a65d5e 100644 --- a/examples/desktop/line_collection/line_collection.py +++ b/examples/desktop/line_collection/line_collection.py @@ -39,7 +39,7 @@ def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray: fig.show() -fig.canvas.set_logical_size(800, 800) +fig.canvas.set_logical_size(700, 560) # NOTE: `if __name__ == "__main__"` is NOT how to use fastplotlib interactively # please see our docs for using fastplotlib interactively in ipython and jupyter diff --git a/examples/desktop/line_collection/line_collection_cmap_values.py b/examples/desktop/line_collection/line_collection_cmap_values.py index 3b14e6e2f..f0e47e4f6 100644 --- a/examples/desktop/line_collection/line_collection_cmap_values.py +++ b/examples/desktop/line_collection/line_collection_cmap_values.py @@ -49,7 +49,7 @@ def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray: # NOT required for users canvas = fig.canvas -fig.canvas.set_logical_size(800, 800) +fig.canvas.set_logical_size(700, 560) # NOTE: `if __name__ == "__main__"` is NOT how to use fastplotlib interactively # please see our docs for using fastplotlib interactively in ipython and jupyter diff --git a/examples/desktop/line_collection/line_collection_cmap_values_qualitative.py b/examples/desktop/line_collection/line_collection_cmap_values_qualitative.py index da04afd05..21d59a182 100644 --- a/examples/desktop/line_collection/line_collection_cmap_values_qualitative.py +++ b/examples/desktop/line_collection/line_collection_cmap_values_qualitative.py @@ -55,7 +55,7 @@ def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray: # NOT required for users canvas = fig.canvas -fig.canvas.set_logical_size(800, 800) +fig.canvas.set_logical_size(700, 560) # NOTE: `if __name__ == "__main__"` is NOT how to use fastplotlib interactively # please see our docs for using fastplotlib interactively in ipython and jupyter diff --git a/examples/desktop/line_collection/line_collection_colors.py b/examples/desktop/line_collection/line_collection_colors.py index d63dbe2a0..b550be34b 100644 --- a/examples/desktop/line_collection/line_collection_colors.py +++ b/examples/desktop/line_collection/line_collection_colors.py @@ -43,7 +43,7 @@ def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray: fig.show() -fig.canvas.set_logical_size(800, 800) +fig.canvas.set_logical_size(700, 560) # NOTE: `if __name__ == "__main__"` is NOT how to use fastplotlib interactively # please see our docs for using fastplotlib interactively in ipython and jupyter diff --git a/examples/desktop/line_collection/line_stack.py b/examples/desktop/line_collection/line_stack.py index cd1c5c331..482288df7 100644 --- a/examples/desktop/line_collection/line_stack.py +++ b/examples/desktop/line_collection/line_stack.py @@ -29,7 +29,7 @@ # NOT required for users canvas = fig.canvas -fig.canvas.set_logical_size(900, 600) +fig.canvas.set_logical_size(700, 560) # NOTE: `if __name__ == "__main__"` is NOT how to use fastplotlib interactively # please see our docs for using fastplotlib interactively in ipython and jupyter diff --git a/examples/desktop/misc/image_animation.py b/examples/desktop/misc/image_animation.py index 3ea656e29..1ab7b035b 100644 --- a/examples/desktop/misc/image_animation.py +++ b/examples/desktop/misc/image_animation.py @@ -33,7 +33,7 @@ def update_data(figure_instance): # NOT required for users canvas = fig.canvas -fig.canvas.set_logical_size(800, 800) +fig.canvas.set_logical_size(700, 560) # NOTE: `if __name__ == "__main__"` is NOT how to use fastplotlib interactively # please see our docs for using fastplotlib interactively in ipython and jupyter diff --git a/examples/desktop/misc/line_animation.py b/examples/desktop/misc/line_animation.py index 36fbb6c2f..c72fd1903 100644 --- a/examples/desktop/misc/line_animation.py +++ b/examples/desktop/misc/line_animation.py @@ -46,7 +46,7 @@ def update_line(subplot): # NOT required for users canvas = fig.canvas -fig.canvas.set_logical_size(800, 800) +fig.canvas.set_logical_size(700, 560) # NOTE: `if __name__ == "__main__"` is NOT how to use fastplotlib interactively # please see our docs for using fastplotlib interactively in ipython and jupyter diff --git a/examples/desktop/misc/scatter_animation.py b/examples/desktop/misc/scatter_animation.py index adf2b156b..214f7ab1c 100644 --- a/examples/desktop/misc/scatter_animation.py +++ b/examples/desktop/misc/scatter_animation.py @@ -54,7 +54,7 @@ def update_points(subplot): # NOT required for users canvas = fig_scatter.canvas -fig_scatter.canvas.set_logical_size(800, 800) +subplot_scatter.canvas.set_logical_size(700, 560) # NOTE: `if __name__ == "__main__"` is NOT how to use fastplotlib interactively # please see our docs for using fastplotlib interactively in ipython and jupyter diff --git a/examples/desktop/scatter/scatter.py b/examples/desktop/scatter/scatter.py index 1a110605d..9bdb07159 100644 --- a/examples/desktop/scatter/scatter.py +++ b/examples/desktop/scatter/scatter.py @@ -30,7 +30,7 @@ fig.show() -fig.canvas.set_logical_size(800, 800) +fig.canvas.set_logical_size(700, 560) fig[0, 0].auto_scale() diff --git a/examples/desktop/scatter/scatter_cmap.py b/examples/desktop/scatter/scatter_cmap.py index 4b8d1d315..daf3a73f9 100644 --- a/examples/desktop/scatter/scatter_cmap.py +++ b/examples/desktop/scatter/scatter_cmap.py @@ -33,7 +33,7 @@ fig.show() -fig.canvas.set_logical_size(800, 800) +fig.canvas.set_logical_size(700, 560) fig[0, 0].auto_scale() diff --git a/examples/desktop/scatter/scatter_colorslice.py b/examples/desktop/scatter/scatter_colorslice.py index c12c1a0c8..a9f943b5d 100644 --- a/examples/desktop/scatter/scatter_colorslice.py +++ b/examples/desktop/scatter/scatter_colorslice.py @@ -31,7 +31,7 @@ # NOT required for users canvas = fig.canvas -fig.canvas.set_logical_size(800, 800) +fig.canvas.set_logical_size(700, 560) fig[0, 0].auto_scale() diff --git a/examples/desktop/scatter/scatter_dataslice.py b/examples/desktop/scatter/scatter_dataslice.py index 313e24ff3..43f746d01 100644 --- a/examples/desktop/scatter/scatter_dataslice.py +++ b/examples/desktop/scatter/scatter_dataslice.py @@ -31,7 +31,7 @@ fig.show() -fig.canvas.set_logical_size(800, 800) +fig.canvas.set_logical_size(700, 560) fig[0, 0].auto_scale() diff --git a/examples/desktop/scatter/scatter_present.py b/examples/desktop/scatter/scatter_present.py index 9402a4931..0957a5127 100644 --- a/examples/desktop/scatter/scatter_present.py +++ b/examples/desktop/scatter/scatter_present.py @@ -33,7 +33,7 @@ # NOT required for users canvas = fig.canvas -fig.canvas.set_logical_size(800, 800) +fig.canvas.set_logical_size(700, 560) fig[0, 0].auto_scale() diff --git a/examples/desktop/scatter/scatter_size.py b/examples/desktop/scatter/scatter_size.py index 6f43b5dff..6ecd8bad5 100644 --- a/examples/desktop/scatter/scatter_size.py +++ b/examples/desktop/scatter/scatter_size.py @@ -42,6 +42,8 @@ fig.show() +fig.canvas.set_logical_size(700, 560) + # 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__": From 59ec3fb863ceb284368f635012ae6595211aeb7d Mon Sep 17 00:00:00 2001 From: Caitlin Date: Wed, 5 Jun 2024 14:27:49 -0400 Subject: [PATCH 19/32] change scatter examples, remove sklearn from docs dependencies --- examples/desktop/image/image_cmap.py | 2 +- examples/desktop/scatter/scatter.py | 31 ++++++++++---- examples/desktop/scatter/scatter_cmap.py | 42 ++++++++++++------- .../desktop/scatter/scatter_colorslice.py | 40 +++++++++++++----- examples/desktop/scatter/scatter_dataslice.py | 33 ++++++++------- examples/desktop/scatter/scatter_present.py | 33 ++++++++------- examples/desktop/scatter/scatter_size.py | 5 ++- setup.py | 1 - 8 files changed, 120 insertions(+), 67 deletions(-) diff --git a/examples/desktop/image/image_cmap.py b/examples/desktop/image/image_cmap.py index fb5228aaf..950cbe72f 100644 --- a/examples/desktop/image/image_cmap.py +++ b/examples/desktop/image/image_cmap.py @@ -1,5 +1,5 @@ """ -Image colormap +Image Colormap ============== Example showing simple plot creation and subsequent cmap change with Standard image from imageio. diff --git a/examples/desktop/scatter/scatter.py b/examples/desktop/scatter/scatter.py index 9bdb07159..1af953cf7 100644 --- a/examples/desktop/scatter/scatter.py +++ b/examples/desktop/scatter/scatter.py @@ -1,6 +1,7 @@ """ Scatter Plot ============ + Example showing scatter plot. """ @@ -9,20 +10,36 @@ import fastplotlib as fpl import numpy as np -from pathlib import Path -import sys fig = fpl.Figure() -current_file = Path(sys.argv[0]).resolve() +# create a random distribution of 10,000 xyz coordinates +n_points = 5_000 + +# dimensions always have to be [n_points, xyz] +dims = (n_points, 3) + +clouds_offset = 15 -data_path = Path(current_file.parent.parent.joinpath("data", "iris.npy")) -data = np.load(data_path) +# create some random clouds +normal = np.random.normal(size=dims, scale=5) +# stack the data into a single array +cloud = np.vstack( + [ + normal - clouds_offset, + normal, + normal + clouds_offset, + ] +) -n_points = 50 +# color each of them separately colors = ["yellow"] * n_points + ["cyan"] * n_points + ["magenta"] * n_points -scatter_graphic = fig[0, 0].add_scatter(data=data[:, :-1], sizes=6, alpha=0.7, colors=colors) +# create plot +fig = fpl.Figure() + +# use an alpha value since this will be a lot of points +fig[0,0].add_scatter(data=cloud, sizes=3, colors=colors, alpha=0.6) # set canvas variable for sphinx_gallery to properly generate examples # NOT required for users diff --git a/examples/desktop/scatter/scatter_cmap.py b/examples/desktop/scatter/scatter_cmap.py index daf3a73f9..27164d4fe 100644 --- a/examples/desktop/scatter/scatter_cmap.py +++ b/examples/desktop/scatter/scatter_cmap.py @@ -1,6 +1,7 @@ """ -Scatter Plot -============ +Scatter Colormap +================ + Example showing cmap change for scatter plot. """ @@ -9,36 +10,49 @@ import fastplotlib as fpl import numpy as np -from pathlib import Path -from sklearn.cluster import AgglomerativeClustering -import sys fig = fpl.Figure() -current_file = Path(sys.argv[0]).resolve() +# create a random distribution of 10,000 xyz coordinates +n_points = 5_000 -data_path = Path(current_file.parent.parent.joinpath("data", "iris.npy")) -data = np.load(data_path) +# dimensions always have to be [n_points, xyz] +dims = (n_points, 3) -agg = AgglomerativeClustering(n_clusters=3) -agg.fit_predict(data) +clouds_offset = 15 -scatter_graphic = fig[0, 0].add_scatter( - data=data[:, :-1], sizes=15, alpha=0.7, cmap="Set1", cmap_values=agg.labels_ +# create some random clouds +normal = np.random.normal(size=dims, scale=5) +# stack the data into a single array +cloud = np.vstack( + [ + normal - clouds_offset, + normal, + normal + clouds_offset, + ] ) +# color each of them separately +colors = ["yellow"] * n_points + ["cyan"] * n_points + ["magenta"] * n_points + +# create plot +fig = fpl.Figure() + +# use an alpha value since this will be a lot of points +fig[0,0].add_scatter(data=cloud, sizes=3, colors=colors, alpha=0.6) + # set canvas variable for sphinx_gallery to properly generate examples # NOT required for users canvas = fig.canvas fig.show() +fig[0,0].graphics[0].cmap = "viridis" + fig.canvas.set_logical_size(700, 560) fig[0, 0].auto_scale() -scatter_graphic.cmap = "tab10" - # 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__": diff --git a/examples/desktop/scatter/scatter_colorslice.py b/examples/desktop/scatter/scatter_colorslice.py index a9f943b5d..dc42b89ea 100644 --- a/examples/desktop/scatter/scatter_colorslice.py +++ b/examples/desktop/scatter/scatter_colorslice.py @@ -1,6 +1,7 @@ """ -Scatter Plot -============ +Scatter Plot Color Slicing +========================== + Example showing color slice for scatter plot. """ @@ -9,30 +10,47 @@ import fastplotlib as fpl import numpy as np -from pathlib import Path -import sys - fig = fpl.Figure() -current_file = Path(sys.argv[0]).resolve() +# create a random distribution of 10,000 xyz coordinates +n_points = 5_000 + +# dimensions always have to be [n_points, xyz] +dims = (n_points, 3) -data_path = Path(current_file.parent.parent.joinpath("data", "iris.npy")) -data = np.load(data_path) +clouds_offset = 30 -n_points = 50 +# create some random clouds +normal = np.random.normal(size=dims, scale=5) +# stack the data into a single array +cloud = np.vstack( + [ + normal - clouds_offset, + normal, + normal + clouds_offset, + ] +) + +# color each of them separately colors = ["yellow"] * n_points + ["cyan"] * n_points + ["magenta"] * n_points -scatter_graphic = fig[0, 0].add_scatter(data=data[:, :-1], sizes=6, alpha=0.7, colors=colors) +# create plot +fig = fpl.Figure() -fig.show() +# use an alpha value since this will be a lot of points +fig[0,0].add_scatter(data=cloud, sizes=3, colors=colors, alpha=0.6) # set canvas variable for sphinx_gallery to properly generate examples # NOT required for users canvas = fig.canvas +fig.show() + fig.canvas.set_logical_size(700, 560) +scatter_graphic = fig[0, 0].graphics[0] + fig[0, 0].auto_scale() scatter_graphic.colors[0:75] = "red" diff --git a/examples/desktop/scatter/scatter_dataslice.py b/examples/desktop/scatter/scatter_dataslice.py index 43f746d01..11b5b5f18 100644 --- a/examples/desktop/scatter/scatter_dataslice.py +++ b/examples/desktop/scatter/scatter_dataslice.py @@ -1,6 +1,7 @@ """ -Scatter Plot -============ +Scatter Plot Data Slicing +========================= + Example showing data slice for scatter plot. """ @@ -9,21 +10,25 @@ import fastplotlib as fpl import numpy as np -from pathlib import Path -import sys fig = fpl.Figure() -current_file = Path(sys.argv[0]).resolve() +# create a gaussian cloud of 5_000 points +n_points = 1_000 + +mean = [0, 0] # mean of the Gaussian distribution +covariance = [[1, 0], [0, 1]] # covariance matrix -data_path = Path(current_file.parent.parent.joinpath("data", "iris.npy")) -data = np.load(data_path) +gaussian_cloud = np.random.multivariate_normal(mean, covariance, n_points) +gaussian_cloud2 = np.random.multivariate_normal(mean, covariance, n_points) -n_points = 50 -colors = ["yellow"] * n_points + ["cyan"] * n_points + ["magenta"] * n_points +# create plot +fig = fpl.Figure() -scatter_graphic = fig[0, 0].add_scatter(data=data[:, :-1], sizes=6, alpha=0.7, colors=colors) +# use an alpha value since this will be a lot of points +scatter1 = fig[0,0].add_scatter(data=gaussian_cloud, sizes=3) +scatter2 = fig[0,0].add_scatter(data=gaussian_cloud2, colors="r", sizes=3) # set canvas variable for sphinx_gallery to properly generate examples # NOT required for users @@ -35,12 +40,8 @@ fig[0, 0].auto_scale() -scatter_graphic.data[0] = np.array([[5, 3, 1.5]]) -scatter_graphic.data[1] = np.array([[4.3, 3.2, 1.3]]) -scatter_graphic.data[2] = np.array([[5.2, 2.7, 1.7]]) - -scatter_graphic.data[10:15] = scatter_graphic.data[0:5] + np.array([1, 1, 1]) -scatter_graphic.data[50:100:2] = scatter_graphic.data[100:150:2] + np.array([1, 1, 0]) +scatter1.data[:500] = np.array([0 , 0, 0]) +scatter2.data[500:] = np.array([0 , 0, 0]) # NOTE: `if __name__ == "__main__"` is NOT how to use fastplotlib interactively # please see our docs for using fastplotlib interactively in ipython and jupyter diff --git a/examples/desktop/scatter/scatter_present.py b/examples/desktop/scatter/scatter_present.py index 0957a5127..f67d80eb4 100644 --- a/examples/desktop/scatter/scatter_present.py +++ b/examples/desktop/scatter/scatter_present.py @@ -1,6 +1,7 @@ """ -Scatter Plot -============ +Scatter Plot Present +==================== + Example showing present feature for scatter plot. """ @@ -9,35 +10,37 @@ import fastplotlib as fpl import numpy as np -from pathlib import Path -import sys + fig = fpl.Figure() -current_file = Path(sys.argv[0]).resolve() +# create a gaussian cloud of 5_000 points +n_points = 1_000 -data_path = Path(current_file.parent.parent.joinpath("data", "iris.npy")) -data = np.load(data_path) +mean = [0, 0] # mean of the Gaussian distribution +covariance = [[1, 0], [0, 1]] # covariance matrix -n_points = 50 -colors = ["yellow"] * n_points + ["cyan"] * n_points + ["magenta"] * n_points +gaussian_cloud = np.random.multivariate_normal(mean, covariance, n_points) +gaussian_cloud2 = np.random.multivariate_normal(mean, covariance, n_points) -scatter_graphic = fig[0, 0].add_scatter(data=data[:, :-1], sizes=6, alpha=0.7, colors=colors) +# create plot +fig = fpl.Figure() -colors = ["red"] * n_points + ["white"] * n_points + ["blue"] * n_points -scatter_graphic2 = fig[0, 0].add_scatter(data=data[:, 1:], sizes=6, alpha=0.7, colors=colors) - -fig.show() +# use an alpha value since this will be a lot of points +scatter1 = fig[0,0].add_scatter(data=gaussian_cloud, sizes=3) +scatter2 = fig[0,0].add_scatter(data=gaussian_cloud2, colors="r", sizes=3) # set canvas variable for sphinx_gallery to properly generate examples # NOT required for users canvas = fig.canvas +fig.show() + fig.canvas.set_logical_size(700, 560) fig[0, 0].auto_scale() -scatter_graphic.present = False +scatter1.present = False # NOTE: `if __name__ == "__main__"` is NOT how to use fastplotlib interactively # please see our docs for using fastplotlib interactively in ipython and jupyter diff --git a/examples/desktop/scatter/scatter_size.py b/examples/desktop/scatter/scatter_size.py index 6ecd8bad5..ad7d5b7a8 100644 --- a/examples/desktop/scatter/scatter_size.py +++ b/examples/desktop/scatter/scatter_size.py @@ -1,6 +1,7 @@ """ -Scatter Plot -============ +Scatter Plot Size +================= + Example showing point size change for scatter plot. """ diff --git a/setup.py b/setup.py index 503af8f99..5ed907bfe 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,6 @@ "sidecar", "imageio", "matplotlib", - "scikit-learn" ], "notebook": [ "jupyterlab", From d0852f4a4a379bd227edc2036e2f30677f9c52ca Mon Sep 17 00:00:00 2001 From: Caitlin Date: Wed, 5 Jun 2024 14:49:21 -0400 Subject: [PATCH 20/32] add iris scatter examples, exclude from screenshot tests --- examples/desktop/scatter/scatter_iris.py | 42 +++++++++++++++++++ examples/desktop/scatter/scatter_iris_cmap.py | 0 .../scatter/scatter_iris_colorslice.py | 0 .../desktop/scatter/scatter_iris_dataslice.py | 0 .../desktop/scatter/scatter_iris_present.py | 0 5 files changed, 42 insertions(+) create mode 100644 examples/desktop/scatter/scatter_iris.py create mode 100644 examples/desktop/scatter/scatter_iris_cmap.py create mode 100644 examples/desktop/scatter/scatter_iris_colorslice.py create mode 100644 examples/desktop/scatter/scatter_iris_dataslice.py create mode 100644 examples/desktop/scatter/scatter_iris_present.py diff --git a/examples/desktop/scatter/scatter_iris.py b/examples/desktop/scatter/scatter_iris.py new file mode 100644 index 000000000..7aa9ec441 --- /dev/null +++ b/examples/desktop/scatter/scatter_iris.py @@ -0,0 +1,42 @@ +""" +Iris Scatter Plot +================= + +Example showing scatter plot using sklearn iris dataset. +""" + +# test_example = false +# sphinx_gallery_pygfx_docs = 'screenshot' + +import fastplotlib as fpl +import numpy as np +from pathlib import Path +import sys + +fig = fpl.Figure() + +current_file = Path(sys.argv[0]).resolve() + +data_path = Path(current_file.parent.parent.joinpath("data", "iris.npy")) +data = np.load(data_path) + +n_points = 50 +colors = ["yellow"] * n_points + ["cyan"] * n_points + ["magenta"] * n_points + +scatter_graphic = fig[0, 0].add_scatter(data=data[:, :-1], sizes=6, alpha=0.7, colors=colors) + +# set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users +canvas = fig.canvas + +fig.show() + +fig.canvas.set_logical_size(700, 560) + +fig[0, 0].auto_scale() + +# 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.run() \ No newline at end of file diff --git a/examples/desktop/scatter/scatter_iris_cmap.py b/examples/desktop/scatter/scatter_iris_cmap.py new file mode 100644 index 000000000..e69de29bb diff --git a/examples/desktop/scatter/scatter_iris_colorslice.py b/examples/desktop/scatter/scatter_iris_colorslice.py new file mode 100644 index 000000000..e69de29bb diff --git a/examples/desktop/scatter/scatter_iris_dataslice.py b/examples/desktop/scatter/scatter_iris_dataslice.py new file mode 100644 index 000000000..e69de29bb diff --git a/examples/desktop/scatter/scatter_iris_present.py b/examples/desktop/scatter/scatter_iris_present.py new file mode 100644 index 000000000..e69de29bb From 7efad6b60250e9d567ae595ca397681b4f21c1ea Mon Sep 17 00:00:00 2001 From: Caitlin Date: Wed, 5 Jun 2024 15:52:56 -0400 Subject: [PATCH 21/32] add more animation examples, add to tests --- examples/desktop/misc/cycle_animation.py | 66 +++++++++++ examples/desktop/misc/em_wave_animation.py | 109 +++++++++++++++++++ examples/desktop/misc/line3d_animation.py | 67 ++++++++++++ examples/desktop/misc/line_animation.py | 2 + examples/desktop/misc/multiplot_animation.py | 53 +++++++++ examples/desktop/misc/scatter_animation.py | 4 +- examples/tests/testutils.py | 3 +- 7 files changed, 301 insertions(+), 3 deletions(-) create mode 100644 examples/desktop/misc/cycle_animation.py create mode 100644 examples/desktop/misc/em_wave_animation.py create mode 100644 examples/desktop/misc/line3d_animation.py create mode 100644 examples/desktop/misc/multiplot_animation.py diff --git a/examples/desktop/misc/cycle_animation.py b/examples/desktop/misc/cycle_animation.py new file mode 100644 index 000000000..2553483bb --- /dev/null +++ b/examples/desktop/misc/cycle_animation.py @@ -0,0 +1,66 @@ +""" +Scatter Animation Colors +======================== + +Example showing animation with a scatter plot. +""" + +# test_example = false +# sphinx_gallery_pygfx_docs = 'animate' + +import fastplotlib as fpl +import numpy as np + +# create a random distribution of 10,000 xyz coordinates +n_points = 10_000 + +# dimensions always have to be [n_points, xyz] +dims = (n_points, 3) + +clouds_offset = 15 + +# create some random clouds +normal = np.random.normal(size=dims, scale=5) +# stack the data into a single array +cloud = np.vstack( + [ + normal - clouds_offset, + normal, + normal + clouds_offset, + ] +) + +# color each of them separately +colors = ["yellow"] * n_points + ["cyan"] * n_points + ["magenta"] * n_points + +# create plot +fig_scatter = fpl.Figure() +subplot_scatter = fig_scatter[0, 0] +# use an alpha value since this will be a lot of points +scatter_graphic = subplot_scatter.add_scatter(data=cloud, sizes=3, colors=colors, alpha=0.6) + + +i = 0.05 +def cycle_colors(subplot): + global i + # cycle the red values + scatter_graphic.colors[n_points * 2:, 0] = np.abs(np.sin(i)) + scatter_graphic.colors[n_points * 2:, 1] = np.abs(np.sin(i + (np.pi / 4))) + scatter_graphic.colors[n_points * 2:, 2] = np.abs(np.cos(i)) + i += 0.05 + +subplot_scatter.add_animations(cycle_colors) + +fig_scatter.show() + +# set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users +canvas = fig_scatter.canvas + +subplot_scatter.canvas.set_logical_size(700, 560) + +# 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.run() \ No newline at end of file diff --git a/examples/desktop/misc/em_wave_animation.py b/examples/desktop/misc/em_wave_animation.py new file mode 100644 index 000000000..99561d6b2 --- /dev/null +++ b/examples/desktop/misc/em_wave_animation.py @@ -0,0 +1,109 @@ +""" +Electromagnetic Wave Animation +============================== + +Example showing animation of an electromagnetic wave. +""" + +# test_example = false +# sphinx_gallery_pygfx_docs = 'animate' + +import fastplotlib as fpl +import numpy as np + +fig_em = fpl.Figure( + cameras="3d", + controller_types="orbit", + size=(700, 400) +) + +start, stop = 0, 4 * np.pi + +# let's define the x, y and z axes for each with direction of wave propogation along the z-axis +# electric field in the xz plane travelling along +zs = np.linspace(start, stop, 200) +e_ys = np.zeros(200) +e_xs = np.sin(zs) +electric = np.column_stack([e_xs, e_ys, zs]) + +# magnetic field in the yz plane +zs = np.linspace(start, stop, 200) +m_ys = np.sin(zs) +m_xs = np.zeros(200) +magnetic = np.column_stack([m_xs, m_ys, zs]) + +# add the lines +fig_em[0, 0].add_line(electric, colors="blue", thickness=2, name="e") +fig_em[0, 0].add_line(magnetic, colors="red", thickness=2, name="m") + +# draw vector line at every 10th position +electric_vectors = [np.array([[0, 0, z], [x, 0, z]]) for (x, z) in zip(e_xs[::10], zs[::10])] +magnetic_vectors = [np.array([[0, 0, z], [0, y, z]]) for (y, z) in zip(m_ys[::10], zs[::10])] + +# add as a line collection +fig_em[0, 0].add_line_collection(electric_vectors, colors="blue", thickness=1.5, name="e-vec", z_offset=0) +fig_em[0, 0].add_line_collection(magnetic_vectors, colors="red", thickness=1.5, name="m-vec", z_offset=0) +# note that the z_offset in `add_line_collection` is not data-related +# it is the z-offset for where to place the *graphic*, by default with Orthographic cameras (i.e. 2D views) +# it will increment by 1 for each line in the collection, we want to disable this so set z_position=0 + +# axes are a WIP, just draw a white line along z for now +z_axis = np.array([[0, 0, 0], [0, 0, stop]]) +fig_em[0, 0].add_line(z_axis, colors="w", thickness=1) + +# just a pre-saved camera state +state = { + 'position': np.array([-8.0 , 6.0, -2.0]), + 'rotation': np.array([0.09, 0.9 , 0.2, -0.5]), + 'scale': np.array([1., 1., 1.]), + 'reference_up': np.array([0., 1., 0.]), + 'fov': 50.0, + 'width': 12, + 'height': 12, + 'zoom': 1.35, + 'maintain_aspect': True, + 'depth_range': None +} + + +fig_em[0, 0].camera.set_state(state) + +fig_em.show() + +fig_em[0, 0].camera.zoom = 1.5 + +increment = np.pi * 4 / 100 + +# set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users +canvas = fig_em.canvas + +fig_em.canvas.set_logical_size(700, 560) + +# moves the wave one step along the z-axis +def tick(subplot): + global increment, start, stop, zs + new_zs = np.linspace(start, stop, 200) + new_data = np.sin(new_zs) + + # just change the x-axis vals for the electric field + subplot["e"].data[:, 0] = new_data + # and y-axis vals for magnetic field + subplot["m"].data[:, 1] = new_data + + # update the vector lines + for i, (value, z) in enumerate(zip(new_data[::10], zs[::10])): + subplot["e-vec"].graphics[i].data = np.array([[0, 0, z], [value, 0, z]]) + subplot["m-vec"].graphics[i].data = np.array([[0, 0, z], [0, value, z]]) + + start += increment + stop += increment + + +fig_em[0, 0].add_animations(tick) + +# 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.run() \ No newline at end of file diff --git a/examples/desktop/misc/line3d_animation.py b/examples/desktop/misc/line3d_animation.py new file mode 100644 index 000000000..bee636e7b --- /dev/null +++ b/examples/desktop/misc/line3d_animation.py @@ -0,0 +1,67 @@ +""" +Simple 3D Line Animation +======================== + +Example showing animation with 3D lines. +""" + +# test_example = false +# sphinx_gallery_pygfx_docs = 'animate 5s' + +import numpy as np +import fastplotlib as fpl + +# create data in the shape of a spiral +phi = np.linspace(0, 30, 200) + +xs = phi * np.cos(phi) +ys = phi * np.sin(phi) +zs = phi + +# make data 3d, with shape [, 3] +spiral = np.dstack([xs, ys, zs])[0] + +fig = fpl.Figure(cameras="3d") + +line_graphic = fig[0,0].add_line(data=spiral, thickness=3, cmap='jet') + +# make axes visible +fig[0,0].set_axes_visibility(True) +fig[0,0].set_grid_visibility(True) + +marker = fig[0,0].add_scatter(data=spiral[0], sizes=10, name="marker") + +marker_index = 0 + + +# a function to move the ball along the spiral +def move_marker(): + global marker_index + + marker_index += 1 + + if marker_index == spiral.shape[0]: + marker_index = 0 + + for subplot in fig: + subplot["marker"].data = spiral[marker_index] + + +# add `move_marker` to the animations +fig.add_animations(move_marker) + +fig.show() + +# set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users +canvas = fig.canvas + +fig.canvas.set_logical_size(700, 560) + +fig[0,0].auto_scale(maintain_aspect=False) + +# 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.run() \ No newline at end of file diff --git a/examples/desktop/misc/line_animation.py b/examples/desktop/misc/line_animation.py index c72fd1903..8b27e1647 100644 --- a/examples/desktop/misc/line_animation.py +++ b/examples/desktop/misc/line_animation.py @@ -48,6 +48,8 @@ def update_line(subplot): fig.canvas.set_logical_size(700, 560) +fig[0,0].auto_scale(maintain_aspect=False) + # 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__": diff --git a/examples/desktop/misc/multiplot_animation.py b/examples/desktop/misc/multiplot_animation.py new file mode 100644 index 000000000..84281ea5f --- /dev/null +++ b/examples/desktop/misc/multiplot_animation.py @@ -0,0 +1,53 @@ +""" +Multi-Subplot Image Update +========================== + +Example showing updating a single plot with new random 512x512 data. +""" + +# test_example = false +# sphinx_gallery_pygfx_docs = 'animate' + +import fastplotlib as fpl +import numpy as np + +# Figure of shape 2 x 3 with all controllers synced +figure_grid = fpl.Figure(shape=(2, 3), controller_ids="sync") + +# Make a random image graphic for each subplot +for subplot in figure_grid: + # create image data + data = np.random.rand(512, 512) + # add an image to the subplot + subplot.add_image(data, name="rand-img") + +figure_grid[0,1]["rand-img"].cmap = "viridis" +figure_grid[1,0]["rand-img"].cmap = "Wistia" +figure_grid[0,2]["rand-img"].cmap = "gray" +figure_grid[1,1]["rand-img"].cmap = "spring" + +# Define a function to update the image graphics with new data +# add_animations will pass the gridplot to the animation function +def update_data(f): + for subplot in f: + new_data = np.random.rand(512, 512) + # index the image graphic by name and set the data + subplot["rand-img"].data = new_data + +# add the animation function +figure_grid.add_animations(update_data) + +# show the gridplot +figure_grid.show() + +# set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users +canvas = figure_grid.canvas + +figure_grid.canvas.set_logical_size(700, 560) + +# 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.run() \ No newline at end of file diff --git a/examples/desktop/misc/scatter_animation.py b/examples/desktop/misc/scatter_animation.py index 214f7ab1c..2d51862aa 100644 --- a/examples/desktop/misc/scatter_animation.py +++ b/examples/desktop/misc/scatter_animation.py @@ -1,6 +1,6 @@ """ -Scatter Animation -================= +Scatter Animation Data +====================== Example showing animation with a scatter plot. """ diff --git a/examples/tests/testutils.py b/examples/tests/testutils.py index f62ae7602..22747ce08 100644 --- a/examples/tests/testutils.py +++ b/examples/tests/testutils.py @@ -22,7 +22,8 @@ "scatter/*.py", "line/*.py", "line_collection/*.py", - "gridplot/*.py" + "gridplot/*.py", + "misc/*.py" ] From 16c712c82bcf3491c68b71a3c0431b52ba2e7dc1 Mon Sep 17 00:00:00 2001 From: Caitlin Date: Wed, 5 Jun 2024 17:05:29 -0400 Subject: [PATCH 22/32] add simple multigraphic gridplot example --- .../desktop/gridplot/multigraphic_gridplot.py | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 examples/desktop/gridplot/multigraphic_gridplot.py diff --git a/examples/desktop/gridplot/multigraphic_gridplot.py b/examples/desktop/gridplot/multigraphic_gridplot.py new file mode 100644 index 000000000..7be65d33c --- /dev/null +++ b/examples/desktop/gridplot/multigraphic_gridplot.py @@ -0,0 +1,110 @@ +""" +Multi-Graphic GridPlot +====================== + +Example showing a Figure with multiple subplots and multiple graphic types. +""" + +# test_example = true +# sphinx_gallery_pygfx_docs = 'screenshot' + +import fastplotlib as fpl +import numpy as np +import imageio.v3 as iio +from itertools import product + +# define figure +fig = fpl.Figure(shape=(2,2), names=[["image-overlay", "circles"], ["line-stack", "scatter"]]) + +img = iio.imread("imageio:coffee.png") + +# add image to subplot +fig["image-overlay"].add_image(data=img) + +# generate overlay + +# empty array for overlay, shape is [nrows, ncols, RGBA] +overlay = np.zeros(shape=(*img.shape[:2], 4), dtype=np.float32) + +# set the blue values of some pixels with an alpha > 1 +overlay[img[:, :, -1] > 200] = np.array([0.0, 0.0, 1.0, 0.6]).astype(np.float32) + +# add overlay to image +fig["image-overlay"].add_image(data=overlay) + +# generate some circles +def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray: + theta = np.linspace(0, 2 * np.pi, n_points) + xs = radius * np.sin(theta) + ys = radius * np.cos(theta) + + return np.column_stack([xs, ys]) + center + + +spatial_dims = (50, 50) + +# this makes 16 circles, so we can create 16 cmap values, so it will use these values to set the +# color of the line based by using the cmap as a LUT with the corresponding cmap_value +circles = list() +for center in product(range(0, spatial_dims[0], 15), range(0, spatial_dims[1], 15)): + circles.append(make_circle(center, 5, n_points=75)) + +# things like class labels, cluster labels, etc. +cmap_values = [ + 0, 1, 1, 2, + 0, 0, 1, 1, + 2, 2, 8, 3, + 1, 9, 1, 5 +] + +# add the circles to the figure +fig["circles"].add_line_collection( + circles, + cmap="tab10", + cmap_values=cmap_values, + thickness=3 +) + +# generate some sine data +# linspace, create 100 evenly spaced x values from -10 to 10 +xs = np.linspace(-10, 10, 100) +# sine wave +ys = np.sin(xs) +sine = np.dstack([xs, ys])[0] + +# make 10 identical waves +sine_waves = 10 * [sine] + +# add the line stack to the figure +fig["line-stack"].add_line_stack(data=sine_waves, cmap="Wistia", separation=1) + +fig["line-stack"].auto_scale(maintain_aspect=True) + +# generate some scatter data +# create a gaussian cloud of 500 points +n_points = 500 + +mean = [0, 0] # mean of the Gaussian distribution +covariance = [[1, 0], [0, 1]] # covariance matrix + +gaussian_cloud = np.random.multivariate_normal(mean, covariance, n_points) +gaussian_cloud2 = np.random.multivariate_normal(mean, covariance, n_points) + +# add the scatter graphics to the figure +fig["scatter"].add_scatter(data=gaussian_cloud, sizes=1, cmap="jet") +fig["scatter"].add_scatter(data=gaussian_cloud2, colors="r", sizes=1) + +# set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users +canvas = fig.canvas + +fig.show() + +fig.canvas.set_logical_size(700, 560) + +# 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.run() + From 98d52806ba281967c5765d665bdeac0a6541c408 Mon Sep 17 00:00:00 2001 From: Caitlin Date: Thu, 6 Jun 2024 10:07:04 -0400 Subject: [PATCH 23/32] add simple event, fix multigraphic gridplot --- examples/desktop/gridplot/multigraphic_gridplot.py | 13 ++++++++++++- examples/desktop/misc/simple_event.py | 0 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 examples/desktop/misc/simple_event.py diff --git a/examples/desktop/gridplot/multigraphic_gridplot.py b/examples/desktop/gridplot/multigraphic_gridplot.py index 7be65d33c..0071312fc 100644 --- a/examples/desktop/gridplot/multigraphic_gridplot.py +++ b/examples/desktop/gridplot/multigraphic_gridplot.py @@ -57,14 +57,25 @@ def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray: 1, 9, 1, 5 ] +# add an image to overlay the circles on +img2 = np.ones((60, 60)) + +fig["circles"].add_image(data=img2) + # add the circles to the figure fig["circles"].add_line_collection( circles, cmap="tab10", cmap_values=cmap_values, - thickness=3 + thickness=3, + alpha=0.5, + name="circles-graphic" ) +# move the circles graphic so that it is centered over the image +fig["circles"]["circles-graphic"].position_y += 7 +fig["circles"]["circles-graphic"].position_x += 7 + # generate some sine data # linspace, create 100 evenly spaced x values from -10 to 10 xs = np.linspace(-10, 10, 100) diff --git a/examples/desktop/misc/simple_event.py b/examples/desktop/misc/simple_event.py new file mode 100644 index 000000000..e69de29bb From ff3f429520f3a3c9d2108be155ded6405ddc3ba3 Mon Sep 17 00:00:00 2001 From: Caitlin Lewis <69729525+clewis7@users.noreply.github.com> Date: Thu, 6 Jun 2024 10:14:18 -0400 Subject: [PATCH 24/32] Update line3d_animation.py --- examples/desktop/misc/line3d_animation.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/examples/desktop/misc/line3d_animation.py b/examples/desktop/misc/line3d_animation.py index bee636e7b..431d2616a 100644 --- a/examples/desktop/misc/line3d_animation.py +++ b/examples/desktop/misc/line3d_animation.py @@ -25,10 +25,6 @@ line_graphic = fig[0,0].add_line(data=spiral, thickness=3, cmap='jet') -# make axes visible -fig[0,0].set_axes_visibility(True) -fig[0,0].set_grid_visibility(True) - marker = fig[0,0].add_scatter(data=spiral[0], sizes=10, name="marker") marker_index = 0 @@ -64,4 +60,4 @@ def move_marker(): # please see our docs for using fastplotlib interactively in ipython and jupyter if __name__ == "__main__": print(__doc__) - fpl.run() \ No newline at end of file + fpl.run() From 1fba2c4434e041a663a0dcb22cd532294a84d7b6 Mon Sep 17 00:00:00 2001 From: Caitlin Date: Thu, 6 Jun 2024 10:16:27 -0400 Subject: [PATCH 25/32] add simple event example --- examples/desktop/misc/simple_event.py | 73 +++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/examples/desktop/misc/simple_event.py b/examples/desktop/misc/simple_event.py index e69de29bb..a26e86834 100644 --- a/examples/desktop/misc/simple_event.py +++ b/examples/desktop/misc/simple_event.py @@ -0,0 +1,73 @@ +""" +Simple Event +============ + +Example showing how to add a simple callback event. +""" + +# test_example = false +# sphinx_gallery_pygfx_docs = 'screenshot' + +import fastplotlib as fpl +import numpy as np + +# generate some date +# linspace, create 100 evenly spaced x values from -10 to 10 +xs = np.linspace(-10, 10, 100) +# sine wave +ys = np.sin(xs) +sine = np.column_stack([xs, ys]) + +# cosine wave +ys = np.cos(xs) + 5 +cosine = np.column_stack([xs, ys]) + +# sinc function +a = 0.5 +ys = np.sinc(xs) * 3 + 8 +sinc = np.column_stack([xs, ys]) + +# Create a figure +fig_lines = fpl.Figure() + +# we will add all the lines to the same subplot +subplot = fig_lines[0, 0] + +# plot sine wave, use a single color +sine_graphic = subplot.add_line(data=sine, thickness=5, colors="magenta") + +# you can also use colormaps for lines! +cosine_graphic = subplot.add_line(data=cosine, thickness=12, cmap="autumn") + +# or a list of colors for each datapoint +colors = ["r"] * 25 + ["purple"] * 25 + ["y"] * 25 + ["b"] * 25 +sinc_graphic = subplot.add_line(data=sinc, thickness=5, colors=colors) + +# show the plot +fig_lines.show() + +subplot.auto_scale(maintain_aspect=True) + + +def callback_func(event_data): + print(event_data) + + +# Will print event data when the color changes +cosine_graphic.colors.add_event_handler(callback_func) + +# more complex indexing of colors +# from point 15 - 30, set every 3rd point as "cyan" +cosine_graphic.colors[15:50:3] = "cyan" + +# set canvas variable for sphinx_gallery to properly generate examples +# NOT required for users +canvas = fig_lines.canvas + +fig_lines.canvas.set_logical_size(700, 560) + +# 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.run() From 26d85e487c7e48533510fb6ae52229b3a81e0daf Mon Sep 17 00:00:00 2001 From: Caitlin Date: Tue, 18 Jun 2024 10:31:46 -0400 Subject: [PATCH 26/32] minor changes --- .../desktop/line_collection/line_stack_3d.py | 6 +- examples/desktop/misc/simple_event.py | 55 +++++++------------ examples/desktop/scatter/scatter_dataslice.py | 2 +- examples/desktop/scatter/scatter_iris.py | 6 +- fastplotlib/layouts/_figure.py | 9 +-- 5 files changed, 31 insertions(+), 47 deletions(-) diff --git a/examples/desktop/line_collection/line_stack_3d.py b/examples/desktop/line_collection/line_stack_3d.py index 5c0b1160d..314a97ff2 100644 --- a/examples/desktop/line_collection/line_stack_3d.py +++ b/examples/desktop/line_collection/line_stack_3d.py @@ -6,7 +6,7 @@ """ # test_example = false -# sphinx_gallery_pygfx_docs = 'hidden' +# sphinx_gallery_pygfx_docs = 'animate' import numpy as np import fastplotlib as fpl @@ -97,8 +97,10 @@ def animate_colors(subplot): figure[0, 0].camera.set_state(camera_state) -figure.canvas.set_logical_size(500, 500) +figure.canvas.set_logical_size(700, 560) +# 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.run() diff --git a/examples/desktop/misc/simple_event.py b/examples/desktop/misc/simple_event.py index 4f048b9fc..cbe57fb48 100644 --- a/examples/desktop/misc/simple_event.py +++ b/examples/desktop/misc/simple_event.py @@ -9,56 +9,43 @@ # sphinx_gallery_pygfx_docs = 'screenshot' import fastplotlib as fpl -import numpy as np +import imageio.v3 as iio -# generate some date -# linspace, create 100 evenly spaced x values from -10 to 10 -xs = np.linspace(-10, 10, 100) -# sine wave -ys = np.sin(xs) -sine = np.column_stack([xs, ys]) - -# cosine wave -ys = np.cos(xs) + 5 -cosine = np.column_stack([xs, ys]) - -# sinc function -a = 0.5 -ys = np.sinc(xs) * 3 + 8 -sinc = np.column_stack([xs, ys]) +data = iio.imread("imageio:camera.png") # Create a figure figure = fpl.Figure() -# we will add all the lines to the same subplot -subplot = figure[0, 0] - # plot sine wave, use a single color -sine_graphic = subplot.add_line(data=sine, thickness=5, colors="magenta") - -# you can also use colormaps for lines! -cosine_graphic = subplot.add_line(data=cosine, thickness=12, cmap="autumn") - -# or a list of colors for each datapoint -colors = ["r"] * 25 + ["purple"] * 25 + ["y"] * 25 + ["b"] * 25 -sinc_graphic = subplot.add_line(data=sinc, thickness=5, colors=colors) +image_graphic = figure[0,0].add_image(data=data) # show the plot figure.show() -subplot.auto_scale(maintain_aspect=True) - +# define callback function to print the event data def callback_func(event_data): - print(event_data) + print(event_data.info) # Will print event data when the color changes -cosine_graphic.colors.add_event_handler(callback_func) +image_graphic.add_event_handler(callback_func, "cmap") + +image_graphic.cmap = "viridis" + + +# adding a click event +@image_graphic.add_event_handler("click") +def click_event(event_data): + # get the click location in screen coordinates + xy = (event_data.x, event_data.y) + + # map the screen coordinates to world coordinates + xy = figure[0,0].map_screen_to_world(xy)[:-1] + + # print the click location + print(xy) -# more complex indexing of colors -# from point 15 - 30, set every 3rd point as "cyan" -cosine_graphic.colors[15:50:3] = "cyan" figure.canvas.set_logical_size(700, 560) diff --git a/examples/desktop/scatter/scatter_dataslice.py b/examples/desktop/scatter/scatter_dataslice.py index 1dcf53c07..af2fffebd 100644 --- a/examples/desktop/scatter/scatter_dataslice.py +++ b/examples/desktop/scatter/scatter_dataslice.py @@ -5,7 +5,7 @@ Example showing data slice for scatter plot. """ -# test_example = true +# test_example = false # sphinx_gallery_pygfx_docs = 'screenshot' import fastplotlib as fpl diff --git a/examples/desktop/scatter/scatter_iris.py b/examples/desktop/scatter/scatter_iris.py index 9a9b16edc..c16a4b135 100644 --- a/examples/desktop/scatter/scatter_iris.py +++ b/examples/desktop/scatter/scatter_iris.py @@ -5,8 +5,8 @@ Example showing scatter plot using sklearn iris dataset. """ -# test_example = false -# sphinx_gallery_pygfx_docs = 'screenshot' +# test_example = true +# sphinx_gallery_pygfx_docs = 'hidden' import fastplotlib as fpl import numpy as np @@ -17,7 +17,7 @@ current_file = Path(sys.argv[0]).resolve() -data_path = Path(current_file.parent.parent.joinpath("data", "iris.npy")) +data_path = Path(__file__).parent.parent.joinpath("data", "iris.npy") data = np.load(data_path) n_points = 50 diff --git a/fastplotlib/layouts/_figure.py b/fastplotlib/layouts/_figure.py index 3f8cbceb8..d7f5d399c 100644 --- a/fastplotlib/layouts/_figure.py +++ b/fastplotlib/layouts/_figure.py @@ -475,13 +475,8 @@ def show( _maintain_aspect = maintain_aspect subplot.auto_scale(maintain_aspect=_maintain_aspect, zoom=0.95) - # used for generating images in docs using nbsphinx - if ( - "NB_SNAPSHOT" in os.environ.keys() - and "WGPU_FORCE_OFFSCREEN" not in os.environ.keys() - ): - if os.environ["NB_SNAPSHOT"] == "1": - return self.canvas.snapshot() + if "NB_SNAPSHOT" in os.environ.keys() and os.environ["NB_SNAPSHOT"] == "1": + return self.canvas.snapshot() # return the appropriate OutputContext based on the current canvas if self.canvas.__class__.__name__ == "JupyterWgpuCanvas": From ea298dc188120d9eff73f7600a976d1811097733 Mon Sep 17 00:00:00 2001 From: Caitlin Date: Tue, 18 Jun 2024 10:43:34 -0400 Subject: [PATCH 27/32] replace screenshots and fix small bug --- examples/desktop/screenshots/gridplot.png | 4 ++-- examples/desktop/screenshots/gridplot_non_square.png | 4 ++-- examples/desktop/screenshots/heatmap.png | 4 ++-- examples/desktop/screenshots/image_cmap.png | 4 ++-- examples/desktop/screenshots/image_rgb.png | 4 ++-- examples/desktop/screenshots/image_rgbvminvmax.png | 4 ++-- examples/desktop/screenshots/image_simple.png | 4 ++-- examples/desktop/screenshots/image_vminvmax.png | 4 ++-- examples/desktop/screenshots/line.png | 4 ++-- examples/desktop/screenshots/line_cmap.png | 4 ++-- examples/desktop/screenshots/line_collection.png | 4 ++-- examples/desktop/screenshots/line_collection_cmap_values.png | 4 ++-- .../screenshots/line_collection_cmap_values_qualitative.png | 4 ++-- examples/desktop/screenshots/line_collection_colors.png | 4 ++-- examples/desktop/screenshots/line_collection_slicing.png | 3 +++ examples/desktop/screenshots/line_colorslice.png | 4 ++-- examples/desktop/screenshots/line_dataslice.png | 4 ++-- examples/desktop/screenshots/line_stack.png | 4 ++-- examples/desktop/screenshots/multigraphic_gridplot.png | 3 +++ examples/desktop/screenshots/scatter.png | 4 ++-- examples/desktop/screenshots/scatter_cmap.png | 4 ++-- examples/desktop/screenshots/scatter_colorslice.png | 4 ++-- examples/desktop/screenshots/scatter_iris.png | 3 +++ examples/desktop/screenshots/scatter_size.png | 4 ++-- examples/notebooks/screenshots/nb-astronaut.png | 4 ++-- examples/notebooks/screenshots/nb-astronaut_RGB.png | 4 ++-- examples/notebooks/screenshots/nb-camera.png | 4 ++-- .../notebooks/screenshots/nb-image-widget-movie-set_data.png | 4 ++-- .../screenshots/nb-image-widget-movie-single-0-reset.png | 4 ++-- .../notebooks/screenshots/nb-image-widget-movie-single-0.png | 4 ++-- .../screenshots/nb-image-widget-movie-single-279.png | 4 ++-- .../nb-image-widget-movie-single-50-window-max-33.png | 4 ++-- .../nb-image-widget-movie-single-50-window-mean-13.png | 4 ++-- .../nb-image-widget-movie-single-50-window-mean-33.png | 4 ++-- .../nb-image-widget-movie-single-50-window-reset.png | 4 ++-- .../notebooks/screenshots/nb-image-widget-movie-single-50.png | 4 ++-- .../notebooks/screenshots/nb-image-widget-single-gnuplot2.png | 4 ++-- examples/notebooks/screenshots/nb-image-widget-single.png | 4 ++-- .../nb-image-widget-zfish-frame-50-frame-apply-gaussian.png | 4 ++-- .../nb-image-widget-zfish-frame-50-frame-apply-reset.png | 4 ++-- .../nb-image-widget-zfish-frame-50-max-window-13.png | 4 ++-- .../nb-image-widget-zfish-frame-50-mean-window-13.png | 4 ++-- .../nb-image-widget-zfish-frame-50-mean-window-5.png | 4 ++-- .../notebooks/screenshots/nb-image-widget-zfish-frame-50.png | 4 ++-- .../notebooks/screenshots/nb-image-widget-zfish-frame-99.png | 4 ++-- ...-image-widget-zfish-grid-frame-50-frame-apply-gaussian.png | 4 ++-- .../nb-image-widget-zfish-grid-frame-50-frame-apply-reset.png | 4 ++-- .../nb-image-widget-zfish-grid-frame-50-max-window-13.png | 4 ++-- .../nb-image-widget-zfish-grid-frame-50-mean-window-13.png | 4 ++-- .../nb-image-widget-zfish-grid-frame-50-mean-window-5.png | 4 ++-- .../screenshots/nb-image-widget-zfish-grid-frame-50.png | 4 ++-- .../screenshots/nb-image-widget-zfish-grid-frame-99.png | 4 ++-- .../nb-image-widget-zfish-grid-init-mean-window-5.png | 4 ++-- ...b-image-widget-zfish-grid-set_data-reset-indices-false.png | 4 ++-- ...nb-image-widget-zfish-grid-set_data-reset-indices-true.png | 4 ++-- .../screenshots/nb-image-widget-zfish-init-mean-window-5.png | 4 ++-- .../nb-image-widget-zfish-mixed-rgb-cockatoo-frame-50.png | 4 ++-- .../nb-image-widget-zfish-mixed-rgb-cockatoo-set-data.png | 4 ++-- .../nb-image-widget-zfish-mixed-rgb-cockatoo-windowrgb.png | 4 ++-- examples/notebooks/screenshots/nb-lines-3d.png | 4 ++-- .../notebooks/screenshots/nb-lines-cmap-jet-values-cosine.png | 4 ++-- examples/notebooks/screenshots/nb-lines-cmap-jet-values.png | 4 ++-- examples/notebooks/screenshots/nb-lines-cmap-jet.png | 4 ++-- examples/notebooks/screenshots/nb-lines-cmap-tab-10.png | 4 ++-- .../notebooks/screenshots/nb-lines-cmap-viridis-values.png | 4 ++-- examples/notebooks/screenshots/nb-lines-cmap-viridis.png | 4 ++-- examples/notebooks/screenshots/nb-lines-cmap-white.png | 4 ++-- examples/notebooks/screenshots/nb-lines-colors.png | 4 ++-- examples/notebooks/screenshots/nb-lines-data.png | 4 ++-- examples/notebooks/screenshots/nb-lines-underlay.png | 4 ++-- examples/notebooks/screenshots/nb-lines.png | 4 ++-- fastplotlib/layouts/_figure.py | 3 --- 72 files changed, 145 insertions(+), 139 deletions(-) create mode 100644 examples/desktop/screenshots/line_collection_slicing.png create mode 100644 examples/desktop/screenshots/multigraphic_gridplot.png create mode 100644 examples/desktop/screenshots/scatter_iris.png diff --git a/examples/desktop/screenshots/gridplot.png b/examples/desktop/screenshots/gridplot.png index ebf2d3a97..6567c57da 100644 --- a/examples/desktop/screenshots/gridplot.png +++ b/examples/desktop/screenshots/gridplot.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f972f67b8830657ab14899f749fb385a080280304377d8868e6cd39c766a0afd -size 267084 +oid sha256:6499a000911de783b69a7958a1bf2b0290b5a3117fe14ade792baca95557b2a7 +size 263883 diff --git a/examples/desktop/screenshots/gridplot_non_square.png b/examples/desktop/screenshots/gridplot_non_square.png index bc642b729..847ed65cb 100644 --- a/examples/desktop/screenshots/gridplot_non_square.png +++ b/examples/desktop/screenshots/gridplot_non_square.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:352bf94c68444a330b000d7b6b3ec51b5b694ff3a0ce810299b325315923d9af -size 175938 +oid sha256:e4a0a002caf10e1e80ca0177bac4085e2f837ad3977f2546830acb42f0106f3f +size 173182 diff --git a/examples/desktop/screenshots/heatmap.png b/examples/desktop/screenshots/heatmap.png index a8c8b73fe..1adcc1e1d 100644 --- a/examples/desktop/screenshots/heatmap.png +++ b/examples/desktop/screenshots/heatmap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5620e4dcb964dbf3318ac77e566af395a35b9762e0687dec2e1a2864eb291fd3 -size 102994 +oid sha256:3e742d06167a49ec80253cb3984da88e6d623dc645f93bcfbd1a82966ba44a84 +size 40051 diff --git a/examples/desktop/screenshots/image_cmap.png b/examples/desktop/screenshots/image_cmap.png index bbf51ab18..9ad74e927 100644 --- a/examples/desktop/screenshots/image_cmap.png +++ b/examples/desktop/screenshots/image_cmap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:555fd969606d0cb231ac152724f7c9717a2220ce22db663c5e7d5793f828ed34 -size 189654 +oid sha256:009326a4c3605622980bf80b20cc8cc807fa610858d155304285a1a5d478b56c +size 187517 diff --git a/examples/desktop/screenshots/image_rgb.png b/examples/desktop/screenshots/image_rgb.png index 9a5082b12..50dfe6761 100644 --- a/examples/desktop/screenshots/image_rgb.png +++ b/examples/desktop/screenshots/image_rgb.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:95f3cae6caf8d64d1a6b4799df52dc61cc05bd6b6ea465edbec06a9678f32435 -size 218089 +oid sha256:c7e026664f350a4abd83297dc55a324a12ddcf8fd94625d26381d09a3fdd953b +size 216191 diff --git a/examples/desktop/screenshots/image_rgbvminvmax.png b/examples/desktop/screenshots/image_rgbvminvmax.png index 00bbdc0c5..73707177c 100644 --- a/examples/desktop/screenshots/image_rgbvminvmax.png +++ b/examples/desktop/screenshots/image_rgbvminvmax.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4fc06b8cdd72040cf2ffc44cde80d5ae21ca392daac25d79fe175b5865b13552 -size 34894 +oid sha256:a6e18e9782514b3f525d8e7f8ed83699fae48fced2b633f3f1831e4b46751c44 +size 33627 diff --git a/examples/desktop/screenshots/image_simple.png b/examples/desktop/screenshots/image_simple.png index 94fcd3061..3857baf9d 100644 --- a/examples/desktop/screenshots/image_simple.png +++ b/examples/desktop/screenshots/image_simple.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3dcfb5d48d0e4db920c33ee725e2c66f3c8e04a66e03d283a6481f42a4121a16 -size 190178 +oid sha256:1ab7ea5e0aa322c8b4249df30a80cbf3d7b55e0b7a0418f4bed99f81d14fdd7e +size 187665 diff --git a/examples/desktop/screenshots/image_vminvmax.png b/examples/desktop/screenshots/image_vminvmax.png index 00bbdc0c5..73707177c 100644 --- a/examples/desktop/screenshots/image_vminvmax.png +++ b/examples/desktop/screenshots/image_vminvmax.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4fc06b8cdd72040cf2ffc44cde80d5ae21ca392daac25d79fe175b5865b13552 -size 34894 +oid sha256:a6e18e9782514b3f525d8e7f8ed83699fae48fced2b633f3f1831e4b46751c44 +size 33627 diff --git a/examples/desktop/screenshots/line.png b/examples/desktop/screenshots/line.png index 74cbae39a..c21a522e7 100644 --- a/examples/desktop/screenshots/line.png +++ b/examples/desktop/screenshots/line.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c8b4f4a08d1791b80d226c8c3099e37d33d8cdd7a400e4f85fb7072ee2aa3c2e -size 29121 +oid sha256:aa12348340af55e7472ceb9986a73be35b398761d057e579e199055fe6bcd9ef +size 27740 diff --git a/examples/desktop/screenshots/line_cmap.png b/examples/desktop/screenshots/line_cmap.png index 9cd93f05d..5e092c844 100644 --- a/examples/desktop/screenshots/line_cmap.png +++ b/examples/desktop/screenshots/line_cmap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d60b4ff117298f973be892773dbfc620ac855c35ca7dea42437e20bf7fcef804 -size 31050 +oid sha256:7177ca064170e815870192afd9b01dd9e23332b7cbdd962592932dacac842a76 +size 29567 diff --git a/examples/desktop/screenshots/line_collection.png b/examples/desktop/screenshots/line_collection.png index bcfe85309..cc6bdcd72 100644 --- a/examples/desktop/screenshots/line_collection.png +++ b/examples/desktop/screenshots/line_collection.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7ca99b8d74fdf7f87b0f2fc5637c59c9090b91bef868e85ddd75dbcb1264f699 -size 95146 +oid sha256:8762da25c8d01ad135288e80c91750522e32c13d824862386ad3612f63e29cfc +size 93068 diff --git a/examples/desktop/screenshots/line_collection_cmap_values.png b/examples/desktop/screenshots/line_collection_cmap_values.png index b7fcdbcae..5dbe1cfda 100644 --- a/examples/desktop/screenshots/line_collection_cmap_values.png +++ b/examples/desktop/screenshots/line_collection_cmap_values.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:68090603856eb5b961092cf2ad2d89a1e9cfd7e31f6d089b3abad101874f65d4 -size 61032 +oid sha256:ba04a638118cc6a2dff2a253fa40fae099aa2acfe347570ff4a0044403a2a5b7 +size 59102 diff --git a/examples/desktop/screenshots/line_collection_cmap_values_qualitative.png b/examples/desktop/screenshots/line_collection_cmap_values_qualitative.png index 9f89a24cc..00fde0fdd 100644 --- a/examples/desktop/screenshots/line_collection_cmap_values_qualitative.png +++ b/examples/desktop/screenshots/line_collection_cmap_values_qualitative.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9cff99e5f9faf319909571778631453c043237f5c94eece6680b028a5d7a5ac2 -size 64149 +oid sha256:a592bf90017c25abf163936c4c475b8a96ac0775e450c8d7355011fe20bbfb22 +size 62416 diff --git a/examples/desktop/screenshots/line_collection_colors.png b/examples/desktop/screenshots/line_collection_colors.png index 7bb4152fd..cf7880a6c 100644 --- a/examples/desktop/screenshots/line_collection_colors.png +++ b/examples/desktop/screenshots/line_collection_colors.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a4aa17a65806300da65f4bbbfccb970d6a7207c4ca4d48b25615f627630fb484 -size 51174 +oid sha256:052a46223f73099eacf2b4672348c1110c14b22a85131b73561ac1feb8e9c796 +size 49693 diff --git a/examples/desktop/screenshots/line_collection_slicing.png b/examples/desktop/screenshots/line_collection_slicing.png new file mode 100644 index 000000000..54d2a1098 --- /dev/null +++ b/examples/desktop/screenshots/line_collection_slicing.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:07a02cb8a93527e913d35a0caed5dfc2feb01234d63b73ba3c3e244bbfda5e59 +size 129082 diff --git a/examples/desktop/screenshots/line_colorslice.png b/examples/desktop/screenshots/line_colorslice.png index 3d04c473f..2bcf008a5 100644 --- a/examples/desktop/screenshots/line_colorslice.png +++ b/examples/desktop/screenshots/line_colorslice.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:aa941eaf5b940b4eebab89ed836cbd092e16b4758abafa3722c296db65c0c4b5 -size 33233 +oid sha256:69c4994a1259511a6480c2227a31472ab527f33f747cd44b9018f409e03ba1f1 +size 32353 diff --git a/examples/desktop/screenshots/line_dataslice.png b/examples/desktop/screenshots/line_dataslice.png index 0863751bf..395d2f1bf 100644 --- a/examples/desktop/screenshots/line_dataslice.png +++ b/examples/desktop/screenshots/line_dataslice.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:78ccd51d1891fb6a345cb2885a341f276d8ad7a6fa506deda6cae6ef14c64094 -size 45843 +oid sha256:268a0e9a6a32e015466b7a72b8cb9675597db2b3212edaf818871a27602a751c +size 44986 diff --git a/examples/desktop/screenshots/line_stack.png b/examples/desktop/screenshots/line_stack.png index c13f05f04..edaae0d0a 100644 --- a/examples/desktop/screenshots/line_stack.png +++ b/examples/desktop/screenshots/line_stack.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5480aefe6e723863b919a4eeb4755310fe7036b27beb8e2e2402e04943ee8c1e -size 201102 +oid sha256:2b3ae8275e536669dfabdc8c3b715d1ca9c73f17062ab1f90f9650bd86b1c4f7 +size 91285 diff --git a/examples/desktop/screenshots/multigraphic_gridplot.png b/examples/desktop/screenshots/multigraphic_gridplot.png new file mode 100644 index 000000000..5a8f3be99 --- /dev/null +++ b/examples/desktop/screenshots/multigraphic_gridplot.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a19f917efe95db66ea2f600e50428f476952cdb22d7e23306facfe0e421d04a2 +size 163713 diff --git a/examples/desktop/screenshots/scatter.png b/examples/desktop/screenshots/scatter.png index 94fb858e1..195c5ae64 100644 --- a/examples/desktop/screenshots/scatter.png +++ b/examples/desktop/screenshots/scatter.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4fc16a1ba74a8eca99a2fc7937f8896ca93207b99e231bc4f53845b0d2bdaed7 -size 15283 +oid sha256:b0f6c3d3b5e7216cc17c70ad3ff114092b1556fb9dcd171ae737f28d52ce51c9 +size 106634 diff --git a/examples/desktop/screenshots/scatter_cmap.png b/examples/desktop/screenshots/scatter_cmap.png index 87a6e0ded..55442aceb 100644 --- a/examples/desktop/screenshots/scatter_cmap.png +++ b/examples/desktop/screenshots/scatter_cmap.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a02d2b5d4735d656d1b754ac3681a7700d961d7e4a43dfaf3a7dd0d4f6516ba6 -size 37808 +oid sha256:0655f8f5f1fdeecbd5d097cf90a4776dd8125a16d0e8edb86aa37f77daba0d9b +size 107892 diff --git a/examples/desktop/screenshots/scatter_colorslice.png b/examples/desktop/screenshots/scatter_colorslice.png index cede76dfd..7c43dd6cb 100644 --- a/examples/desktop/screenshots/scatter_colorslice.png +++ b/examples/desktop/screenshots/scatter_colorslice.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f7956e02d6c231bab091adb4ce9102ad4943050ccf171a0594a899a381880771 -size 14712 +oid sha256:d3319afffb554eb624d9bba5b87daf331b619ac5ec5006f13e479b613f43ca32 +size 72083 diff --git a/examples/desktop/screenshots/scatter_iris.png b/examples/desktop/screenshots/scatter_iris.png new file mode 100644 index 000000000..aa1d2b743 --- /dev/null +++ b/examples/desktop/screenshots/scatter_iris.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:320a02df6de51235b1912b26df4ea7633e9513df4d4034605a4e00724ceb57dc +size 14131 diff --git a/examples/desktop/screenshots/scatter_size.png b/examples/desktop/screenshots/scatter_size.png index 056d2a531..2d4e559fe 100644 --- a/examples/desktop/screenshots/scatter_size.png +++ b/examples/desktop/screenshots/scatter_size.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5ccfbac94de6ba122ea420dce58e4a576b2d58d9282aaf8d64de399278df57b3 -size 38076 +oid sha256:a96a5da476b22f3ebd42ec927c3d1c1dee4dc20f261a97feaced69ed4142c645 +size 35484 diff --git a/examples/notebooks/screenshots/nb-astronaut.png b/examples/notebooks/screenshots/nb-astronaut.png index 378260288..3e55979ee 100644 --- a/examples/notebooks/screenshots/nb-astronaut.png +++ b/examples/notebooks/screenshots/nb-astronaut.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e584533ea04b9758634ba62dceeb72991861c509d01dc082436c54c272686409 -size 112104 +oid sha256:a0fdb5b319347b4db4611dcf92cf08359c938f42a64b05d0dd163e0ca289e3c3 +size 112299 diff --git a/examples/notebooks/screenshots/nb-astronaut_RGB.png b/examples/notebooks/screenshots/nb-astronaut_RGB.png index bf11bf667..fbb514e3e 100644 --- a/examples/notebooks/screenshots/nb-astronaut_RGB.png +++ b/examples/notebooks/screenshots/nb-astronaut_RGB.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:db9602a610f258803d74ac03cd46447dd5a7ad62241ec26a4c3df30c1d6de299 -size 110408 +oid sha256:2d312ce9097114bc32886c0370861bcf7deebfb4fda99e03817ebec2226eabdc +size 110338 diff --git a/examples/notebooks/screenshots/nb-camera.png b/examples/notebooks/screenshots/nb-camera.png index 9db4005bc..5629bd211 100644 --- a/examples/notebooks/screenshots/nb-camera.png +++ b/examples/notebooks/screenshots/nb-camera.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4bb9080b99c2717e093bf6ae4986bf0689a8d377e137a7022c9c6929b9a335d3 -size 77965 +oid sha256:0a415917cc16f09ab7b78eea5e5579d7dd45b6d92e80d87ba0970e9dd0568eb2 +size 77419 diff --git a/examples/notebooks/screenshots/nb-image-widget-movie-set_data.png b/examples/notebooks/screenshots/nb-image-widget-movie-set_data.png index 5be8f55a3..486c89963 100644 --- a/examples/notebooks/screenshots/nb-image-widget-movie-set_data.png +++ b/examples/notebooks/screenshots/nb-image-widget-movie-set_data.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:66a310e312add59a310ff0a50335db97ac557d7f2967d8251a7d811c25a4de28 -size 40517 +oid sha256:3dbb4d04175c5603ff7e56a04438c8f0cfff7deff61889a06c342cedc04ac323 +size 43172 diff --git a/examples/notebooks/screenshots/nb-image-widget-movie-single-0-reset.png b/examples/notebooks/screenshots/nb-image-widget-movie-single-0-reset.png index 8572f6472..1369669e6 100644 --- a/examples/notebooks/screenshots/nb-image-widget-movie-single-0-reset.png +++ b/examples/notebooks/screenshots/nb-image-widget-movie-single-0-reset.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ff83d6bab26b9bbccf66ed100764ffdfc7556f4cb04f0b85f50c2497ba0ab257 -size 134419 +oid sha256:7049dc9344a8d51bcfc3ba7f96a25c84db27f5072f14e8845cd2f01c3f4f5310 +size 133683 diff --git a/examples/notebooks/screenshots/nb-image-widget-movie-single-0.png b/examples/notebooks/screenshots/nb-image-widget-movie-single-0.png index 8572f6472..1369669e6 100644 --- a/examples/notebooks/screenshots/nb-image-widget-movie-single-0.png +++ b/examples/notebooks/screenshots/nb-image-widget-movie-single-0.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ff83d6bab26b9bbccf66ed100764ffdfc7556f4cb04f0b85f50c2497ba0ab257 -size 134419 +oid sha256:7049dc9344a8d51bcfc3ba7f96a25c84db27f5072f14e8845cd2f01c3f4f5310 +size 133683 diff --git a/examples/notebooks/screenshots/nb-image-widget-movie-single-279.png b/examples/notebooks/screenshots/nb-image-widget-movie-single-279.png index e241ce5a6..5817cd299 100644 --- a/examples/notebooks/screenshots/nb-image-widget-movie-single-279.png +++ b/examples/notebooks/screenshots/nb-image-widget-movie-single-279.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:337a22f11649b350f7f47d68d82be165633caeb7f8cef581e50f981d6ec0c52c -size 169615 +oid sha256:1ca687c654679ee9d47a053196fb65d92105ed6cce76f0d2d1775582053e7b07 +size 168750 diff --git a/examples/notebooks/screenshots/nb-image-widget-movie-single-50-window-max-33.png b/examples/notebooks/screenshots/nb-image-widget-movie-single-50-window-max-33.png index b827fc536..2f2e310d0 100644 --- a/examples/notebooks/screenshots/nb-image-widget-movie-single-50-window-max-33.png +++ b/examples/notebooks/screenshots/nb-image-widget-movie-single-50-window-max-33.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:22ff3ed815fcbe8bc95c321c806a4b42536e7014209cd43ac597a5ccefd8b9c6 -size 149261 +oid sha256:dd51516d18f550f62b9f2c989cfae82d267eb6de1d8757cf44949bb41c3b13c2 +size 148408 diff --git a/examples/notebooks/screenshots/nb-image-widget-movie-single-50-window-mean-13.png b/examples/notebooks/screenshots/nb-image-widget-movie-single-50-window-mean-13.png index d37f44a3a..39a4f1274 100644 --- a/examples/notebooks/screenshots/nb-image-widget-movie-single-50-window-mean-13.png +++ b/examples/notebooks/screenshots/nb-image-widget-movie-single-50-window-mean-13.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:11143f73a297d0b59c92db1b115ceac1bc1304135a9925302e616a4fd3669b25 -size 125012 +oid sha256:9613c10e63261ddbcf3274a9804bdf3a1be0734c1190720663b01f8b2ae48389 +size 124532 diff --git a/examples/notebooks/screenshots/nb-image-widget-movie-single-50-window-mean-33.png b/examples/notebooks/screenshots/nb-image-widget-movie-single-50-window-mean-33.png index 46d3fa9b3..b9feacb82 100644 --- a/examples/notebooks/screenshots/nb-image-widget-movie-single-50-window-mean-33.png +++ b/examples/notebooks/screenshots/nb-image-widget-movie-single-50-window-mean-33.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7438018c3b55d423f57c42a9d03c1af6d5de168a2dfa5df9d535ef2ae1f1c8e9 -size 113981 +oid sha256:8fa86b26f11bd9655c60e43ddd88ada618cea1ba06b3dcddcb408569c09a7750 +size 113897 diff --git a/examples/notebooks/screenshots/nb-image-widget-movie-single-50-window-reset.png b/examples/notebooks/screenshots/nb-image-widget-movie-single-50-window-reset.png index 6146a7985..ae280a970 100644 --- a/examples/notebooks/screenshots/nb-image-widget-movie-single-50-window-reset.png +++ b/examples/notebooks/screenshots/nb-image-widget-movie-single-50-window-reset.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9b57a1e6640de9471540fa4d86faadb706d6de8cc1de6a29fb65d709b91eef1e -size 146429 +oid sha256:aca573ba6dcda8ad8f018a96790b1b1aa5da25fe9584a57c2c946e1cf2df9e5c +size 145275 diff --git a/examples/notebooks/screenshots/nb-image-widget-movie-single-50.png b/examples/notebooks/screenshots/nb-image-widget-movie-single-50.png index 6146a7985..ae280a970 100644 --- a/examples/notebooks/screenshots/nb-image-widget-movie-single-50.png +++ b/examples/notebooks/screenshots/nb-image-widget-movie-single-50.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9b57a1e6640de9471540fa4d86faadb706d6de8cc1de6a29fb65d709b91eef1e -size 146429 +oid sha256:aca573ba6dcda8ad8f018a96790b1b1aa5da25fe9584a57c2c946e1cf2df9e5c +size 145275 diff --git a/examples/notebooks/screenshots/nb-image-widget-single-gnuplot2.png b/examples/notebooks/screenshots/nb-image-widget-single-gnuplot2.png index b8bf7adeb..02423a02a 100644 --- a/examples/notebooks/screenshots/nb-image-widget-single-gnuplot2.png +++ b/examples/notebooks/screenshots/nb-image-widget-single-gnuplot2.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:dbfa1e7aeb7f0a068a33f2f11023a06f834332f7b3d8e4cf97b51222536fd6cb -size 434782 +oid sha256:d7384d1a69629cfcdbebdc9e9e6a152383446f3cb696e69a11543253cdde2e64 +size 434060 diff --git a/examples/notebooks/screenshots/nb-image-widget-single.png b/examples/notebooks/screenshots/nb-image-widget-single.png index 86119e247..408739d6e 100644 --- a/examples/notebooks/screenshots/nb-image-widget-single.png +++ b/examples/notebooks/screenshots/nb-image-widget-single.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7ceee2cdd73092cb84b4b0f2876fc08d838b8a47bb94d431a6c19c8a4793a153 -size 403521 +oid sha256:b57dffe179b6f52d204968085c885d70183d1f6a9a3f5a1dc2d005229b7acd01 +size 404179 diff --git a/examples/notebooks/screenshots/nb-image-widget-zfish-frame-50-frame-apply-gaussian.png b/examples/notebooks/screenshots/nb-image-widget-zfish-frame-50-frame-apply-gaussian.png index 82cee281f..596548486 100644 --- a/examples/notebooks/screenshots/nb-image-widget-zfish-frame-50-frame-apply-gaussian.png +++ b/examples/notebooks/screenshots/nb-image-widget-zfish-frame-50-frame-apply-gaussian.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:47e3e6cea0e738b2731060488886606f05595cfdfb0d81e6db1aa099dc8e3a84 -size 148181 +oid sha256:da1c660e4fb779ac6a4baed3d329cf80274981288ea076f243bb43aee7fb8eff +size 157731 diff --git a/examples/notebooks/screenshots/nb-image-widget-zfish-frame-50-frame-apply-reset.png b/examples/notebooks/screenshots/nb-image-widget-zfish-frame-50-frame-apply-reset.png index 0b7832eee..1318be413 100644 --- a/examples/notebooks/screenshots/nb-image-widget-zfish-frame-50-frame-apply-reset.png +++ b/examples/notebooks/screenshots/nb-image-widget-zfish-frame-50-frame-apply-reset.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0af4ceb50ed269aa80667c3012a871c87f73777cd8cb497ebb243b53932b9bad -size 72377 +oid sha256:0d4f6407c3b029b01088fab9522a21f7d90d7a87def1ecbbb45f0fb4f8508f87 +size 69106 diff --git a/examples/notebooks/screenshots/nb-image-widget-zfish-frame-50-max-window-13.png b/examples/notebooks/screenshots/nb-image-widget-zfish-frame-50-max-window-13.png index 2bc2db3a5..e5fdbdd28 100644 --- a/examples/notebooks/screenshots/nb-image-widget-zfish-frame-50-max-window-13.png +++ b/examples/notebooks/screenshots/nb-image-widget-zfish-frame-50-max-window-13.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9053c70da35fd42fe44a76e0ace8788ba79667b33c596409ca1e1f2f6d6ba3ad -size 195906 +oid sha256:e4176109805f4f521a1b630b68df1dce80a63b82a5ed01a6ba4c2cae0dfeb6bd +size 184423 diff --git a/examples/notebooks/screenshots/nb-image-widget-zfish-frame-50-mean-window-13.png b/examples/notebooks/screenshots/nb-image-widget-zfish-frame-50-mean-window-13.png index d5999dd0f..bf9548962 100644 --- a/examples/notebooks/screenshots/nb-image-widget-zfish-frame-50-mean-window-13.png +++ b/examples/notebooks/screenshots/nb-image-widget-zfish-frame-50-mean-window-13.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:77d4a8542a5507e3eda1203a6da29a2f533bbbe2988ad297948c74e44a4337ec -size 177152 +oid sha256:12df56b1045cdaddb94355b7e960aa58137a44eff4ff22aab3596c53ea7944c8 +size 179403 diff --git a/examples/notebooks/screenshots/nb-image-widget-zfish-frame-50-mean-window-5.png b/examples/notebooks/screenshots/nb-image-widget-zfish-frame-50-mean-window-5.png index 29af0398d..7b3e6bfba 100644 --- a/examples/notebooks/screenshots/nb-image-widget-zfish-frame-50-mean-window-5.png +++ b/examples/notebooks/screenshots/nb-image-widget-zfish-frame-50-mean-window-5.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3422923039d45b20ea6150f0ad545bdf876596ba60b156df5ec4004590a29a3e -size 139029 +oid sha256:d5fd2f0918f4a29769ebb572f5163abb52667cf24e89efdd1d99bc57a0f5f607 +size 140124 diff --git a/examples/notebooks/screenshots/nb-image-widget-zfish-frame-50.png b/examples/notebooks/screenshots/nb-image-widget-zfish-frame-50.png index bb07b8fbb..a72245f3b 100644 --- a/examples/notebooks/screenshots/nb-image-widget-zfish-frame-50.png +++ b/examples/notebooks/screenshots/nb-image-widget-zfish-frame-50.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ba9e055298372238ce0cd0c5ac4d75db8cd53f3f4acffbcc22bf7d503b40ec57 -size 79174 +oid sha256:981c925f52ae8789f7f0d24ef3fe34efb7a08f221a7bc6079dd12f01099c3d25 +size 75054 diff --git a/examples/notebooks/screenshots/nb-image-widget-zfish-frame-99.png b/examples/notebooks/screenshots/nb-image-widget-zfish-frame-99.png index 6e8274659..19c19dc1f 100644 --- a/examples/notebooks/screenshots/nb-image-widget-zfish-frame-99.png +++ b/examples/notebooks/screenshots/nb-image-widget-zfish-frame-99.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c6aed15f9f1b6bae442687613c5b04621f42e78f1dbda1e3560b000d652ba0b3 -size 61523 +oid sha256:6a5ecd1f966250ead16a96df996ff39877b4ee28534b7724a4a8e1db9c8984d2 +size 58334 diff --git a/examples/notebooks/screenshots/nb-image-widget-zfish-grid-frame-50-frame-apply-gaussian.png b/examples/notebooks/screenshots/nb-image-widget-zfish-grid-frame-50-frame-apply-gaussian.png index 28704bd2d..bcf663279 100644 --- a/examples/notebooks/screenshots/nb-image-widget-zfish-grid-frame-50-frame-apply-gaussian.png +++ b/examples/notebooks/screenshots/nb-image-widget-zfish-grid-frame-50-frame-apply-gaussian.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:499fab9183f2528297fdfa3c96a25eb58b2376a44556d790ef06928e0379af3a -size 174612 +oid sha256:dbe1375ae8d2f348ad5d7e030fa67d45c250c6ed263c67179d542d0bd903e0d3 +size 177334 diff --git a/examples/notebooks/screenshots/nb-image-widget-zfish-grid-frame-50-frame-apply-reset.png b/examples/notebooks/screenshots/nb-image-widget-zfish-grid-frame-50-frame-apply-reset.png index d163fd22a..963290515 100644 --- a/examples/notebooks/screenshots/nb-image-widget-zfish-grid-frame-50-frame-apply-reset.png +++ b/examples/notebooks/screenshots/nb-image-widget-zfish-grid-frame-50-frame-apply-reset.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:72832b86f802ee90b4eb54cb64d64aff59527fe0c7dcb87a4d8ab281ad15726b -size 142136 +oid sha256:0ff341df374d816411e58c82d432e98a9f4cec1551725dafcd65cdb0c43edb12 +size 138235 diff --git a/examples/notebooks/screenshots/nb-image-widget-zfish-grid-frame-50-max-window-13.png b/examples/notebooks/screenshots/nb-image-widget-zfish-grid-frame-50-max-window-13.png index 52ebd8591..a049a484c 100644 --- a/examples/notebooks/screenshots/nb-image-widget-zfish-grid-frame-50-max-window-13.png +++ b/examples/notebooks/screenshots/nb-image-widget-zfish-grid-frame-50-max-window-13.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b414fbb8f6935901b65851de9c7cb37df628d7b24759dc7f407ee130389216a3 -size 371687 +oid sha256:bd4c51f7e07e46d7c660d28563aff1b7d3759387fc10db10addca29dfc0919b0 +size 365838 diff --git a/examples/notebooks/screenshots/nb-image-widget-zfish-grid-frame-50-mean-window-13.png b/examples/notebooks/screenshots/nb-image-widget-zfish-grid-frame-50-mean-window-13.png index 6c406a621..ada15017c 100644 --- a/examples/notebooks/screenshots/nb-image-widget-zfish-grid-frame-50-mean-window-13.png +++ b/examples/notebooks/screenshots/nb-image-widget-zfish-grid-frame-50-mean-window-13.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e0ef52156509f308d972533fb45509ba7451b4d6149400d519aae28274609e41 -size 212053 +oid sha256:1d13cc8a32b40f5c721ab30020632d7dc1c679c8c8e5857476176e986de18ad3 +size 211240 diff --git a/examples/notebooks/screenshots/nb-image-widget-zfish-grid-frame-50-mean-window-5.png b/examples/notebooks/screenshots/nb-image-widget-zfish-grid-frame-50-mean-window-5.png index aaed804b8..2e71fd30d 100644 --- a/examples/notebooks/screenshots/nb-image-widget-zfish-grid-frame-50-mean-window-5.png +++ b/examples/notebooks/screenshots/nb-image-widget-zfish-grid-frame-50-mean-window-5.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8fd94e597074094dc3718153c8bb94fb0b1bf58e58e34601e5c7281f938f52bd -size 200278 +oid sha256:39044f4bb54038eee17f0d75940fd848b304629858d9e747ac0c81ce076d3c25 +size 199075 diff --git a/examples/notebooks/screenshots/nb-image-widget-zfish-grid-frame-50.png b/examples/notebooks/screenshots/nb-image-widget-zfish-grid-frame-50.png index 3110fa7cf..690b1c578 100644 --- a/examples/notebooks/screenshots/nb-image-widget-zfish-grid-frame-50.png +++ b/examples/notebooks/screenshots/nb-image-widget-zfish-grid-frame-50.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:76ab21314fbd7846c1b94aeeed9ef7b97be99d2f2f7f09c13c0474a889c21179 -size 159319 +oid sha256:109a4c8d708114e1b36d1a9fa129dbd9a768617baa953f37500310c0968b688a +size 154169 diff --git a/examples/notebooks/screenshots/nb-image-widget-zfish-grid-frame-99.png b/examples/notebooks/screenshots/nb-image-widget-zfish-grid-frame-99.png index 0cfad54e7..3e577698c 100644 --- a/examples/notebooks/screenshots/nb-image-widget-zfish-grid-frame-99.png +++ b/examples/notebooks/screenshots/nb-image-widget-zfish-grid-frame-99.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:77f247de5374a8cb7ce27a338ab8be880d53d9586b52f646b400901ba70be3aa -size 146217 +oid sha256:568ae05e8889cec56530db0149613826f2697f55d8252cffbd32ff692b565fcf +size 141338 diff --git a/examples/notebooks/screenshots/nb-image-widget-zfish-grid-init-mean-window-5.png b/examples/notebooks/screenshots/nb-image-widget-zfish-grid-init-mean-window-5.png index c74807939..1ab48d117 100644 --- a/examples/notebooks/screenshots/nb-image-widget-zfish-grid-init-mean-window-5.png +++ b/examples/notebooks/screenshots/nb-image-widget-zfish-grid-init-mean-window-5.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:33c3dfa77bbc558493634ab83fd1539ef76022a2e20d10e1353d2bd0a0e94a2c -size 183739 +oid sha256:e7847dc083d6df2b20788b42153674c557b627b75db74d9446b06e165aa5a50a +size 182713 diff --git a/examples/notebooks/screenshots/nb-image-widget-zfish-grid-set_data-reset-indices-false.png b/examples/notebooks/screenshots/nb-image-widget-zfish-grid-set_data-reset-indices-false.png index a2841b1d5..0b0f05fc3 100644 --- a/examples/notebooks/screenshots/nb-image-widget-zfish-grid-set_data-reset-indices-false.png +++ b/examples/notebooks/screenshots/nb-image-widget-zfish-grid-set_data-reset-indices-false.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:715f7909db0d374c2e618bb41f7a6341a8cc8891b1e3e8678a6f934fd71159a4 -size 127129 +oid sha256:839dd3fdc9db98d7044d88e816c179bff34f30584ba26ce7a96ea3b35fc3374e +size 122463 diff --git a/examples/notebooks/screenshots/nb-image-widget-zfish-grid-set_data-reset-indices-true.png b/examples/notebooks/screenshots/nb-image-widget-zfish-grid-set_data-reset-indices-true.png index 9064f2323..534403b1e 100644 --- a/examples/notebooks/screenshots/nb-image-widget-zfish-grid-set_data-reset-indices-true.png +++ b/examples/notebooks/screenshots/nb-image-widget-zfish-grid-set_data-reset-indices-true.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:76708e8e6e6865d700aa5286fca4d58ba4eb91f21ab3b0243bb128e9a84f063c -size 131192 +oid sha256:f7088e11517a4a78492d16746ac8101b2e5e9142ebd61966030c555ab173443e +size 126267 diff --git a/examples/notebooks/screenshots/nb-image-widget-zfish-init-mean-window-5.png b/examples/notebooks/screenshots/nb-image-widget-zfish-init-mean-window-5.png index 1fbaec974..94993c688 100644 --- a/examples/notebooks/screenshots/nb-image-widget-zfish-init-mean-window-5.png +++ b/examples/notebooks/screenshots/nb-image-widget-zfish-init-mean-window-5.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:51c62474b9ebee76242ef82a710a83b90e0183792790f6a2cd00213642b76755 -size 99519 +oid sha256:709c7ec07e3e37e0415fad3fa542729d2896e8e546b6ea8d1373e7b46005bc26 +size 97278 diff --git a/examples/notebooks/screenshots/nb-image-widget-zfish-mixed-rgb-cockatoo-frame-50.png b/examples/notebooks/screenshots/nb-image-widget-zfish-mixed-rgb-cockatoo-frame-50.png index 5e0750ac8..27c693c1a 100644 --- a/examples/notebooks/screenshots/nb-image-widget-zfish-mixed-rgb-cockatoo-frame-50.png +++ b/examples/notebooks/screenshots/nb-image-widget-zfish-mixed-rgb-cockatoo-frame-50.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7f8f74a0a5fa24e10a88d3723836306913243fa5fc23f46f44bbdae4c0209075 -size 58878 +oid sha256:c66db583e0d455319b665d35a8c5c8a5f717653c11311cdaba90e2c85e64235f +size 58941 diff --git a/examples/notebooks/screenshots/nb-image-widget-zfish-mixed-rgb-cockatoo-set-data.png b/examples/notebooks/screenshots/nb-image-widget-zfish-mixed-rgb-cockatoo-set-data.png index 8df83fe33..7444d7dbf 100644 --- a/examples/notebooks/screenshots/nb-image-widget-zfish-mixed-rgb-cockatoo-set-data.png +++ b/examples/notebooks/screenshots/nb-image-widget-zfish-mixed-rgb-cockatoo-set-data.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0809b2dda0e773b7f100386f97144c40d36d51cd935c86ef1dcd4a938fce3981 -size 56319 +oid sha256:36867cd793634d00c46c782911abae6e7c579067aeeed891e40ddedbb0c228d9 +size 56505 diff --git a/examples/notebooks/screenshots/nb-image-widget-zfish-mixed-rgb-cockatoo-windowrgb.png b/examples/notebooks/screenshots/nb-image-widget-zfish-mixed-rgb-cockatoo-windowrgb.png index 5bbefc7ae..3941f3120 100644 --- a/examples/notebooks/screenshots/nb-image-widget-zfish-mixed-rgb-cockatoo-windowrgb.png +++ b/examples/notebooks/screenshots/nb-image-widget-zfish-mixed-rgb-cockatoo-windowrgb.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a2e2e2cf7ac6be1a4fccec54494c3fd48af673765653675438fa2469c549e90c -size 55055 +oid sha256:8b23f3655fcfcd85f6138f4de5cedf228a6dbad0c8cff0c87900042f83b8f409 +size 55269 diff --git a/examples/notebooks/screenshots/nb-lines-3d.png b/examples/notebooks/screenshots/nb-lines-3d.png index a3b75de58..6c19c965c 100644 --- a/examples/notebooks/screenshots/nb-lines-3d.png +++ b/examples/notebooks/screenshots/nb-lines-3d.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:677f544d93cf7a733003c38666f555f0b598d41b92681dd2f09e6c11faa4aed0 -size 14186 +oid sha256:c6ab8d74c980a02505d5d626d170b60847ce2b733ea5b47278a1f48228011a38 +size 14181 diff --git a/examples/notebooks/screenshots/nb-lines-cmap-jet-values-cosine.png b/examples/notebooks/screenshots/nb-lines-cmap-jet-values-cosine.png index 0d9ff5729..f75d83ba4 100644 --- a/examples/notebooks/screenshots/nb-lines-cmap-jet-values-cosine.png +++ b/examples/notebooks/screenshots/nb-lines-cmap-jet-values-cosine.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0d981d57d7905879ab68af95da84d2cf530a9a40dc4d0ffb138119a11f4966be -size 11808 +oid sha256:d2b87297587b5f76062132370fdf7e8318cbde68d38d12a0179548f9790c2af8 +size 11765 diff --git a/examples/notebooks/screenshots/nb-lines-cmap-jet-values.png b/examples/notebooks/screenshots/nb-lines-cmap-jet-values.png index dbcbf1e7f..a8229cfc8 100644 --- a/examples/notebooks/screenshots/nb-lines-cmap-jet-values.png +++ b/examples/notebooks/screenshots/nb-lines-cmap-jet-values.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:706bffa485dd7994a70602ef2076aee79e1206dd508fbac903549fce526087b6 -size 13095 +oid sha256:99f6a7a9a1399aaf8d1070812c41f03f80ba41812a1acf9d4bdd17641bc589f4 +size 13038 diff --git a/examples/notebooks/screenshots/nb-lines-cmap-jet.png b/examples/notebooks/screenshots/nb-lines-cmap-jet.png index 6a3ae0c1c..ccc897f66 100644 --- a/examples/notebooks/screenshots/nb-lines-cmap-jet.png +++ b/examples/notebooks/screenshots/nb-lines-cmap-jet.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cfd3f55e1671ac1fa45a8eb26aeb425ccb8d1ac033f5766f4002fee4380b2a77 -size 11174 +oid sha256:cac3d7cb23d7ec207cdf7fd7032037c7749e30563754d6c2cac50d67a7731a2d +size 11086 diff --git a/examples/notebooks/screenshots/nb-lines-cmap-tab-10.png b/examples/notebooks/screenshots/nb-lines-cmap-tab-10.png index 9bb368e0e..8ddc44ead 100644 --- a/examples/notebooks/screenshots/nb-lines-cmap-tab-10.png +++ b/examples/notebooks/screenshots/nb-lines-cmap-tab-10.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:338dbcdf1a87266eee33367bfa08bcaec7eac42ef2dd928bbc699b3a0412ebaf -size 9889 +oid sha256:d38a2c27e5b598883c40b44e45b347f029a7369b638bc4111ef2d69978245378 +size 9943 diff --git a/examples/notebooks/screenshots/nb-lines-cmap-viridis-values.png b/examples/notebooks/screenshots/nb-lines-cmap-viridis-values.png index 23137bdf3..6bf270874 100644 --- a/examples/notebooks/screenshots/nb-lines-cmap-viridis-values.png +++ b/examples/notebooks/screenshots/nb-lines-cmap-viridis-values.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e36a7a74ac39dac5ac96a4e7c8e56990794ab1cda1b8ee5276087e9814dd1696 -size 10100 +oid sha256:d0ead67733470d6afcb2228645ee1a056acd525d369d74c16b1054783d6ab4f5 +size 10155 diff --git a/examples/notebooks/screenshots/nb-lines-cmap-viridis.png b/examples/notebooks/screenshots/nb-lines-cmap-viridis.png index 2fcd4749c..4f99e5fb5 100644 --- a/examples/notebooks/screenshots/nb-lines-cmap-viridis.png +++ b/examples/notebooks/screenshots/nb-lines-cmap-viridis.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b12ee5e31f64415b57536c59587b91c7a3a7c74e95be3459d8036a43d073d7db -size 13821 +oid sha256:15f4decaa6ba08f09a988771c5dc433629cb9e3bccfa08f820268366a3ff06a6 +size 13761 diff --git a/examples/notebooks/screenshots/nb-lines-cmap-white.png b/examples/notebooks/screenshots/nb-lines-cmap-white.png index 397b5fc94..85e43aa5e 100644 --- a/examples/notebooks/screenshots/nb-lines-cmap-white.png +++ b/examples/notebooks/screenshots/nb-lines-cmap-white.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6239f23d3b5c1745879f5706352abb905d5638522b171776bff051e511426c2f -size 8359 +oid sha256:8a623f31d28533cc6052143856d0ef2e827b42891397fa4ac20d358f44d751d7 +size 8332 diff --git a/examples/notebooks/screenshots/nb-lines-colors.png b/examples/notebooks/screenshots/nb-lines-colors.png index 149321e52..ab50dfaaf 100644 --- a/examples/notebooks/screenshots/nb-lines-colors.png +++ b/examples/notebooks/screenshots/nb-lines-colors.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9a5e99c5a872d9bbf8dd909498459ddee7f22f08d3fe3cd68b3ea57c105ab51b -size 27634 +oid sha256:0cbcafef567bff33762d64bcf6f83c7a1982015ea21d508b1e6564cb0d8435d2 +size 27420 diff --git a/examples/notebooks/screenshots/nb-lines-data.png b/examples/notebooks/screenshots/nb-lines-data.png index 9ed38b1f5..88f1001ad 100644 --- a/examples/notebooks/screenshots/nb-lines-data.png +++ b/examples/notebooks/screenshots/nb-lines-data.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cc0d3d6819ce0d9f5d531276bbde0397ef35e3084ac1f9b3575f0209eea07456 -size 39512 +oid sha256:f62dc16cd1ea212cf29974a64e6ad2dd3d7ae10d7b3eef573c25316bbe89b097 +size 38740 diff --git a/examples/notebooks/screenshots/nb-lines-underlay.png b/examples/notebooks/screenshots/nb-lines-underlay.png index d4b3d9f6d..f9650e253 100644 --- a/examples/notebooks/screenshots/nb-lines-underlay.png +++ b/examples/notebooks/screenshots/nb-lines-underlay.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9b12c8f29436be8d17c38f420120ab3d54b0eee9bef751eea2f99d01b1a8fa43 -size 50761 +oid sha256:ec7881cc0084b0ea2182f8d4f6f23388a4d48b88dbbf9c06b9dc2fa8125989b7 +size 49553 diff --git a/examples/notebooks/screenshots/nb-lines.png b/examples/notebooks/screenshots/nb-lines.png index 603f4a8fc..7df6ea14f 100644 --- a/examples/notebooks/screenshots/nb-lines.png +++ b/examples/notebooks/screenshots/nb-lines.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:eeef2c47e7dde62038307fa7929a306801bf8b708fbcf1062ed9c751727bfb2b -size 24300 +oid sha256:b925337438aa24f0179a8b5c1688e154679fa002402a16746b6bb3cd6684af1e +size 24246 diff --git a/fastplotlib/layouts/_figure.py b/fastplotlib/layouts/_figure.py index d7f5d399c..17bb28095 100644 --- a/fastplotlib/layouts/_figure.py +++ b/fastplotlib/layouts/_figure.py @@ -475,9 +475,6 @@ def show( _maintain_aspect = maintain_aspect subplot.auto_scale(maintain_aspect=_maintain_aspect, zoom=0.95) - if "NB_SNAPSHOT" in os.environ.keys() and os.environ["NB_SNAPSHOT"] == "1": - return self.canvas.snapshot() - # return the appropriate OutputContext based on the current canvas if self.canvas.__class__.__name__ == "JupyterWgpuCanvas": from .output.jupyter_output import ( From 950d4b43f9de7c90ea27f4233c7331be1697044d Mon Sep 17 00:00:00 2001 From: Caitlin Date: Tue, 18 Jun 2024 11:00:57 -0400 Subject: [PATCH 28/32] fix scatter examples for CI build --- examples/desktop/scatter/scatter.py | 2 +- examples/desktop/scatter/scatter_cmap.py | 2 +- examples/desktop/scatter/scatter_cmap_iris.py | 44 +++++++++++++++++++ .../desktop/scatter/scatter_colorslice.py | 2 +- .../scatter/scatter_colorslice_iris.py | 44 +++++++++++++++++++ .../desktop/scatter/scatter_dataslice_iris.py | 42 ++++++++++++++++++ 6 files changed, 133 insertions(+), 3 deletions(-) create mode 100644 examples/desktop/scatter/scatter_cmap_iris.py create mode 100644 examples/desktop/scatter/scatter_colorslice_iris.py create mode 100644 examples/desktop/scatter/scatter_dataslice_iris.py diff --git a/examples/desktop/scatter/scatter.py b/examples/desktop/scatter/scatter.py index e27426e65..05dd7a99b 100644 --- a/examples/desktop/scatter/scatter.py +++ b/examples/desktop/scatter/scatter.py @@ -5,7 +5,7 @@ Example showing scatter plot. """ -# test_example = true +# test_example = false # sphinx_gallery_pygfx_docs = 'screenshot' import fastplotlib as fpl diff --git a/examples/desktop/scatter/scatter_cmap.py b/examples/desktop/scatter/scatter_cmap.py index be909981f..0adf72509 100644 --- a/examples/desktop/scatter/scatter_cmap.py +++ b/examples/desktop/scatter/scatter_cmap.py @@ -5,7 +5,7 @@ Example showing cmap change for scatter plot. """ -# test_example = true +# test_example = false # sphinx_gallery_pygfx_docs = 'screenshot' import fastplotlib as fpl diff --git a/examples/desktop/scatter/scatter_cmap_iris.py b/examples/desktop/scatter/scatter_cmap_iris.py new file mode 100644 index 000000000..cc9093f4f --- /dev/null +++ b/examples/desktop/scatter/scatter_cmap_iris.py @@ -0,0 +1,44 @@ +""" +Iris Scatter Colormap +===================== + +Example showing cmap change for scatter plot. +""" + +# test_example = true +# sphinx_gallery_pygfx_docs = 'hidden' + +import fastplotlib as fpl +import numpy as np +from pathlib import Path +from sklearn.cluster import AgglomerativeClustering + + +figure = fpl.Figure() + +data_path = Path(__file__).parent.parent.joinpath("data", "iris.npy") +data = np.load(data_path) + +agg = AgglomerativeClustering(n_clusters=3) +agg.fit_predict(data) + +scatter_graphic = figure[0, 0].add_scatter( + data=data[:, :-1], # use only xy data + sizes=15, + alpha=0.7, + cmap="Set1", + cmap_transform=agg.labels_ # use the labels as a transform to map colors from the colormap +) + +figure.show() + +figure.canvas.set_logical_size(800, 800) + +figure[0, 0].auto_scale() + +scatter_graphic.cmap = "tab10" + + +if __name__ == "__main__": + print(__doc__) + fpl.run() diff --git a/examples/desktop/scatter/scatter_colorslice.py b/examples/desktop/scatter/scatter_colorslice.py index f796f1f49..3d3a3fa26 100644 --- a/examples/desktop/scatter/scatter_colorslice.py +++ b/examples/desktop/scatter/scatter_colorslice.py @@ -5,7 +5,7 @@ Example showing color slice for scatter plot. """ -# test_example = true +# test_example = false # sphinx_gallery_pygfx_docs = 'screenshot' import fastplotlib as fpl diff --git a/examples/desktop/scatter/scatter_colorslice_iris.py b/examples/desktop/scatter/scatter_colorslice_iris.py new file mode 100644 index 000000000..15b8b647e --- /dev/null +++ b/examples/desktop/scatter/scatter_colorslice_iris.py @@ -0,0 +1,44 @@ +""" +Iris Scatter Plot Color Slicing +=============================== + +Example showing color slice for scatter plot. +""" + +# test_example = true +# sphinx_gallery_pygfx_docs = 'hidden' + +import fastplotlib as fpl +import numpy as np +from pathlib import Path + + +figure = fpl.Figure() + +data_path = Path(__file__).parent.parent.joinpath("data", "iris.npy") +data = np.load(data_path) + +n_points = 50 +colors = ["yellow"] * n_points + ["cyan"] * n_points + ["magenta"] * n_points + +scatter_graphic = figure[0, 0].add_scatter( + data=data[:, :-1], + sizes=6, + alpha=0.7, + colors=colors # use colors from the list of strings +) + +figure.show() + +figure.canvas.set_logical_size(800, 800) + +figure[0, 0].auto_scale() + +scatter_graphic.colors[0:75] = "red" +scatter_graphic.colors[75:150] = "white" +scatter_graphic.colors[::2] = "blue" + + +if __name__ == "__main__": + print(__doc__) + fpl.run() diff --git a/examples/desktop/scatter/scatter_dataslice_iris.py b/examples/desktop/scatter/scatter_dataslice_iris.py new file mode 100644 index 000000000..087d1a4c4 --- /dev/null +++ b/examples/desktop/scatter/scatter_dataslice_iris.py @@ -0,0 +1,42 @@ +""" +Iris Scatter Plot Data Slicing +============================== + +Example showing data slice for scatter plot. +""" + +# test_example = true +# sphinx_gallery_pygfx_docs = 'hidden' + +import fastplotlib as fpl +import numpy as np +from pathlib import Path + + +figure = fpl.Figure() + +data_path = Path(__file__).parent.parent.joinpath("data", "iris.npy") +data = np.load(data_path) + +n_points = 50 +colors = ["yellow"] * n_points + ["cyan"] * n_points + ["magenta"] * n_points + +scatter_graphic = figure[0, 0].add_scatter(data=data[:, :-1], sizes=6, alpha=0.7, colors=colors) + +figure.show() + +figure.canvas.set_logical_size(800, 800) + +figure[0, 0].auto_scale() + +scatter_graphic.data[0] = np.array([[5, 3, 1.5]]) +scatter_graphic.data[1] = np.array([[4.3, 3.2, 1.3]]) +scatter_graphic.data[2] = np.array([[5.2, 2.7, 1.7]]) + +scatter_graphic.data[10:15] = scatter_graphic.data[0:5] + np.array([1, 1, 1]) +scatter_graphic.data[50:100:2] = scatter_graphic.data[100:150:2] + np.array([1, 1, 0]) + + +if __name__ == "__main__": + print(__doc__) + fpl.run() From 64aaca7f4617c3dc54c4e7dccd9446eec1de4dd0 Mon Sep 17 00:00:00 2001 From: Caitlin Date: Tue, 18 Jun 2024 11:10:12 -0400 Subject: [PATCH 29/32] fix screenshots --- examples/desktop/screenshots/multigraphic_gridplot.png | 4 ++-- examples/desktop/screenshots/scatter_cmap_iris.png | 3 +++ examples/desktop/screenshots/scatter_colorslice_iris.png | 3 +++ examples/desktop/screenshots/scatter_dataslice_iris.png | 3 +++ 4 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 examples/desktop/screenshots/scatter_cmap_iris.png create mode 100644 examples/desktop/screenshots/scatter_colorslice_iris.png create mode 100644 examples/desktop/screenshots/scatter_dataslice_iris.png diff --git a/examples/desktop/screenshots/multigraphic_gridplot.png b/examples/desktop/screenshots/multigraphic_gridplot.png index 5a8f3be99..9528e4e71 100644 --- a/examples/desktop/screenshots/multigraphic_gridplot.png +++ b/examples/desktop/screenshots/multigraphic_gridplot.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a19f917efe95db66ea2f600e50428f476952cdb22d7e23306facfe0e421d04a2 -size 163713 +oid sha256:0b0b7f99f2d59fce96a580132e254409e493fbd351a19bb1f44cff2f1fe5664e +size 163774 diff --git a/examples/desktop/screenshots/scatter_cmap_iris.png b/examples/desktop/screenshots/scatter_cmap_iris.png new file mode 100644 index 000000000..9a5aeb8b9 --- /dev/null +++ b/examples/desktop/screenshots/scatter_cmap_iris.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:58bc2319d1e7b90c8dfa72c53bb940e8afca00899ead14fab720384ee022496f +size 32895 diff --git a/examples/desktop/screenshots/scatter_colorslice_iris.png b/examples/desktop/screenshots/scatter_colorslice_iris.png new file mode 100644 index 000000000..b567aa492 --- /dev/null +++ b/examples/desktop/screenshots/scatter_colorslice_iris.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d94311986eb4973cc12dffa1a0fee6ed0e8184ef7208804feb1d20f502047895 +size 14708 diff --git a/examples/desktop/screenshots/scatter_dataslice_iris.png b/examples/desktop/screenshots/scatter_dataslice_iris.png new file mode 100644 index 000000000..052c921f9 --- /dev/null +++ b/examples/desktop/screenshots/scatter_dataslice_iris.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:58e34c62360f5bdb77994ad060fe73c05267278f507291b092d67a45486a1e65 +size 15633 From 27c90aaf1820c804bacb8efa16bfa67ce83e476d Mon Sep 17 00:00:00 2001 From: Caitlin Date: Tue, 18 Jun 2024 16:18:28 -0400 Subject: [PATCH 30/32] add sklearn as docs dependency, include iris scatter examples in gallery --- examples/desktop/scatter/scatter_cmap_iris.py | 10 ++++------ examples/desktop/scatter/scatter_colorslice_iris.py | 10 ++++------ examples/desktop/scatter/scatter_dataslice_iris.py | 9 ++++----- setup.py | 1 + 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/examples/desktop/scatter/scatter_cmap_iris.py b/examples/desktop/scatter/scatter_cmap_iris.py index cc9093f4f..700f5c136 100644 --- a/examples/desktop/scatter/scatter_cmap_iris.py +++ b/examples/desktop/scatter/scatter_cmap_iris.py @@ -6,18 +6,16 @@ """ # test_example = true -# sphinx_gallery_pygfx_docs = 'hidden' +# sphinx_gallery_pygfx_docs = 'screenshot' import fastplotlib as fpl -import numpy as np -from pathlib import Path from sklearn.cluster import AgglomerativeClustering +from sklearn import datasets figure = fpl.Figure() -data_path = Path(__file__).parent.parent.joinpath("data", "iris.npy") -data = np.load(data_path) +data = datasets.load_iris()["data"] agg = AgglomerativeClustering(n_clusters=3) agg.fit_predict(data) @@ -32,7 +30,7 @@ figure.show() -figure.canvas.set_logical_size(800, 800) +figure.canvas.set_logical_size(700, 560) figure[0, 0].auto_scale() diff --git a/examples/desktop/scatter/scatter_colorslice_iris.py b/examples/desktop/scatter/scatter_colorslice_iris.py index 15b8b647e..a1e6d5318 100644 --- a/examples/desktop/scatter/scatter_colorslice_iris.py +++ b/examples/desktop/scatter/scatter_colorslice_iris.py @@ -6,17 +6,15 @@ """ # test_example = true -# sphinx_gallery_pygfx_docs = 'hidden' +# sphinx_gallery_pygfx_docs = 'screenshot' import fastplotlib as fpl -import numpy as np -from pathlib import Path +from sklearn import datasets figure = fpl.Figure() -data_path = Path(__file__).parent.parent.joinpath("data", "iris.npy") -data = np.load(data_path) +data = datasets.load_iris()["data"] n_points = 50 colors = ["yellow"] * n_points + ["cyan"] * n_points + ["magenta"] * n_points @@ -30,7 +28,7 @@ figure.show() -figure.canvas.set_logical_size(800, 800) +figure.canvas.set_logical_size(700, 560) figure[0, 0].auto_scale() diff --git a/examples/desktop/scatter/scatter_dataslice_iris.py b/examples/desktop/scatter/scatter_dataslice_iris.py index 087d1a4c4..0d47c6efd 100644 --- a/examples/desktop/scatter/scatter_dataslice_iris.py +++ b/examples/desktop/scatter/scatter_dataslice_iris.py @@ -6,17 +6,16 @@ """ # test_example = true -# sphinx_gallery_pygfx_docs = 'hidden' +# sphinx_gallery_pygfx_docs = 'screenshot' import fastplotlib as fpl import numpy as np -from pathlib import Path +from sklearn import datasets figure = fpl.Figure() -data_path = Path(__file__).parent.parent.joinpath("data", "iris.npy") -data = np.load(data_path) +data = datasets.load_iris()["data"] n_points = 50 colors = ["yellow"] * n_points + ["cyan"] * n_points + ["magenta"] * n_points @@ -25,7 +24,7 @@ figure.show() -figure.canvas.set_logical_size(800, 800) +figure.canvas.set_logical_size(700, 560) figure[0, 0].auto_scale() diff --git a/setup.py b/setup.py index 5ed907bfe..503af8f99 100644 --- a/setup.py +++ b/setup.py @@ -24,6 +24,7 @@ "sidecar", "imageio", "matplotlib", + "scikit-learn" ], "notebook": [ "jupyterlab", From ee2d8f102a6165436502049743d9f16fe487ec0f Mon Sep 17 00:00:00 2001 From: Caitlin Lewis <69729525+clewis7@users.noreply.github.com> Date: Tue, 18 Jun 2024 16:19:39 -0400 Subject: [PATCH 31/32] Update examples/desktop/misc/simple_event.py Co-authored-by: Kushal Kolar --- examples/desktop/misc/simple_event.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/desktop/misc/simple_event.py b/examples/desktop/misc/simple_event.py index cbe57fb48..b6d408862 100644 --- a/examples/desktop/misc/simple_event.py +++ b/examples/desktop/misc/simple_event.py @@ -34,7 +34,7 @@ def callback_func(event_data): image_graphic.cmap = "viridis" -# adding a click event +# adding a click event, we can also use decorators to add event handlers @image_graphic.add_event_handler("click") def click_event(event_data): # get the click location in screen coordinates From 0e199ea615f718951dde45e54c40e8b17081ef31 Mon Sep 17 00:00:00 2001 From: Caitlin Date: Tue, 18 Jun 2024 16:30:05 -0400 Subject: [PATCH 32/32] update screenshots --- examples/desktop/screenshots/multigraphic_gridplot.png | 4 ++-- examples/desktop/screenshots/scatter_cmap_iris.png | 4 ++-- examples/desktop/screenshots/scatter_colorslice_iris.png | 4 ++-- examples/desktop/screenshots/scatter_dataslice_iris.png | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/desktop/screenshots/multigraphic_gridplot.png b/examples/desktop/screenshots/multigraphic_gridplot.png index 9528e4e71..e814eadde 100644 --- a/examples/desktop/screenshots/multigraphic_gridplot.png +++ b/examples/desktop/screenshots/multigraphic_gridplot.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0b0b7f99f2d59fce96a580132e254409e493fbd351a19bb1f44cff2f1fe5664e -size 163774 +oid sha256:e879a39032759006685eff1d5c2331a66b9126b13bc148734c3622bd6cdc68a7 +size 163902 diff --git a/examples/desktop/screenshots/scatter_cmap_iris.png b/examples/desktop/screenshots/scatter_cmap_iris.png index 9a5aeb8b9..eb8802c0e 100644 --- a/examples/desktop/screenshots/scatter_cmap_iris.png +++ b/examples/desktop/screenshots/scatter_cmap_iris.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:58bc2319d1e7b90c8dfa72c53bb940e8afca00899ead14fab720384ee022496f -size 32895 +oid sha256:088579410d42768e68d7e7b298d2ed9e409eaff28ba5a2dd2ec8283e5994b862 +size 31599 diff --git a/examples/desktop/screenshots/scatter_colorslice_iris.png b/examples/desktop/screenshots/scatter_colorslice_iris.png index b567aa492..8692f53b3 100644 --- a/examples/desktop/screenshots/scatter_colorslice_iris.png +++ b/examples/desktop/screenshots/scatter_colorslice_iris.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d94311986eb4973cc12dffa1a0fee6ed0e8184ef7208804feb1d20f502047895 -size 14708 +oid sha256:f21ab8499384298a74db3e5fbb5aa0113f714d6f77e1e3d614da3d278a2c7a78 +size 13478 diff --git a/examples/desktop/screenshots/scatter_dataslice_iris.png b/examples/desktop/screenshots/scatter_dataslice_iris.png index 052c921f9..c0c6aa5e7 100644 --- a/examples/desktop/screenshots/scatter_dataslice_iris.png +++ b/examples/desktop/screenshots/scatter_dataslice_iris.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:58e34c62360f5bdb77994ad060fe73c05267278f507291b092d67a45486a1e65 -size 15633 +oid sha256:2032ce0b3c39f35e9dc37bc54fac016dc43aef716cfc65e6d65fd7fc977e74cf +size 14473 pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy