-
Notifications
You must be signed in to change notification settings - Fork 64
"DockedViewport" - Viewports adjacent to Subplot Viewport
#30
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
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2df9ee4
some basic ideas for sub_viewports
kushalkolar 75a1ab4
viewports within subplots working for right side
kushalkolar 0900bde
'docked viewports' within subplots now working well on all sides
kushalkolar 4662d3f
make viewport rect code more readable
kushalkolar 7630c97
fix merge conflicts
kushalkolar 021ef62
new PlotArea base class, subclassed by Subplot and DockedViewport, works
kushalkolar 6611a6c
bug fixes, cleanup, PlotArea repr and str, everything tested and work…
kushalkolar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import numpy as np | ||
| from wgpu.gui.auto import WgpuCanvas | ||
| import pygfx as gfx | ||
| from fastplotlib import GridPlot, Line, Scatter, Histogram | ||
| from fastplotlib import Image, GridPlot, run | ||
| from math import sin, cos, radians | ||
|
|
||
| # GridPlot of shape 2 x 3 | ||
| grid_plot = GridPlot(shape=(2, 3)) | ||
|
|
||
| image_graphics = list() | ||
|
|
||
| hist_data1 = np.random.normal(0, 256, 2048) | ||
| hist_data2 = np.random.poisson(0, 256) | ||
|
|
||
| # Make a random image graphic for each subplot | ||
| for i, subplot in enumerate(grid_plot): | ||
| img = np.random.rand(512, 512) * 255 | ||
| ig = Image(data=img, vmin=0, vmax=255, cmap='gnuplot2') | ||
| image_graphics.append(ig) | ||
|
|
||
| # add the graphic to the subplot | ||
| subplot.add_graphic(ig) | ||
|
|
||
| histogram = Histogram(data=hist_data1, bins=100) | ||
| histogram.world_object.rotation.w = cos(radians(45)) | ||
| histogram.world_object.rotation.z = sin(radians(45)) | ||
|
|
||
| histogram.world_object.scale.y = 1 | ||
| histogram.world_object.scale.x = 8 | ||
|
|
||
| for dv_position in ["right", "top", "bottom", "left"]: | ||
| h2 = Histogram(data=hist_data1, bins=100) | ||
|
|
||
| subplot.docked_viewports[dv_position].size = 60 | ||
| subplot.docked_viewports[dv_position].add_graphic(h2) | ||
| # | ||
|
|
||
| # Define a function to update the image graphics | ||
| # with new randomly generated data | ||
| def set_random_frame(): | ||
| for ig in image_graphics: | ||
| new_data = np.random.rand(512, 512) * 255 | ||
| ig.update_data(data=new_data) | ||
|
|
||
|
|
||
| # add the animation | ||
| grid_plot.add_animations([set_random_frame]) | ||
|
|
||
| grid_plot.show() | ||
|
|
||
| run() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.