Skip to content

fix heatmap tiling after linalg refactor #266

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 14 additions & 39 deletions examples/notebooks/heatmap.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,15 @@
"outputs": [],
"source": [
"import numpy as np\n",
"import fastplotlib as fpl\n",
"\n",
"from tqdm import tqdm"
"import fastplotlib as fpl"
]
},
{
"cell_type": "markdown",
"id": "908f93f8-68c3-4a36-8f40-e0aab560955d",
"metadata": {},
"source": [
"## Generate some random neural-like data"
"## Generate some sine and cosine data"
]
},
{
Expand All @@ -42,70 +40,47 @@
},
"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": []
},
"outputs": [],
"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)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "84deb31b-5464-4cce-a938-694371011021",
"id": "df3f8994-0f5b-4578-a36d-4cd9bf0733c0",
"metadata": {},
"outputs": [],
"source": []
Expand Down
4 changes: 2 additions & 2 deletions fastplotlib/graphics/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
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