Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Rectangle/bbox layouts in a Figure #740

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 82 commits into from
Mar 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
0802f34
start basic mesh and camera stuff
kushalkolar Feb 27, 2025
c26da10
progress
kushalkolar Feb 27, 2025
f199f65
resizing canvas auto-resizes bboxes using internal fractional bbox
kushalkolar Feb 28, 2025
f9b5c14
resizing works well
kushalkolar Feb 28, 2025
c1100b1
ranges as array, comments
kushalkolar Feb 28, 2025
d7f572e
layout management logic works! :D git status
kushalkolar Mar 1, 2025
e48c852
handler color, size
kushalkolar Mar 1, 2025
eedba34
cleanup
kushalkolar Mar 1, 2025
a39d383
resize handler highlight
kushalkolar Mar 2, 2025
685830b
subplot title works, rename to Frame
kushalkolar Mar 2, 2025
1329628
start generalizing layout manager
kushalkolar Mar 2, 2025
ce721bd
cleaner
kushalkolar Mar 2, 2025
4d6b395
start rect and extent class for organization
kushalkolar Mar 2, 2025
5e97818
start moving rect logic to a dedicated class
kushalkolar Mar 3, 2025
06ecc77
organization
kushalkolar Mar 5, 2025
69b02f3
better extent validation
kushalkolar Mar 5, 2025
66b78ae
progress
kushalkolar Mar 6, 2025
538edc2
progress
kushalkolar Mar 6, 2025
6763680
progress
kushalkolar Mar 6, 2025
194eef4
almost there
kushalkolar Mar 7, 2025
8990757
formatting, subplot toolbar tweaks
kushalkolar Mar 7, 2025
6e30b8b
cleanup
kushalkolar Mar 7, 2025
ad5b903
docks
kushalkolar Mar 8, 2025
500c05c
more stuff
kushalkolar Mar 8, 2025
3d16ce1
grid works
kushalkolar Mar 8, 2025
0989157
add or remove subplot, not tested
kushalkolar Mar 8, 2025
f19c294
better highlight behavior
kushalkolar Mar 8, 2025
09a7036
increase size of example fig
kushalkolar Mar 8, 2025
da66260
repr
kushalkolar Mar 8, 2025
13a4049
sdf for resize handle, better resize handle, overlap stuff with distance
kushalkolar Mar 8, 2025
8f52f50
cleanup
kushalkolar Mar 8, 2025
cf0fa1f
more space
kushalkolar Mar 8, 2025
8ad3086
spacing tweaks
kushalkolar Mar 8, 2025
88df692
add utils._types
kushalkolar Mar 8, 2025
f94e18a
unit circle using extents
kushalkolar Mar 8, 2025
cb3d3ba
black
kushalkolar Mar 8, 2025
528bb9d
refactor, better organization
kushalkolar Mar 9, 2025
4a20f34
modified: scripts/generate_add_graphic_methods.py
kushalkolar Mar 9, 2025
3c39b3a
more stuff
kushalkolar Mar 9, 2025
be56f34
more
kushalkolar Mar 9, 2025
7943000
add examples
kushalkolar Mar 9, 2025
d8b8921
black
kushalkolar Mar 9, 2025
14cd6b0
rename
kushalkolar Mar 9, 2025
e95eaa7
update test utils
kushalkolar Mar 9, 2025
2c91851
update nb test utils
kushalkolar Mar 9, 2025
cc005f3
update ground truths
kushalkolar Mar 9, 2025
6f57644
update nb ground truths
kushalkolar Mar 9, 2025
5fe5815
flex layouts examples 'as screenshot tests
kushalkolar Mar 9, 2025
2b70265
accidentaly added screenshot
kushalkolar Mar 9, 2025
4e9998a
comments, cleanup
kushalkolar Mar 10, 2025
dbe4368
docs api
kushalkolar Mar 10, 2025
f252e70
black
kushalkolar Mar 10, 2025
69d6b65
fix
kushalkolar Mar 10, 2025
4a053fe
cleanup
kushalkolar Mar 10, 2025
526e94e
add README.rst for flex layouts examples dir
kushalkolar Mar 10, 2025
c7656d4
add flex layouts to test utils list
kushalkolar Mar 10, 2025
e0e163b
add spinning spiral scatter example
kushalkolar Mar 10, 2025
354d109
modify docs conf
kushalkolar Mar 10, 2025
ac8341c
forgot a comma
kushalkolar Mar 10, 2025
b8ed276
add rect extent ground truths
kushalkolar Mar 10, 2025
bc48fe3
fix text
clewis7 Mar 10, 2025
e5f28e1
fix text features
clewis7 Mar 10, 2025
e76a77e
types
kushalkolar Mar 11, 2025
a26e24a
comments, docstrings
kushalkolar Mar 11, 2025
7aaeb0f
update w.r.t. text changes
kushalkolar Mar 11, 2025
8e0e27a
small typos
clewis7 Mar 13, 2025
1264ec6
small typos
clewis7 Mar 13, 2025
61ac3ff
Update fastplotlib/layouts/_engine.py
kushalkolar Mar 13, 2025
8b9a466
rename FlexLayout -> WindowLayout
kushalkolar Mar 14, 2025
996bbe7
better check for imgui
kushalkolar Mar 14, 2025
0bc9600
imports
kushalkolar Mar 14, 2025
0efd2b2
comments
kushalkolar Mar 14, 2025
302deb5
example tests files moved
kushalkolar Mar 14, 2025
db14148
smaller canvas initial size for abs pixels until rendercanvs fix for …
kushalkolar Mar 14, 2025
0976aa4
better error messages
kushalkolar Mar 14, 2025
6b318ee
update screenshots
kushalkolar Mar 14, 2025
5123f86
update screenshots
kushalkolar Mar 14, 2025
acff8cd
black
kushalkolar Mar 14, 2025
89ee960
newer black really was an extra comma for some reason
kushalkolar Mar 14, 2025
1b69eaa
update example
kushalkolar Mar 14, 2025
bc4b634
underline
kushalkolar Mar 14, 2025
f6263a3
docstring, better exception messages
kushalkolar Mar 14, 2025
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
5 changes: 3 additions & 2 deletions 5 docs/source/api/layouts/figure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,25 @@ Properties
Figure.cameras
Figure.canvas
Figure.controllers
Figure.mode
Figure.layout
Figure.names
Figure.renderer
Figure.shape
Figure.spacing

