Skip to content

cameras and controllers refactor #382

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 17 commits into from
Nov 30, 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
46 changes: 4 additions & 42 deletions docs/source/quickstart.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,7 @@
"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!**\n",
"\n",
"By default the origin is on the bottom left, you can click the flip button to flip the y-axis, or use `plot.camera.world.scale_y *= -1`"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9b4e977e-2a7d-4e2b-aee4-cfc36767b3c6",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"plot.camera.world.scale_y *= -1"
"**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!**"
]
},
{
Expand Down Expand Up @@ -510,18 +496,6 @@
"plot_rgb.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7e4b5a30-4293-4ae3-87dc-06a1355bb2c7",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"plot_rgb.camera.world.scale_y *= -1"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -1361,7 +1335,7 @@
"outputs": [],
"source": [
"# GridPlot of shape 2 x 3 with all controllers synced\n",
"grid_plot = fpl.GridPlot(shape=(2, 3), controllers=\"sync\")\n",
"grid_plot = fpl.GridPlot(shape=(2, 3), controller_ids=\"sync\")\n",
"\n",
"# Make a random image graphic for each subplot\n",
"for subplot in grid_plot:\n",
Expand Down Expand Up @@ -1549,7 +1523,7 @@
"# pan-zoom controllers for each view\n",
"# views are synced if they have the \n",
"# same controller ID\n",
"controllers = [\n",
"controller_ids = [\n",
" [0, 3, 1], # id each controller with an integer\n",
" [2, 2, 3]\n",
"]\n",
Expand All @@ -1564,7 +1538,7 @@
"# Create the grid plot\n",
"grid_plot = fpl.GridPlot(\n",
" shape=grid_shape,\n",
" controllers=controllers,\n",
" controller_ids=controller_ids,\n",
" names=names,\n",
")\n",
"\n",
Expand Down Expand Up @@ -1678,18 +1652,6 @@
"grid_plot[1, 0][\"rand-image\"].vim = 0.1\n",
"grid_plot[1, 0][\"rand-image\"].vmax = 0.3"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8a5753b9-ee71-4ed1-bb0d-52bdb4ea365f",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"grid_plot[1, 0][\"rand-image\"].type"
]
}
],
"metadata": {
Expand Down
2 changes: 1 addition & 1 deletion examples/desktop/gridplot/gridplot_non_square.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import imageio.v3 as iio


plot = fpl.GridPlot(shape=(2, 2), controllers="sync")
plot = fpl.GridPlot(shape=(2, 2), controller_ids="sync")
# to force a specific framework such as glfw:
# plot = fpl.GridPlot(canvas="glfw")

Expand Down
14 changes: 2 additions & 12 deletions examples/desktop/scatter/scatter_size.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,7 @@
import fastplotlib as fpl

# grid with 2 rows and 3 columns
grid_shape = (2,1)

# pan-zoom controllers for each view
# views are synced if they have the
# same controller ID
controllers = [
[0],
[0]
]

grid_shape = (2, 1)

# you can give string names for each subplot within the gridplot
names = [
Expand All @@ -29,7 +20,6 @@
# Create the grid plot
plot = fpl.GridPlot(
shape=grid_shape,
controllers=controllers,
names=names,
size=(1000, 1000)
)
Expand All @@ -53,4 +43,4 @@

if __name__ == "__main__":
print(__doc__)
fpl.run()
fpl.run()
150 changes: 27 additions & 123 deletions examples/notebooks/gridplot.ipynb

Large diffs are not rendered by default.

142 changes: 37 additions & 105 deletions examples/notebooks/gridplot_simple.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "5171a06e-1bdc-4908-9726-3c1fd45dbb9d",
"metadata": {
"ExecuteTime": {
"end_time": "2023-11-26T04:01:19.120171Z",
"start_time": "2023-11-26T04:01:18.618087Z"
},
"tags": []
},
"outputs": [],
Expand All @@ -23,38 +27,19 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "86a2488f-ae1c-4b98-a7c0-18eae8013af1",
"metadata": {
"ExecuteTime": {
"end_time": "2023-11-26T04:01:19.467264Z",
"start_time": "2023-11-26T04:01:19.121813Z"
},
"tags": []
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "f9067cd724094b8c8dfecf60208acbfa",
"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:34: UserWarning: converting float64 array to float32\n",
" warn(f\"converting {array.dtype} array to float32\")\n"
]
}
],
"outputs": [],
"source": [
"# GridPlot of shape 2 x 3 with all controllers synced\n",
"grid_plot = GridPlot(shape=(2, 3), controllers=\"sync\")\n",
"grid_plot = GridPlot(shape=(2, 3), controller_ids=\"sync\")\n",
"\n",
"# Make a random image graphic for each subplot\n",
"for subplot in grid_plot:\n",
Expand Down Expand Up @@ -88,27 +73,22 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "52163bc7-2c77-4699-b7b0-e455a0ed7584",
"metadata": {},
"outputs": [],
"source": [
"grid_plot"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "17c6bc4a-5340-49f1-8597-f54528cfe915",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"text/plain": [
"unnamed: Subplot @ 0x7f15df4f5c50\n",
" parent: fastplotlib.GridPlot @ 0x7f15d3f27890\n",
"\n",
" Graphics:\n",
"\t'rand-img': ImageGraphic @ 0x7f15d3fb5390"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"# positional indexing\n",
"# row 0 and col 0\n",
Expand All @@ -125,23 +105,12 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"id": "34130f12-9ef6-43b0-b929-931de8b7da25",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"text/plain": [
"(<weakproxy at 0x7f15b83f1d00 to ImageGraphic at 0x7f15b83f5710>,)"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"grid_plot[0, 1].graphics"
]
Expand All @@ -156,7 +125,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": null,
"id": "ef8a29a6-b19c-4e6b-a2ba-fb4823c01451",
"metadata": {
"tags": []
Expand All @@ -176,7 +145,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"id": "d6c2fa4b-c634-4dcf-8b61-f1986f7c4918",
"metadata": {
"tags": []
Expand All @@ -189,74 +158,37 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"id": "2f6b549c-3165-496d-98aa-45b96c3de674",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"text/plain": [
"top-right-plot: Subplot @ 0x7f15d3f769d0\n",
" parent: fastplotlib.GridPlot @ 0x7f15d3f27890\n",
"\n",
" Graphics:\n",
"\t'rand-img': ImageGraphic @ 0x7f15b83f7250"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"grid_plot[\"top-right-plot\"]"
]
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": null,
"id": "be436e04-33a6-4597-8e6a-17e1e5225419",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"text/plain": [
"(0, 2)"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"# view its position\n",
"grid_plot[\"top-right-plot\"].position"
]
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": null,
"id": "6699cda6-af86-4258-87f5-1832f989a564",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"# these are really the same\n",
"grid_plot[\"top-right-plot\"] is grid_plot[0, 2]"
Expand All @@ -272,19 +204,19 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": null,
"id": "545b627b-d794-459a-a75a-3fde44f0ea95",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"grid_plot[\"top-right-plot\"][\"rand-img\"].vmin = 0.5"
"grid_plot[\"top-right-plot\"][\"rand-img\"].cmap.vmin = 0.5"
]
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": null,
"id": "36432d5b-b76c-4a2a-a32c-097faf5ab269",
"metadata": {
"tags": []
Expand Down
Loading
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