diff --git a/examples/notebooks/heatmap.ipynb b/examples/notebooks/heatmap.ipynb index d1c512661..82583b1df 100644 --- a/examples/notebooks/heatmap.ipynb +++ b/examples/notebooks/heatmap.ipynb @@ -20,9 +20,7 @@ "outputs": [], "source": [ "import numpy as np\n", - "import fastplotlib as fpl\n", - "\n", - "from tqdm import tqdm" + "import fastplotlib as fpl" ] }, { @@ -30,7 +28,7 @@ "id": "908f93f8-68c3-4a36-8f40-e0aab560955d", "metadata": {}, "source": [ - "## Generate some random neural-like data" + "## Generate some sine and cosine data" ] }, { @@ -42,54 +40,31 @@ }, "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" + "xs = np.linspace(0, 50, 10_000)\n", + "\n", + "sine_data = np.sin(xs)\n", + "\n", + "cosine_data = np.cos(xs)\n", + "\n", + "data = np.vstack([(sine_data, cosine_data) for i in range(5)])" ] }, { "cell_type": "code", "execution_count": null, - "id": "8a1b83f6-c0d8-4237-abd6-b483e7d978ee", + "id": "02b072eb-2909-40c8-8739-950f07efbbc2", "metadata": { "tags": [] }, "outputs": [], "source": [ - "temporal = generate_traces(10_000, 30_000)" + "data.shape" ] }, { "cell_type": "code", "execution_count": null, - "id": "f89bd740-7397-43e7-9e66-d6cfb14de884", + "id": "84deb31b-5464-4cce-a938-694371011021", "metadata": { "tags": [] }, @@ -97,7 +72,7 @@ "source": [ "plot = fpl.Plot()\n", "\n", - "plot.add_heatmap(temporal, cmap=\"viridis\")\n", + "plot.add_heatmap(data, cmap=\"viridis\")\n", "\n", "plot.show(maintain_aspect=False)" ] @@ -105,7 +80,7 @@ { "cell_type": "code", "execution_count": null, - "id": "84deb31b-5464-4cce-a938-694371011021", + "id": "df3f8994-0f5b-4578-a36d-4cd9bf0733c0", "metadata": {}, "outputs": [], "source": [] diff --git a/fastplotlib/graphics/image.py b/fastplotlib/graphics/image.py index 2ddf5b4cf..cb44e2ff2 100644 --- a/fastplotlib/graphics/image.py +++ b/fastplotlib/graphics/image.py @@ -500,8 +500,8 @@ def __init__( img.row_chunk_index = chunk[0] img.col_chunk_index = chunk[1] - img.position_x = x_pos - img.position_y = y_pos + img.world.x = x_pos + img.world.y = y_pos self.world_object.add(img)