Methods
~~~~~~~
.. autosummary::
:toctree: Figure_api

Figure.add_animations
Figure.add_subplot
Figure.clear
Figure.close
Figure.export
Figure.export_numpy
Figure.get_pygfx_render_area
Figure.open_popup
Figure.remove_animation
Figure.remove_subplot
Figure.show

5 changes: 3 additions & 2 deletions 5 docs/source/api/layouts/imgui_figure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ Properties
ImguiFigure.controllers
ImguiFigure.guis
ImguiFigure.imgui_renderer
ImguiFigure.mode
ImguiFigure.layout
ImguiFigure.names
ImguiFigure.renderer
ImguiFigure.shape
ImguiFigure.spacing

Methods
~~~~~~~
Expand All @@ -38,6 +37,7 @@ Methods

ImguiFigure.add_animations
ImguiFigure.add_gui
ImguiFigure.add_subplot
ImguiFigure.clear
ImguiFigure.close
ImguiFigure.export
Expand All @@ -46,5 +46,6 @@ Methods
ImguiFigure.open_popup
ImguiFigure.register_popup
ImguiFigure.remove_animation
ImguiFigure.remove_subplot
ImguiFigure.show

4 changes: 2 additions & 2 deletions 4 docs/source/api/layouts/subplot.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Properties
Subplot.canvas
Subplot.controller
Subplot.docks
Subplot.frame
Subplot.graphics
Subplot.legends
Subplot.name
Expand All @@ -34,6 +35,7 @@ Properties
Subplot.renderer
Subplot.scene
Subplot.selectors
Subplot.title
Subplot.toolbar
Subplot.viewport

