From 5823047785ccdc9351d8e7b3c04ddcca12c68ec1 Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Mon, 26 Jun 2023 04:47:14 -0400 Subject: [PATCH 1/8] heatmap and lines cmap nb --- notebooks/heatmap.ipynb | 135 ++++++++++++++++++++++++++++ notebooks/lines_cmap.ipynb | 174 +++++++++++++++++++++++++++++++++++++ 2 files changed, 309 insertions(+) create mode 100644 notebooks/heatmap.ipynb create mode 100644 notebooks/lines_cmap.ipynb diff --git a/notebooks/heatmap.ipynb b/notebooks/heatmap.ipynb new file mode 100644 index 000000000..d1c512661 --- /dev/null +++ b/notebooks/heatmap.ipynb @@ -0,0 +1,135 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "d8c90f4b-b635-4027-b7d5-080d77bd40a3", + "metadata": {}, + "source": [ + "# The `HeatmapGraphic` is useful for looking at very large arrays\n", + "\n", + "`ImageGraphic` is limited to a max size of `8192 x 8192`" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "49b2498d-56ae-4559-9282-c8484f3e6b6d", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "import numpy as np\n", + "import fastplotlib as fpl\n", + "\n", + "from tqdm import tqdm" + ] + }, + { + "cell_type": "markdown", + "id": "908f93f8-68c3-4a36-8f40-e0aab560955d", + "metadata": {}, + "source": [ + "## Generate some random neural-like data" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "40718465-abf6-4727-8bd7-4acdd59843d5", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "def generate_traces(n_components, n_frames):\n", + " n_frames = n_frames + 50\n", + " n_components = n_components\n", + " \n", + " out = np.zeros((n_components, n_frames), dtype=np.float16)\n", + " \n", + " xs = np.arange(0, 50, 1)\n", + " # exponential decay\n", + " _lambda = 0.1\n", + " ys = np.e**-(_lambda * xs)\n", + " \n", + " for component_num in tqdm(range(n_components)):\n", + " time_step = 0\n", + " while time_step < n_frames - 50:\n", + " firing_prop = np.random.randint(0, 20)\n", + " if np.random.poisson() > firing_prop:\n", + " out[component_num, time_step:min(time_step + 50, n_frames - 1)] = ys.astype(np.float16)\n", + " time_step += 100\n", + " else:\n", + " time_step += 2\n", + " \n", + " return out[:, :n_frames - 50]" + ] + }, + { + "cell_type": "markdown", + "id": "fc1070d9-f9e9-405f-939c-a130cc5c456a", + "metadata": {}, + "source": [ + "Generate an array that is `10,000 x 30,000`, this may take a few minutes" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "8a1b83f6-c0d8-4237-abd6-b483e7d978ee", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "temporal = generate_traces(10_000, 30_000)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f89bd740-7397-43e7-9e66-d6cfb14de884", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "plot = fpl.Plot()\n", + "\n", + "plot.add_heatmap(temporal, cmap=\"viridis\")\n", + "\n", + "plot.show(maintain_aspect=False)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "84deb31b-5464-4cce-a938-694371011021", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "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.11.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/notebooks/lines_cmap.ipynb b/notebooks/lines_cmap.ipynb new file mode 100644 index 000000000..5eb783d77 --- /dev/null +++ b/notebooks/lines_cmap.ipynb @@ -0,0 +1,174 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "b169210c-b148-4701-91d2-87f8be2c90da", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "import numpy as np\n", + "import fastplotlib as fpl" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a6615d45-6a6e-4a1e-a998-18f7cc52f6b9", + "metadata": { + "tags": [] + }, + "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)\n", + "cosine = np.dstack([xs, ys])[0]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "52a91e8a-25b7-4121-a06f-623d7412b558", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "plot = fpl.Plot()\n", + "\n", + "plot.add_line(sine, thickness=10)\n", + "\n", + "plot.show()" + ] + }, + { + "cell_type": "markdown", + "id": "889b1858-ed64-4d6b-96ad-3883fbe4d38e", + "metadata": {}, + "source": [ + "# Fancy indexing of line colormaps" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "13185547-07bc-4771-ac6d-83314622bf30", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "plot.graphics[0].cmap = \"jet\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ee9ec4d7-d9a2-417c-92bd-b01a9a019801", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "plot.graphics[0].cmap.values = sine[:, 1]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ebf9f494-782d-4529-9ef6-a2a4032f097d", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "plot.graphics[0].cmap.values = cosine[:, 1]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5ddc95cf-b3be-4212-b525-1c628dc1e091", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "plot.graphics[0].cmap = \"viridis\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7712d313-16cd-49e5-89ca-91364412f194", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "cmap_values = [0] * 25 + [1] * 5 + [2] * 50 + [3] * 20" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c8c13c03-56f0-48c3-b44e-65545a3bc3bc", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "plot.graphics[0].cmap.values = cmap_values" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f64d036d-8a9e-4799-b77f-e78afa441fec", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "plot.graphics[0].cmap = \"tab10\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c290c642-ba5f-4a46-9a17-c434cb39de26", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "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.11.3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} From 96bff10309a20ae06844b2974f9cdf3752cd5012 Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Mon, 26 Jun 2023 04:53:23 -0400 Subject: [PATCH 2/8] update simple.ipynb --- notebooks/simple.ipynb | 92 +++++++++++++++++++++++++++++------------- 1 file changed, 65 insertions(+), 27 deletions(-) diff --git a/notebooks/simple.ipynb b/notebooks/simple.ipynb index 9ca764283..367a0126c 100644 --- a/notebooks/simple.ipynb +++ b/notebooks/simple.ipynb @@ -16,7 +16,9 @@ "cell_type": "code", "execution_count": null, "id": "fb57c3d3-f20d-4d88-9e7a-04b9309bc637", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "from fastplotlib import Plot\n", @@ -36,7 +38,9 @@ "cell_type": "code", "execution_count": null, "id": "237823b7-e2c0-4e2f-9ee8-e3fc2b4453c4", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# create a `Plot` instance\n", @@ -72,7 +76,9 @@ "cell_type": "code", "execution_count": null, "id": "de816c88-1c4a-4071-8a5e-c46c93671ef5", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "image_graphic.cmap = \"viridis\"" @@ -82,7 +88,9 @@ "cell_type": "code", "execution_count": null, "id": "09350854-5058-4574-a01d-84d00e276c57", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "image_graphic.data = 0" @@ -92,7 +100,9 @@ "cell_type": "code", "execution_count": null, "id": "83b2db1b-2783-4e89-bcf3-66bb6e09e18a", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "image_graphic.data[::15, :] = 1\n", @@ -103,7 +113,9 @@ "cell_type": "code", "execution_count": null, "id": "3e298c1c-7551-4401-ade0-b9af7d2bbe23", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "image_graphic.data = np.random.rand(512, 512)" @@ -121,7 +133,9 @@ "cell_type": "code", "execution_count": null, "id": "e6ba689c-ff4a-44ef-9663-f2c8755072c4", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "plot.graphics" @@ -131,7 +145,9 @@ "cell_type": "code", "execution_count": null, "id": "5b18f4e3-e13b-46d5-af1f-285c5a7fdc12", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "plot[\"random-image\"]" @@ -149,7 +165,9 @@ "cell_type": "code", "execution_count": null, "id": "2b5c1321-1fd4-44bc-9433-7439ad3e22cf", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "image_graphic" @@ -159,10 +177,12 @@ "cell_type": "code", "execution_count": null, "id": "b12bf75e-4e93-4930-9146-e96324fdf3f6", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ - "image_graphic is plot[\"random-image\"]" + "image_graphic == plot[\"random-image\"]" ] }, { @@ -181,7 +201,9 @@ "cell_type": "code", "execution_count": null, "id": "aadd757f-6379-4f52-a709-46aa57c56216", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# create another `Plot` instance\n", @@ -268,15 +290,6 @@ "VBox([plot_v.show(), plot_sync.show()])" ] }, - { - "cell_type": "markdown", - "id": "be53ca2c-1d97-4cbd-b88b-a414bf0bcc4a", - "metadata": {}, - "source": [ - "# Please note that `HBox` can be buggy and crash the kernel, avoid using it\n", - "### This is an upstream issue in `jupyter-rfb`" - ] - }, { "cell_type": "code", "execution_count": null, @@ -377,7 +390,7 @@ "id": "9ac18409-56d8-46cc-86bf-32456fcece48", "metadata": {}, "source": [ - "### The point is, we have a movie of the following shape, an image sequence" + "### Now we have a movie of the following shape, an image sequence" ] }, { @@ -422,10 +435,7 @@ "slider = IntSlider(min=0, max=movie.shape[0] - 1, step=1, value=0)\n", "\n", "# function to update movie_graphic\n", - "def update_movie(change):\n", - " global movie\n", - " global movie_graphic\n", - " \n", + "def update_movie(change): \n", " index = change[\"new\"]\n", " movie_graphic.data = movie[index]\n", " \n", @@ -529,7 +539,9 @@ "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!" + "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." ] }, { @@ -721,6 +733,32 @@ "sinc_graphic.present = True" ] }, + { + "cell_type": "markdown", + "id": "05f93e93-283b-45d8-ab31-8d15a7671dd2", + "metadata": {}, + "source": [ + "### You can set the z-positions of graphics to have them appear under 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", + "plot_l.add_image(img, name=\"image\", cmap=\"gray\")\n", + "\n", + "# z axix position -1 so it is below all the lines\n", + "plot_l[\"image\"].position_z = -1\n", + "plot_l[\"image\"].position_x = -50" + ] + }, { "cell_type": "markdown", "id": "2c90862e-2f2a-451f-a468-0cf6b857e87a", From b06fe6246f8d28d8b490d2ff518bb814dc722384 Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Mon, 26 Jun 2023 04:56:32 -0400 Subject: [PATCH 3/8] move nb examples --- .github/workflows/ci.yml | 2 +- {notebooks => examples/notebooks}/gridplot.ipynb | 0 {notebooks => examples/notebooks}/gridplot_simple.ipynb | 0 {notebooks => examples/notebooks}/heatmap.ipynb | 0 {notebooks => examples/notebooks}/image_widget.ipynb | 0 {notebooks => examples/notebooks}/linear_region_selector.ipynb | 0 {notebooks => examples/notebooks}/linear_selector.ipynb | 0 {notebooks => examples/notebooks}/lineplot.ipynb | 0 {notebooks => examples/notebooks}/lines_cmap.ipynb | 0 {notebooks => examples/notebooks}/scatter.ipynb | 0 {notebooks => examples/notebooks}/simple.ipynb | 0 11 files changed, 1 insertion(+), 1 deletion(-) rename {notebooks => examples/notebooks}/gridplot.ipynb (100%) rename {notebooks => examples/notebooks}/gridplot_simple.ipynb (100%) rename {notebooks => examples/notebooks}/heatmap.ipynb (100%) rename {notebooks => examples/notebooks}/image_widget.ipynb (100%) rename {notebooks => examples/notebooks}/linear_region_selector.ipynb (100%) rename {notebooks => examples/notebooks}/linear_selector.ipynb (100%) rename {notebooks => examples/notebooks}/lineplot.ipynb (100%) rename {notebooks => examples/notebooks}/lines_cmap.ipynb (100%) rename {notebooks => examples/notebooks}/scatter.ipynb (100%) rename {notebooks => examples/notebooks}/simple.ipynb (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b0ddb4baf..f50c1b05f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,7 +61,7 @@ jobs: PYGFX_EXPECT_LAVAPIPE: true run: | pytest -v examples - pytest --nbmake notebooks/ + pytest --nbmake examples/notebooks/ - uses: actions/upload-artifact@v3 if: ${{ failure() }} with: diff --git a/notebooks/gridplot.ipynb b/examples/notebooks/gridplot.ipynb similarity index 100% rename from notebooks/gridplot.ipynb rename to examples/notebooks/gridplot.ipynb diff --git a/notebooks/gridplot_simple.ipynb b/examples/notebooks/gridplot_simple.ipynb similarity index 100% rename from notebooks/gridplot_simple.ipynb rename to examples/notebooks/gridplot_simple.ipynb diff --git a/notebooks/heatmap.ipynb b/examples/notebooks/heatmap.ipynb similarity index 100% rename from notebooks/heatmap.ipynb rename to examples/notebooks/heatmap.ipynb diff --git a/notebooks/image_widget.ipynb b/examples/notebooks/image_widget.ipynb similarity index 100% rename from notebooks/image_widget.ipynb rename to examples/notebooks/image_widget.ipynb diff --git a/notebooks/linear_region_selector.ipynb b/examples/notebooks/linear_region_selector.ipynb similarity index 100% rename from notebooks/linear_region_selector.ipynb rename to examples/notebooks/linear_region_selector.ipynb diff --git a/notebooks/linear_selector.ipynb b/examples/notebooks/linear_selector.ipynb similarity index 100% rename from notebooks/linear_selector.ipynb rename to examples/notebooks/linear_selector.ipynb diff --git a/notebooks/lineplot.ipynb b/examples/notebooks/lineplot.ipynb similarity index 100% rename from notebooks/lineplot.ipynb rename to examples/notebooks/lineplot.ipynb diff --git a/notebooks/lines_cmap.ipynb b/examples/notebooks/lines_cmap.ipynb similarity index 100% rename from notebooks/lines_cmap.ipynb rename to examples/notebooks/lines_cmap.ipynb diff --git a/notebooks/scatter.ipynb b/examples/notebooks/scatter.ipynb similarity index 100% rename from notebooks/scatter.ipynb rename to examples/notebooks/scatter.ipynb diff --git a/notebooks/simple.ipynb b/examples/notebooks/simple.ipynb similarity index 100% rename from notebooks/simple.ipynb rename to examples/notebooks/simple.ipynb From 162af2667ff73f549e93f6a0bd3a3810fd22cdac Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Mon, 26 Jun 2023 05:19:33 -0400 Subject: [PATCH 4/8] simplify examples --- examples/image/image_cmap.py | 15 +++++---------- examples/image/image_rgb.py | 16 ++++++---------- examples/image/image_rgbvminvmax.py | 14 +++++--------- examples/image/image_simple.py | 15 +++++---------- examples/image/image_vminvmax.py | 15 +++++---------- examples/line/line.py | 8 +++++--- examples/line/line_cmap.py | 3 +++ examples/line/line_colorslice.py | 7 +++++-- examples/line/line_dataslice.py | 7 +++++-- examples/line/line_present_scaling.py | 8 +++++--- examples/line_collection/line_collection.py | 3 +++ .../line_collection_cmap_values.py | 3 +++ .../line_collection_cmap_values_qualitative.py | 3 +++ .../line_collection/line_collection_colors.py | 3 +++ examples/line_collection/line_stack.py | 3 +++ examples/scatter/scatter.py | 13 +++++-------- examples/scatter/scatter_cmap.py | 8 +++++--- examples/scatter/scatter_colorslice.py | 12 +++++------- examples/scatter/scatter_dataslice.py | 13 +++++-------- examples/scatter/scatter_present.py | 10 +++------- 20 files changed, 87 insertions(+), 92 deletions(-) diff --git a/examples/image/image_cmap.py b/examples/image/image_cmap.py index 3f061c9d4..9a9f0d497 100644 --- a/examples/image/image_cmap.py +++ b/examples/image/image_cmap.py @@ -5,17 +5,13 @@ """ # test_example = true -from fastplotlib import Plot -import numpy as np +import fastplotlib as fpl import imageio.v3 as iio -from wgpu.gui.offscreen import WgpuCanvas -from pygfx import WgpuRenderer -canvas = WgpuCanvas() -renderer = WgpuRenderer(canvas) - -plot = Plot(canvas=canvas, renderer=renderer) +plot = fpl.Plot() +# to force a specific framework such as glfw: +# plot = fpl.Plot(canvas="glfw") im = iio.imread("imageio:camera.png") @@ -30,7 +26,6 @@ image_graphic.cmap = "viridis" -img = np.asarray(plot.renderer.target.draw()) - if __name__ == "__main__": print(__doc__) + fpl.run() diff --git a/examples/image/image_rgb.py b/examples/image/image_rgb.py index fbd4cf24a..f73077acf 100644 --- a/examples/image/image_rgb.py +++ b/examples/image/image_rgb.py @@ -5,17 +5,13 @@ """ # test_example = true -from fastplotlib import Plot -import numpy as np +import fastplotlib as fpl import imageio.v3 as iio -from wgpu.gui.offscreen import WgpuCanvas -from pygfx import WgpuRenderer -canvas = WgpuCanvas() -renderer = WgpuRenderer(canvas) - -plot = Plot(canvas=canvas, renderer=renderer) +plot = fpl.Plot() +# to force a specific framework such as glfw: +# plot = fpl.Plot(canvas="glfw") im = iio.imread("imageio:astronaut.png") @@ -28,7 +24,7 @@ plot.auto_scale() -img = np.asarray(plot.renderer.target.draw()) if __name__ == "__main__": - print(__doc__) \ No newline at end of file + print(__doc__) + fpl.run() diff --git a/examples/image/image_rgbvminvmax.py b/examples/image/image_rgbvminvmax.py index f6b419b60..4891c5614 100644 --- a/examples/image/image_rgbvminvmax.py +++ b/examples/image/image_rgbvminvmax.py @@ -5,17 +5,13 @@ """ # test_example = true -from fastplotlib import Plot -import numpy as np +import fastplotlib as fpl import imageio.v3 as iio -from wgpu.gui.offscreen import WgpuCanvas -from pygfx import WgpuRenderer -canvas = WgpuCanvas() -renderer = WgpuRenderer(canvas) - -plot = Plot(canvas=canvas, renderer=renderer) +plot = fpl.Plot() +# to force a specific framework such as glfw: +# plot = fpl.Plot(canvas="glfw") im = iio.imread("imageio:astronaut.png") @@ -31,7 +27,7 @@ image_graphic.cmap.vmin = 0.5 image_graphic.cmap.vmax = 0.75 -img = np.asarray(plot.renderer.target.draw()) if __name__ == "__main__": print(__doc__) + fpl.run() diff --git a/examples/image/image_simple.py b/examples/image/image_simple.py index afe5a608e..2d273ad68 100644 --- a/examples/image/image_simple.py +++ b/examples/image/image_simple.py @@ -6,17 +6,13 @@ # test_example = true -from fastplotlib import Plot -import numpy as np +import fastplotlib as fpl import imageio.v3 as iio -from wgpu.gui.offscreen import WgpuCanvas -from pygfx import WgpuRenderer -canvas = WgpuCanvas() -renderer = WgpuRenderer(canvas) - -plot = Plot(canvas=canvas, renderer=renderer) +plot = fpl.Plot() +# to force a specific framework such as glfw: +# plot = fpl.Plot(canvas="glfw") data = iio.imread("imageio:camera.png") @@ -29,7 +25,6 @@ plot.auto_scale() -img = np.asarray(plot.renderer.target.draw()) - if __name__ == "__main__": print(__doc__) + fpl.run() diff --git a/examples/image/image_vminvmax.py b/examples/image/image_vminvmax.py index c2636bb17..ae5d102fa 100644 --- a/examples/image/image_vminvmax.py +++ b/examples/image/image_vminvmax.py @@ -5,18 +5,13 @@ """ # test_example = true -from fastplotlib import Plot -import numpy as np -from pathlib import Path +import fastplotlib as fpl import imageio.v3 as iio -from wgpu.gui.offscreen import WgpuCanvas -from pygfx import WgpuRenderer -canvas = WgpuCanvas() -renderer = WgpuRenderer(canvas) - -plot = Plot(canvas=canvas, renderer=renderer) +plot = fpl.Plot() +# to force a specific framework such as glfw: +# plot = fpl.Plot(canvas="glfw") data = iio.imread("imageio:astronaut.png") @@ -32,7 +27,7 @@ image_graphic.cmap.vmin = 0.5 image_graphic.cmap.vmax = 0.75 -img = np.asarray(plot.renderer.target.draw()) if __name__ == "__main__": print(__doc__) + fpl.run() diff --git a/examples/line/line.py b/examples/line/line.py index 45fc5eb5b..8cab1954f 100644 --- a/examples/line/line.py +++ b/examples/line/line.py @@ -6,11 +6,13 @@ # test_example = true -from fastplotlib import Plot +import fastplotlib as fpl import numpy as np -plot = Plot() +plot = fpl.Plot() +# to force a specific framework such as glfw: +# plot = fpl.Plot(canvas="glfw") xs = np.linspace(-10, 10, 100) # sine wave @@ -41,7 +43,7 @@ plot.auto_scale() -img = np.asarray(plot.renderer.target.draw()) if __name__ == "__main__": print(__doc__) + fpl.run() diff --git a/examples/line/line_cmap.py b/examples/line/line_cmap.py index f2fa29d79..b196132ed 100644 --- a/examples/line/line_cmap.py +++ b/examples/line/line_cmap.py @@ -11,6 +11,8 @@ plot = fpl.Plot() +# to force a specific framework such as glfw: +# plot = fpl.Plot(canvas="glfw") xs = np.linspace(-10, 10, 100) # sine wave @@ -43,4 +45,5 @@ plot.canvas.set_logical_size(800, 800) if __name__ == "__main__": + print(__doc__) fpl.run() diff --git a/examples/line/line_colorslice.py b/examples/line/line_colorslice.py index a82f43aa6..f757a7efe 100644 --- a/examples/line/line_colorslice.py +++ b/examples/line/line_colorslice.py @@ -6,11 +6,13 @@ # test_example = true -from fastplotlib import Plot +import fastplotlib as fpl import numpy as np -plot = Plot() +plot = fpl.Plot() +# to force a specific framework such as glfw: +# plot = fpl.Plot(canvas="glfw") xs = np.linspace(-10, 10, 100) # sine wave @@ -64,3 +66,4 @@ if __name__ == "__main__": print(__doc__) + fpl.run() diff --git a/examples/line/line_dataslice.py b/examples/line/line_dataslice.py index ddc670cd2..ef3cccfe8 100644 --- a/examples/line/line_dataslice.py +++ b/examples/line/line_dataslice.py @@ -6,11 +6,13 @@ # test_example = true -from fastplotlib import Plot +import fastplotlib as fpl import numpy as np -plot = Plot() +plot = fpl.Plot() +# to force a specific framework such as glfw: +# plot = fpl.Plot(canvas="glfw") xs = np.linspace(-10, 10, 100) # sine wave @@ -53,3 +55,4 @@ if __name__ == "__main__": print(__doc__) + fpl.run() diff --git a/examples/line/line_present_scaling.py b/examples/line/line_present_scaling.py index 9cf2706e1..b8e9be63c 100644 --- a/examples/line/line_present_scaling.py +++ b/examples/line/line_present_scaling.py @@ -6,11 +6,13 @@ # test_example = true -from fastplotlib import Plot +import fastplotlib as fpl import numpy as np -plot = Plot() +plot = fpl.Plot() +# to force a specific framework such as glfw: +# plot = fpl.Plot(canvas="glfw") xs = np.linspace(-10, 10, 100) # sine wave @@ -47,4 +49,4 @@ if __name__ == "__main__": print(__doc__) - + fpl.run() diff --git a/examples/line_collection/line_collection.py b/examples/line_collection/line_collection.py index 508aca190..071da2e2e 100644 --- a/examples/line_collection/line_collection.py +++ b/examples/line_collection/line_collection.py @@ -28,6 +28,8 @@ def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray: pos_xy = np.vstack(circles) plot = fpl.Plot() +# to force a specific framework such as glfw: +# plot = fpl.Plot(canvas="glfw") plot.add_line_collection(circles, cmap="jet", thickness=5) @@ -36,4 +38,5 @@ def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray: plot.canvas.set_logical_size(800, 800) if __name__ == "__main__": + print(__doc__) fpl.run() diff --git a/examples/line_collection/line_collection_cmap_values.py b/examples/line_collection/line_collection_cmap_values.py index 749d25b38..3623c20c3 100644 --- a/examples/line_collection/line_collection_cmap_values.py +++ b/examples/line_collection/line_collection_cmap_values.py @@ -34,6 +34,8 @@ def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray: cmap_values = [10] * 4 + [0] * 4 + [7] * 4 + [5] * 4 plot = fpl.Plot() +# to force a specific framework such as glfw: +# plot = fpl.Plot(canvas="glfw") plot.add_line_collection( circles, @@ -47,4 +49,5 @@ def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray: plot.canvas.set_logical_size(800, 800) if __name__ == "__main__": + print(__doc__) fpl.run() diff --git a/examples/line_collection/line_collection_cmap_values_qualitative.py b/examples/line_collection/line_collection_cmap_values_qualitative.py index f42c46ca3..f56d2ca02 100644 --- a/examples/line_collection/line_collection_cmap_values_qualitative.py +++ b/examples/line_collection/line_collection_cmap_values_qualitative.py @@ -40,6 +40,8 @@ def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray: ] plot = fpl.Plot() +# to force a specific framework such as glfw: +# plot = fpl.Plot(canvas="glfw") plot.add_line_collection( circles, @@ -53,4 +55,5 @@ def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray: plot.canvas.set_logical_size(800, 800) if __name__ == "__main__": + print(__doc__) fpl.run() diff --git a/examples/line_collection/line_collection_colors.py b/examples/line_collection/line_collection_colors.py index bb1a2c833..d74f65d82 100644 --- a/examples/line_collection/line_collection_colors.py +++ b/examples/line_collection/line_collection_colors.py @@ -32,6 +32,8 @@ def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray: colors = ["blue"] * 4 + ["red"] * 4 + ["yellow"] * 4 + ["w"] * 4 plot = fpl.Plot() +# to force a specific framework such as glfw: +# plot = fpl.Plot(canvas="glfw") plot.add_line_collection(circles, colors=colors, thickness=10) @@ -40,4 +42,5 @@ def make_circle(center, radius: float, n_points: int = 75) -> np.ndarray: plot.canvas.set_logical_size(800, 800) if __name__ == "__main__": + print(__doc__) fpl.run() diff --git a/examples/line_collection/line_stack.py b/examples/line_collection/line_stack.py index 282137c40..5a94caee7 100644 --- a/examples/line_collection/line_stack.py +++ b/examples/line_collection/line_stack.py @@ -18,6 +18,8 @@ data = np.vstack([ys] * 25) plot = fpl.Plot() +# to force a specific framework such as glfw: +# plot = fpl.Plot(canvas="glfw") # line stack takes all the same arguments as line collection and behaves similarly plot.add_line_stack(data, cmap="jet") @@ -27,4 +29,5 @@ plot.canvas.set_logical_size(900, 600) if __name__ == "__main__": + print(__doc__) fpl.run() diff --git a/examples/scatter/scatter.py b/examples/scatter/scatter.py index c866c4907..243924035 100644 --- a/examples/scatter/scatter.py +++ b/examples/scatter/scatter.py @@ -6,17 +6,13 @@ # test_example = true -from fastplotlib import Plot +import fastplotlib as fpl import numpy as np from pathlib import Path -from wgpu.gui.offscreen import WgpuCanvas -from pygfx import WgpuRenderer - -canvas = WgpuCanvas() -renderer = WgpuRenderer(canvas) - -plot = Plot(canvas=canvas, renderer=renderer) +plot = fpl.Plot() +# to force a specific framework such as glfw: +# plot = fpl.Plot(canvas="glfw") data_path = Path(__file__).parent.parent.joinpath("data", "iris.npy") data = np.load(data_path) @@ -36,3 +32,4 @@ if __name__ == "__main__": print(__doc__) + fpl.run() diff --git a/examples/scatter/scatter_cmap.py b/examples/scatter/scatter_cmap.py index b6ab5fb17..ae113537a 100644 --- a/examples/scatter/scatter_cmap.py +++ b/examples/scatter/scatter_cmap.py @@ -6,13 +6,15 @@ # test_example = true -from fastplotlib import Plot, run +import fastplotlib as fpl import numpy as np from pathlib import Path from sklearn.cluster import AgglomerativeClustering -plot = Plot() +plot = fpl.Plot() +# to force a specific framework such as glfw: +# plot = fpl.Plot(canvas="glfw") data_path = Path(__file__).parent.parent.joinpath("data", "iris.npy") data = np.load(data_path) @@ -43,4 +45,4 @@ if __name__ == "__main__": print(__doc__) - run() + fpl.run() diff --git a/examples/scatter/scatter_colorslice.py b/examples/scatter/scatter_colorslice.py index d3dd681a2..f5f32f5be 100644 --- a/examples/scatter/scatter_colorslice.py +++ b/examples/scatter/scatter_colorslice.py @@ -6,17 +6,14 @@ # test_example = true -from fastplotlib import Plot +import fastplotlib as fpl import numpy as np from pathlib import Path -from wgpu.gui.offscreen import WgpuCanvas -from pygfx import WgpuRenderer -canvas = WgpuCanvas() -renderer = WgpuRenderer(canvas) - -plot = Plot(canvas=canvas, renderer=renderer) +plot = fpl.Plot() +# to force a specific framework such as glfw: +# plot = fpl.Plot(canvas="glfw") data_path = Path(__file__).parent.parent.joinpath("data", "iris.npy") data = np.load(data_path) @@ -40,3 +37,4 @@ if __name__ == "__main__": print(__doc__) + fpl.run() diff --git a/examples/scatter/scatter_dataslice.py b/examples/scatter/scatter_dataslice.py index c522ca729..7b80d6c9e 100644 --- a/examples/scatter/scatter_dataslice.py +++ b/examples/scatter/scatter_dataslice.py @@ -6,17 +6,14 @@ # test_example = true -from fastplotlib import Plot +import fastplotlib as fpl import numpy as np from pathlib import Path -from wgpu.gui.offscreen import WgpuCanvas -from pygfx import WgpuRenderer -canvas = WgpuCanvas() -renderer = WgpuRenderer(canvas) - -plot = Plot(canvas=canvas, renderer=renderer) +plot = fpl.Plot() +# to force a specific framework such as glfw: +# plot = fpl.Plot(canvas="glfw") data_path = Path(__file__).parent.parent.joinpath("data", "iris.npy") data = np.load(data_path) @@ -43,4 +40,4 @@ if __name__ == "__main__": print(__doc__) - \ No newline at end of file + fpl.run() diff --git a/examples/scatter/scatter_present.py b/examples/scatter/scatter_present.py index 8770a1b92..fe0a3bf4f 100644 --- a/examples/scatter/scatter_present.py +++ b/examples/scatter/scatter_present.py @@ -6,17 +6,12 @@ # test_example = true -from fastplotlib import Plot +import fastplotlib as fpl import numpy as np from pathlib import Path -from wgpu.gui.offscreen import WgpuCanvas -from pygfx import WgpuRenderer -canvas = WgpuCanvas() -renderer = WgpuRenderer(canvas) - -plot = Plot(canvas=canvas, renderer=renderer) +plot = fpl.Plot() data_path = Path(__file__).parent.parent.joinpath("data", "iris.npy") data = np.load(data_path) @@ -41,3 +36,4 @@ if __name__ == "__main__": print(__doc__) + fpl.run() From 5e99dc04f5934f0d190c1e1333553ae913358c3b Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Mon, 26 Jun 2023 05:26:38 -0400 Subject: [PATCH 5/8] move test examples to desktop dir --- examples/README.md | 6 ------ examples/{ => desktop}/data/iris.npy | Bin examples/{ => desktop}/gridplot/__init__.py | 0 examples/{ => desktop}/gridplot/gridplot.py | 15 +++++---------- examples/{ => desktop}/image/__init__.py | 0 examples/{ => desktop}/image/image_cmap.py | 0 examples/{ => desktop}/image/image_rgb.py | 0 .../{ => desktop}/image/image_rgbvminvmax.py | 0 examples/{ => desktop}/image/image_simple.py | 0 examples/{ => desktop}/image/image_vminvmax.py | 0 examples/{ => desktop}/line/__init__.py | 0 examples/{ => desktop}/line/line.py | 0 examples/{ => desktop}/line/line_cmap.py | 0 examples/{ => desktop}/line/line_colorslice.py | 0 examples/{ => desktop}/line/line_dataslice.py | 0 .../{ => desktop}/line/line_present_scaling.py | 0 .../{ => desktop}/line_collection/__init__.py | 0 .../line_collection/line_collection.py | 0 .../line_collection_cmap_values.py | 0 .../line_collection_cmap_values_qualitative.py | 0 .../line_collection/line_collection_colors.py | 0 .../{ => desktop}/line_collection/line_stack.py | 0 examples/{ => desktop}/scatter/__init__.py | 0 examples/{ => desktop}/scatter/scatter.py | 0 examples/{ => desktop}/scatter/scatter_cmap.py | 0 .../{ => desktop}/scatter/scatter_colorslice.py | 0 .../{ => desktop}/scatter/scatter_dataslice.py | 0 .../{ => desktop}/scatter/scatter_present.py | 0 examples/{ => desktop}/screenshots/gridplot.png | 0 .../{ => desktop}/screenshots/image_cmap.png | 0 examples/{ => desktop}/screenshots/image_rgb.png | 0 .../screenshots/image_rgbvminvmax.png | 0 .../{ => desktop}/screenshots/image_simple.png | 0 .../{ => desktop}/screenshots/image_vminvmax.png | 0 examples/{ => desktop}/screenshots/line.png | 0 examples/{ => desktop}/screenshots/line_cmap.png | 0 .../screenshots/line_collection.png | 0 .../screenshots/line_collection_cmap_values.png | 0 .../line_collection_cmap_values_qualitative.png | 0 .../screenshots/line_collection_colors.png | 0 .../screenshots/line_colorslice.png | 0 .../{ => desktop}/screenshots/line_dataslice.png | 0 .../screenshots/line_present_scaling.png | 0 .../{ => desktop}/screenshots/line_stack.png | 0 examples/{ => desktop}/screenshots/scatter.png | 0 .../{ => desktop}/screenshots/scatter_cmap.png | 0 .../screenshots/scatter_colorslice.png | 0 .../screenshots/scatter_dataslice.png | 0 .../screenshots/scatter_present.png | 0 examples/tests/testutils.py | 2 +- 50 files changed, 6 insertions(+), 17 deletions(-) delete mode 100644 examples/README.md rename examples/{ => desktop}/data/iris.npy (100%) rename examples/{ => desktop}/gridplot/__init__.py (100%) rename examples/{ => desktop}/gridplot/gridplot.py (67%) rename examples/{ => desktop}/image/__init__.py (100%) rename examples/{ => desktop}/image/image_cmap.py (100%) rename examples/{ => desktop}/image/image_rgb.py (100%) rename examples/{ => desktop}/image/image_rgbvminvmax.py (100%) rename examples/{ => desktop}/image/image_simple.py (100%) rename examples/{ => desktop}/image/image_vminvmax.py (100%) rename examples/{ => desktop}/line/__init__.py (100%) rename examples/{ => desktop}/line/line.py (100%) rename examples/{ => desktop}/line/line_cmap.py (100%) rename examples/{ => desktop}/line/line_colorslice.py (100%) rename examples/{ => desktop}/line/line_dataslice.py (100%) rename examples/{ => desktop}/line/line_present_scaling.py (100%) rename examples/{ => desktop}/line_collection/__init__.py (100%) rename examples/{ => desktop}/line_collection/line_collection.py (100%) rename examples/{ => desktop}/line_collection/line_collection_cmap_values.py (100%) rename examples/{ => desktop}/line_collection/line_collection_cmap_values_qualitative.py (100%) rename examples/{ => desktop}/line_collection/line_collection_colors.py (100%) rename examples/{ => desktop}/line_collection/line_stack.py (100%) rename examples/{ => desktop}/scatter/__init__.py (100%) rename examples/{ => desktop}/scatter/scatter.py (100%) rename examples/{ => desktop}/scatter/scatter_cmap.py (100%) rename examples/{ => desktop}/scatter/scatter_colorslice.py (100%) rename examples/{ => desktop}/scatter/scatter_dataslice.py (100%) rename examples/{ => desktop}/scatter/scatter_present.py (100%) rename examples/{ => desktop}/screenshots/gridplot.png (100%) rename examples/{ => desktop}/screenshots/image_cmap.png (100%) rename examples/{ => desktop}/screenshots/image_rgb.png (100%) rename examples/{ => desktop}/screenshots/image_rgbvminvmax.png (100%) rename examples/{ => desktop}/screenshots/image_simple.png (100%) rename examples/{ => desktop}/screenshots/image_vminvmax.png (100%) rename examples/{ => desktop}/screenshots/line.png (100%) rename examples/{ => desktop}/screenshots/line_cmap.png (100%) rename examples/{ => desktop}/screenshots/line_collection.png (100%) rename examples/{ => desktop}/screenshots/line_collection_cmap_values.png (100%) rename examples/{ => desktop}/screenshots/line_collection_cmap_values_qualitative.png (100%) rename examples/{ => desktop}/screenshots/line_collection_colors.png (100%) rename examples/{ => desktop}/screenshots/line_colorslice.png (100%) rename examples/{ => desktop}/screenshots/line_dataslice.png (100%) rename examples/{ => desktop}/screenshots/line_present_scaling.png (100%) rename examples/{ => desktop}/screenshots/line_stack.png (100%) rename examples/{ => desktop}/screenshots/scatter.png (100%) rename examples/{ => desktop}/screenshots/scatter_cmap.png (100%) rename examples/{ => desktop}/screenshots/scatter_colorslice.png (100%) rename examples/{ => desktop}/screenshots/scatter_dataslice.png (100%) rename examples/{ => desktop}/screenshots/scatter_present.png (100%) diff --git a/examples/README.md b/examples/README.md deleted file mode 100644 index 1b79c879b..000000000 --- a/examples/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# Examples - -**IMPORTANT NOTE: If you install `fastplotlib` and `pygfx` from `pypi`, i.e. `pip install pygfx`, you will need to use the examples from the following commit until `pygfx` publishes a new release to `pypi`: https://github.com/kushalkolar/fastplotlib/tree/f872155eb687b18e3cc9b3b720eb9e241a9f974c/examples . -The current examples will work if you installed `fastplotlib` and `pygfx` directly from github** - -Both `fastplotlib` and `pygfx` are rapidly evolving libraries, and we try to closely track `pygfx`. diff --git a/examples/data/iris.npy b/examples/desktop/data/iris.npy similarity index 100% rename from examples/data/iris.npy rename to examples/desktop/data/iris.npy diff --git a/examples/gridplot/__init__.py b/examples/desktop/gridplot/__init__.py similarity index 100% rename from examples/gridplot/__init__.py rename to examples/desktop/gridplot/__init__.py diff --git a/examples/gridplot/gridplot.py b/examples/desktop/gridplot/gridplot.py similarity index 67% rename from examples/gridplot/gridplot.py rename to examples/desktop/gridplot/gridplot.py index 211c671f7..3acf6a8ba 100644 --- a/examples/gridplot/gridplot.py +++ b/examples/desktop/gridplot/gridplot.py @@ -6,17 +6,13 @@ # test_example = true -from fastplotlib import GridPlot -import numpy as np +import fastplotlib as fpl import imageio.v3 as iio -from wgpu.gui.offscreen import WgpuCanvas -from pygfx import WgpuRenderer -canvas = WgpuCanvas() -renderer = WgpuRenderer(canvas) - -plot = GridPlot(shape=(2,2), canvas=canvas, renderer=renderer) +plot = fpl.GridPlot(shape=(2, 2)) +# to force a specific framework such as glfw: +# plot = fpl.GridPlot(canvas="glfw") im = iio.imread("imageio:clock.png") im2 = iio.imread("imageio:astronaut.png") @@ -35,7 +31,6 @@ for subplot in plot: subplot.auto_scale() -img = np.asarray(plot.renderer.target.draw()) - if __name__ == "__main__": print(__doc__) + fpl.run() diff --git a/examples/image/__init__.py b/examples/desktop/image/__init__.py similarity index 100% rename from examples/image/__init__.py rename to examples/desktop/image/__init__.py diff --git a/examples/image/image_cmap.py b/examples/desktop/image/image_cmap.py similarity index 100% rename from examples/image/image_cmap.py rename to examples/desktop/image/image_cmap.py diff --git a/examples/image/image_rgb.py b/examples/desktop/image/image_rgb.py similarity index 100% rename from examples/image/image_rgb.py rename to examples/desktop/image/image_rgb.py diff --git a/examples/image/image_rgbvminvmax.py b/examples/desktop/image/image_rgbvminvmax.py similarity index 100% rename from examples/image/image_rgbvminvmax.py rename to examples/desktop/image/image_rgbvminvmax.py diff --git a/examples/image/image_simple.py b/examples/desktop/image/image_simple.py similarity index 100% rename from examples/image/image_simple.py rename to examples/desktop/image/image_simple.py diff --git a/examples/image/image_vminvmax.py b/examples/desktop/image/image_vminvmax.py similarity index 100% rename from examples/image/image_vminvmax.py rename to examples/desktop/image/image_vminvmax.py diff --git a/examples/line/__init__.py b/examples/desktop/line/__init__.py similarity index 100% rename from examples/line/__init__.py rename to examples/desktop/line/__init__.py diff --git a/examples/line/line.py b/examples/desktop/line/line.py similarity index 100% rename from examples/line/line.py rename to examples/desktop/line/line.py diff --git a/examples/line/line_cmap.py b/examples/desktop/line/line_cmap.py similarity index 100% rename from examples/line/line_cmap.py rename to examples/desktop/line/line_cmap.py diff --git a/examples/line/line_colorslice.py b/examples/desktop/line/line_colorslice.py similarity index 100% rename from examples/line/line_colorslice.py rename to examples/desktop/line/line_colorslice.py diff --git a/examples/line/line_dataslice.py b/examples/desktop/line/line_dataslice.py similarity index 100% rename from examples/line/line_dataslice.py rename to examples/desktop/line/line_dataslice.py diff --git a/examples/line/line_present_scaling.py b/examples/desktop/line/line_present_scaling.py similarity index 100% rename from examples/line/line_present_scaling.py rename to examples/desktop/line/line_present_scaling.py diff --git a/examples/line_collection/__init__.py b/examples/desktop/line_collection/__init__.py similarity index 100% rename from examples/line_collection/__init__.py rename to examples/desktop/line_collection/__init__.py diff --git a/examples/line_collection/line_collection.py b/examples/desktop/line_collection/line_collection.py similarity index 100% rename from examples/line_collection/line_collection.py rename to examples/desktop/line_collection/line_collection.py diff --git a/examples/line_collection/line_collection_cmap_values.py b/examples/desktop/line_collection/line_collection_cmap_values.py similarity index 100% rename from examples/line_collection/line_collection_cmap_values.py rename to examples/desktop/line_collection/line_collection_cmap_values.py diff --git a/examples/line_collection/line_collection_cmap_values_qualitative.py b/examples/desktop/line_collection/line_collection_cmap_values_qualitative.py similarity index 100% rename from examples/line_collection/line_collection_cmap_values_qualitative.py rename to examples/desktop/line_collection/line_collection_cmap_values_qualitative.py diff --git a/examples/line_collection/line_collection_colors.py b/examples/desktop/line_collection/line_collection_colors.py similarity index 100% rename from examples/line_collection/line_collection_colors.py rename to examples/desktop/line_collection/line_collection_colors.py diff --git a/examples/line_collection/line_stack.py b/examples/desktop/line_collection/line_stack.py similarity index 100% rename from examples/line_collection/line_stack.py rename to examples/desktop/line_collection/line_stack.py diff --git a/examples/scatter/__init__.py b/examples/desktop/scatter/__init__.py similarity index 100% rename from examples/scatter/__init__.py rename to examples/desktop/scatter/__init__.py diff --git a/examples/scatter/scatter.py b/examples/desktop/scatter/scatter.py similarity index 100% rename from examples/scatter/scatter.py rename to examples/desktop/scatter/scatter.py diff --git a/examples/scatter/scatter_cmap.py b/examples/desktop/scatter/scatter_cmap.py similarity index 100% rename from examples/scatter/scatter_cmap.py rename to examples/desktop/scatter/scatter_cmap.py diff --git a/examples/scatter/scatter_colorslice.py b/examples/desktop/scatter/scatter_colorslice.py similarity index 100% rename from examples/scatter/scatter_colorslice.py rename to examples/desktop/scatter/scatter_colorslice.py diff --git a/examples/scatter/scatter_dataslice.py b/examples/desktop/scatter/scatter_dataslice.py similarity index 100% rename from examples/scatter/scatter_dataslice.py rename to examples/desktop/scatter/scatter_dataslice.py diff --git a/examples/scatter/scatter_present.py b/examples/desktop/scatter/scatter_present.py similarity index 100% rename from examples/scatter/scatter_present.py rename to examples/desktop/scatter/scatter_present.py diff --git a/examples/screenshots/gridplot.png b/examples/desktop/screenshots/gridplot.png similarity index 100% rename from examples/screenshots/gridplot.png rename to examples/desktop/screenshots/gridplot.png diff --git a/examples/screenshots/image_cmap.png b/examples/desktop/screenshots/image_cmap.png similarity index 100% rename from examples/screenshots/image_cmap.png rename to examples/desktop/screenshots/image_cmap.png diff --git a/examples/screenshots/image_rgb.png b/examples/desktop/screenshots/image_rgb.png similarity index 100% rename from examples/screenshots/image_rgb.png rename to examples/desktop/screenshots/image_rgb.png diff --git a/examples/screenshots/image_rgbvminvmax.png b/examples/desktop/screenshots/image_rgbvminvmax.png similarity index 100% rename from examples/screenshots/image_rgbvminvmax.png rename to examples/desktop/screenshots/image_rgbvminvmax.png diff --git a/examples/screenshots/image_simple.png b/examples/desktop/screenshots/image_simple.png similarity index 100% rename from examples/screenshots/image_simple.png rename to examples/desktop/screenshots/image_simple.png diff --git a/examples/screenshots/image_vminvmax.png b/examples/desktop/screenshots/image_vminvmax.png similarity index 100% rename from examples/screenshots/image_vminvmax.png rename to examples/desktop/screenshots/image_vminvmax.png diff --git a/examples/screenshots/line.png b/examples/desktop/screenshots/line.png similarity index 100% rename from examples/screenshots/line.png rename to examples/desktop/screenshots/line.png diff --git a/examples/screenshots/line_cmap.png b/examples/desktop/screenshots/line_cmap.png similarity index 100% rename from examples/screenshots/line_cmap.png rename to examples/desktop/screenshots/line_cmap.png diff --git a/examples/screenshots/line_collection.png b/examples/desktop/screenshots/line_collection.png similarity index 100% rename from examples/screenshots/line_collection.png rename to examples/desktop/screenshots/line_collection.png diff --git a/examples/screenshots/line_collection_cmap_values.png b/examples/desktop/screenshots/line_collection_cmap_values.png similarity index 100% rename from examples/screenshots/line_collection_cmap_values.png rename to examples/desktop/screenshots/line_collection_cmap_values.png diff --git a/examples/screenshots/line_collection_cmap_values_qualitative.png b/examples/desktop/screenshots/line_collection_cmap_values_qualitative.png similarity index 100% rename from examples/screenshots/line_collection_cmap_values_qualitative.png rename to examples/desktop/screenshots/line_collection_cmap_values_qualitative.png diff --git a/examples/screenshots/line_collection_colors.png b/examples/desktop/screenshots/line_collection_colors.png similarity index 100% rename from examples/screenshots/line_collection_colors.png rename to examples/desktop/screenshots/line_collection_colors.png diff --git a/examples/screenshots/line_colorslice.png b/examples/desktop/screenshots/line_colorslice.png similarity index 100% rename from examples/screenshots/line_colorslice.png rename to examples/desktop/screenshots/line_colorslice.png diff --git a/examples/screenshots/line_dataslice.png b/examples/desktop/screenshots/line_dataslice.png similarity index 100% rename from examples/screenshots/line_dataslice.png rename to examples/desktop/screenshots/line_dataslice.png diff --git a/examples/screenshots/line_present_scaling.png b/examples/desktop/screenshots/line_present_scaling.png similarity index 100% rename from examples/screenshots/line_present_scaling.png rename to examples/desktop/screenshots/line_present_scaling.png diff --git a/examples/screenshots/line_stack.png b/examples/desktop/screenshots/line_stack.png similarity index 100% rename from examples/screenshots/line_stack.png rename to examples/desktop/screenshots/line_stack.png diff --git a/examples/screenshots/scatter.png b/examples/desktop/screenshots/scatter.png similarity index 100% rename from examples/screenshots/scatter.png rename to examples/desktop/screenshots/scatter.png diff --git a/examples/screenshots/scatter_cmap.png b/examples/desktop/screenshots/scatter_cmap.png similarity index 100% rename from examples/screenshots/scatter_cmap.png rename to examples/desktop/screenshots/scatter_cmap.png diff --git a/examples/screenshots/scatter_colorslice.png b/examples/desktop/screenshots/scatter_colorslice.png similarity index 100% rename from examples/screenshots/scatter_colorslice.png rename to examples/desktop/screenshots/scatter_colorslice.png diff --git a/examples/screenshots/scatter_dataslice.png b/examples/desktop/screenshots/scatter_dataslice.png similarity index 100% rename from examples/screenshots/scatter_dataslice.png rename to examples/desktop/screenshots/scatter_dataslice.png diff --git a/examples/screenshots/scatter_present.png b/examples/desktop/screenshots/scatter_present.png similarity index 100% rename from examples/screenshots/scatter_present.png rename to examples/desktop/screenshots/scatter_present.png diff --git a/examples/tests/testutils.py b/examples/tests/testutils.py index 7bc271e02..6155f8763 100644 --- a/examples/tests/testutils.py +++ b/examples/tests/testutils.py @@ -9,7 +9,7 @@ ROOT = Path(__file__).parents[2] # repo root -examples_dir = ROOT / "examples" +examples_dir = ROOT / "examples" / "desktop" screenshots_dir = examples_dir / "screenshots" diffs_dir = examples_dir / "diffs" From cd377165d4cdfd1065c96e7dcd73bc80c2f8729f Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Mon, 26 Jun 2023 05:26:50 -0400 Subject: [PATCH 6/8] update CI --- .github/workflows/ci.yml | 2 +- .github/workflows/screenshots.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f50c1b05f..582d02fe3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,4 +66,4 @@ jobs: if: ${{ failure() }} with: name: screenshot-diffs - path: examples/diffs + path: examples/desktop/diffs diff --git a/.github/workflows/screenshots.yml b/.github/workflows/screenshots.yml index 98d2ad86b..984d84aba 100644 --- a/.github/workflows/screenshots.yml +++ b/.github/workflows/screenshots.yml @@ -48,4 +48,4 @@ jobs: if: always() with: name: screenshots - path: examples/screenshots/ + path: examples/desktop/screenshots/ From 31f8a3caa47dbdbab67b4398635319142ce31e0f Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Mon, 26 Jun 2023 05:30:13 -0400 Subject: [PATCH 7/8] update README --- README.md | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 856df65d8..976ac1777 100644 --- a/README.md +++ b/README.md @@ -77,18 +77,26 @@ pip install -e ".[notebook,docs,tests]" > > `fastplotlib` and `pygfx` are fast evolving, you may require the latest `pygfx` and `fastplotlib` from github to use the examples in the master branch. -Clone or download the repo to try the examples +First clone or download the repo to try the examples ```bash -# clone the repo git clone https://github.com/kushalkolar/fastplotlib.git +``` + +### Desktop examples using `glfw` or `Qt` -# IMPORTANT: if you are using a specific version from pip, checkout that version to get the examples which work for that version -# example: -# git checkout git checkout v0.1.0.a9 # replace "v0.1.0.a9" with the version you have +```bash +# most dirs within examples contain example code +cd examples/desktop -# cd into notebooks and launch jupyter lab -cd fastplotlib/notebooks +# simplest example +python image/image_simple.py +``` + +### Notebook examples + +```bash +cd examples/notebooks jupyter lab ``` @@ -96,10 +104,10 @@ jupyter lab ### Simple image plot ```python -from fastplotlib import Plot +import fastplotlib as fpl import numpy as np -plot = Plot() +plot = fpl.Plot() data = np.random.rand(512, 512) plot.add_image(data=data) @@ -110,10 +118,10 @@ plot.show() ### Fast animations ```python -from fastplotlib import Plot +import fastplotlib as fpl import numpy as np -plot = Plot() +plot = fpl.Plot() data = np.random.rand(512, 512) image = plot.image(data=data) From a1c9dfc503bb63cd73c108bfe0f91befc0eb1c60 Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Mon, 26 Jun 2023 05:36:58 -0400 Subject: [PATCH 8/8] add tqdm to test requirements --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 1f4e5cb3a..c9d5d6936 100644 --- a/setup.py +++ b/setup.py @@ -31,6 +31,7 @@ "jupyterlab", "jupyter-rfb", "scikit-learn", + "tqdm" ] }