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

Skip to content

kwargs for Plot and GridPlot to set canvas star size #194

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 1 commit into from
May 17, 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
8 changes: 8 additions & 0 deletions fastplotlib/layouts/_gridplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def __init__(
controllers: Union[np.ndarray, str] = None,
canvas: WgpuCanvas = None,
renderer: pygfx.Renderer = None,
size: Tuple[int, int] = (500, 300),
**kwargs
):
"""
Expand Down Expand Up @@ -62,6 +63,9 @@ def __init__(
renderer: pygfx.Renderer, optional
pygfx renderer instance

size: (int, int)
starting size of canvas, default (500, 300)

"""
self.shape = shape

Expand Down Expand Up @@ -160,6 +164,8 @@ def __init__(

self._current_iter = None

self._starting_size = size

def __getitem__(self, index: Union[Tuple[int, int], str]):
if isinstance(index, str):
for subplot in self._subplots.ravel():
Expand Down Expand Up @@ -266,6 +272,8 @@ def show(self):
for subplot in self:
subplot.auto_scale(maintain_aspect=True, zoom=0.95)

self.canvas.set_logical_size(*self._starting_size)

return self.canvas

def _get_iterator(self):
Expand Down
8 changes: 8 additions & 0 deletions fastplotlib/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def __init__(
renderer: pygfx.Renderer = None,
camera: str = '2d',
controller: Union[pygfx.PanZoomController, pygfx.OrbitController] = None,
size: Tuple[int, int] = (500, 300),
**kwargs
):
"""
Expand All @@ -31,6 +32,9 @@ def __init__(
Usually ``None``, you can pass an existing controller from another
``Plot`` or ``Subplot`` within a ``GridPlot`` to synchronize them.

size: (int, int)
starting size of canvas, default (500, 300)

kwargs
passed to Subplot, for example ``name``

Expand Down Expand Up @@ -83,6 +87,8 @@ def __init__(
**kwargs
)

self._starting_size = size

def render(self):
super(Plot, self).render()

Expand All @@ -103,4 +109,6 @@ def show(self, autoscale: bool = True):
if autoscale:
self.auto_scale(maintain_aspect=True, zoom=0.95)

self.canvas.set_logical_size(*self._starting_size)

return self.canvas