Expand All @@ -53,13 +55,11 @@ Methods
Subplot.auto_scale
Subplot.center_graphic
Subplot.center_scene
Subplot.center_title
Subplot.clear
Subplot.delete_graphic
Subplot.get_figure
Subplot.insert_graphic
Subplot.map_screen_to_world
Subplot.remove_animation
Subplot.remove_graphic
Subplot.set_title

1 change: 1 addition & 0 deletions 1 docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"../../examples/heatmap",
"../../examples/image_widget",
"../../examples/gridplot",
"../../examples/window_layouts",
"../../examples/line",
"../../examples/line_collection",
"../../examples/scatter",
Expand Down
2 changes: 1 addition & 1 deletion 2 examples/image_widget/image_widget_videos.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
[random_data, cockatoo_sub],
rgb=[False, True],
figure_shape=(2, 1), # 2 rows, 1 column
figure_kwargs={"size": (700, 560)}
figure_kwargs={"size": (700, 940)}
)

iw.show()
Expand Down
26 changes: 16 additions & 10 deletions 26 examples/machine_learning/kmeans.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
===================================

Example showing how you can perform K-Means clustering on the MNIST dataset.

Use WASD keys on your keyboard to fly through the data in PCA space.
Use the mouse pointer to select points.
"""

# test_example = false
Expand All @@ -29,17 +32,17 @@
# iterate through each subplot
for i, subplot in enumerate(fig_data):
# reshape each image to (8, 8)
subplot.add_image(data[i].reshape(8,8), cmap="gray", interpolation="linear")
subplot.add_image(data[i].reshape(8, 8), cmap="gray", interpolation="linear")
# add the label as a title
subplot.set_title(f"Label: {labels[i]}")
subplot.title = f"Label: {labels[i]}"
# turn off the axes and toolbar
subplot.axes.visible = False
subplot.toolbar = False
subplot.toolbar = False

fig_data.show()

# project the data from 64 dimensions down to the number of unique digits
n_digits = len(np.unique(labels)) # 10
n_digits = len(np.unique(labels)) # 10

reduced_data = PCA(n_components=n_digits).fit_transform(data) # (1797, 10)

Expand All @@ -53,17 +56,17 @@

# plot the kmeans result and corresponding original image
figure = fpl.Figure(
shape=(1,2),
size=(700, 400),
shape=(1, 2),
size=(700, 560),
cameras=["3d", "2d"],
controller_types=[["fly", "panzoom"]]
controller_types=["fly", "panzoom"]
)

# set the axes to False
figure[0, 0].axes.visible = False
# set the axes to False in the image subplot
figure[0, 1].axes.visible = False

figure[0, 0].set_title(f"K-means clustering of PCA-reduced data")
figure[0, 0].title = "k-means clustering of PCA-reduced data"
figure[0, 1].title = "handwritten digit"

# plot the centroids
figure[0, 0].add_scatter(
Expand Down Expand Up @@ -94,6 +97,7 @@
digit_scatter.colors[ix] = "magenta"
digit_scatter.sizes[ix] = 10


# define event handler to update the selected data point
@digit_scatter.add_event_handler("pointer_enter")
def update(ev):
Expand All @@ -110,8 +114,10 @@ def update(ev):
# update digit fig
figure[0, 1]["digit"].data = data[ix].reshape(8, 8)


figure.show()


# NOTE: `if __name__ == "__main__"` is NOT how to use fastplotlib interactively
# please see our docs for using fastplotlib interactively in ipython and jupyter
if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion 2 examples/notebooks/nb_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def plot_test(name, fig: fpl.Figure):
# hacky but it works for now
fig.imgui_renderer.render()

fig._set_viewport_rects()
fig._fpl_reset_layout()
# render each subplot
for subplot in fig:
subplot.viewport.render(subplot.scene, subplot.camera)
Expand Down
4 changes: 2 additions & 2 deletions 4 examples/notebooks/screenshots/nb-astronaut.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions 4 examples/notebooks/screenshots/nb-astronaut_RGB.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions 4 examples/notebooks/screenshots/nb-camera.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions 4 examples/notebooks/screenshots/nb-image-widget-single.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.