Thanks to visit codestin.com
Credit goes to github.com

Skip to content

working on toolbar #195

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 14 commits into from
May 23, 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
278 changes: 278 additions & 0 deletions examples/buttons.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,278 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "6725ce7d-eea7-44f7-bedc-813e8ce5bf4f",
"metadata": {},
"outputs": [],
"source": [
"from fastplotlib import Plot\n",
"from ipywidgets import HBox, Checkbox, Image, VBox, Layout, ToggleButton, Button\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "33bf59c4-14e5-43a8-8a16-69b6859864c5",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "95be7ab3326347359f783946ec8d9339",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"RFBOutputContext()"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/clewis7/repos/fastplotlib/fastplotlib/graphics/features/_base.py:33: UserWarning: converting float64 array to float32\n",
" warn(f\"converting {array.dtype} array to float32\")\n"
]
},
{
"data": {
"text/plain": [
"<weakproxy at 0x7f125aa1ae00 to LineGraphic at 0x7f125aa50f10>"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot = Plot()\n",
"xs = np.linspace(-10, 10, 100)\n",
"# sine wave\n",
"ys = np.sin(xs)\n",
"sine = np.dstack([xs, ys])[0]\n",
"plot.add_line(sine)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "68ea8011-d6fd-448f-9bf6-34073164d271",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "cecbc6a1fec54d03876ac5a8609e5200",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(JupyterWgpuCanvas(), HBox(children=(Button(icon='expand-arrows-alt', layout=Layout(width='auto'…"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot.show()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "0bbb459c-cb49-448e-b0b8-c541e55da313",
"metadata": {},
"outputs": [],
"source": [
"from fastplotlib import GridPlot\n",
"from ipywidgets import Dropdown"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "91a31531-818b-46a2-9587-5d9ef5b59b93",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "05c6d9d2f62846e8ab6135a3d218964c",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"RFBOutputContext()"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"gp = GridPlot(\n",
" shape=(1,2),\n",
" names=[['plot1', 'plot2']])"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "e96bbda7-3693-42f2-bd52-f668f39134f6",
"metadata": {},
"outputs": [],
"source": [
"img = np.random.rand(512,512)\n",
"for subplot in gp:\n",
" subplot.add_image(data=img)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "03b877ba-cf9c-47d9-a0e5-b3e694274a28",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "9b792858ff24411db756810bb8eea00f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(JupyterWgpuCanvas(), HBox(children=(Button(icon='expand-arrows-alt', layout=Layout(width='auto'…"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"gp.show()"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "afc0cd52-fb24-4561-9876-50fbdf784502",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(0, 1)"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"gp[0,1].position"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "36f5e040-cc58-4b0a-beb1-1f66ea02ccb9",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "f902391ceb614f2a812725371184ce81",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"RFBOutputContext()"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"gp2 = GridPlot(shape=(1,2))"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "c6753d45-a0ae-4c96-8ed5-7638c4cf24e3",
"metadata": {},
"outputs": [],
"source": [
"for subplot in gp2:\n",
" subplot.add_image(data=img)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "5a769c0f-6d95-4969-ad9d-24636fc74b18",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "65a2a30036f44e22a479c6edd215e25a",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(JupyterWgpuCanvas(), HBox(children=(Button(icon='expand-arrows-alt', layout=Layout(width='auto'…"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"gp2.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "cd3e7b3c-f4d2-44c7-931c-d172c7bdad36",
"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.9.2"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading