diff --git a/fastplotlib/layouts/_gridplot.py b/fastplotlib/layouts/_gridplot.py index 3f694b007..ab79a3804 100644 --- a/fastplotlib/layouts/_gridplot.py +++ b/fastplotlib/layouts/_gridplot.py @@ -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 ): """ @@ -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 @@ -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(): @@ -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): diff --git a/fastplotlib/plot.py b/fastplotlib/plot.py index 97e19effd..96b1ac8dc 100644 --- a/fastplotlib/plot.py +++ b/fastplotlib/plot.py @@ -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 ): """ @@ -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`` @@ -83,6 +87,8 @@ def __init__( **kwargs ) + self._starting_size = size + def render(self): super(Plot, self).render() @@ -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