Skip to content

Plot.auto_scale() shouldn't change the camera aspect unless desired #364

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 7 commits into from
Nov 16, 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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

docs-build:
name: Docs
runs-on: ubuntu-latest
runs-on: bigmem
strategy:
fail-fast: false
steps:
Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:

test-build-full:
name: Test examples, env with notebook and glfw
runs-on: ubuntu-latest
runs-on: bigmem
if: ${{ !github.event.pull_request.draft }}
strategy:
fail-fast: false
Expand Down Expand Up @@ -105,7 +105,7 @@ jobs:

test-build-desktop:
name: Test examples, env with only glfw
runs-on: ubuntu-latest
runs-on: bigmem
if: ${{ !github.event.pull_request.draft }}
strategy:
fail-fast: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/screenshots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
jobs:
screenshots:
name: Regenerate
runs-on: 'ubuntu-latest'
runs-on: bigmem
if: ${{ !github.event.pull_request.draft }}
steps:
- name: Install git-lfs
Expand Down
4 changes: 2 additions & 2 deletions examples/desktop/screenshots/gridplot.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 examples/desktop/screenshots/gridplot_non_square.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 examples/desktop/screenshots/heatmap.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 examples/desktop/screenshots/heatmap_cmap.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 examples/desktop/screenshots/heatmap_data.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 examples/desktop/screenshots/heatmap_vmin_vmax.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 examples/desktop/screenshots/image_cmap.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 examples/desktop/screenshots/image_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 examples/desktop/screenshots/image_rgbvminvmax.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 examples/desktop/screenshots/image_simple.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 examples/desktop/screenshots/image_vminvmax.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 examples/desktop/screenshots/line.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 examples/desktop/screenshots/line_cmap.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 examples/desktop/screenshots/line_collection.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.
4 changes: 2 additions & 2 deletions examples/desktop/screenshots/line_collection_colors.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 examples/desktop/screenshots/line_colorslice.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 examples/desktop/screenshots/line_dataslice.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 examples/desktop/screenshots/line_present_scaling.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 examples/desktop/screenshots/line_stack.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 examples/desktop/screenshots/scatter.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 examples/desktop/screenshots/scatter_cmap.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 examples/desktop/screenshots/scatter_colorslice.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 examples/desktop/screenshots/scatter_dataslice.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 examples/desktop/screenshots/scatter_present.png
4 changes: 2 additions & 2 deletions examples/desktop/screenshots/scatter_size.png
4 changes: 2 additions & 2 deletions examples/notebooks/screenshots/nb-astronaut.png
4 changes: 2 additions & 2 deletions examples/notebooks/screenshots/nb-astronaut_RGB.png
4 changes: 2 additions & 2 deletions examples/notebooks/screenshots/nb-camera.png
4 changes: 2 additions & 2 deletions examples/notebooks/screenshots/nb-lines-3d.png
4 changes: 2 additions & 2 deletions examples/notebooks/screenshots/nb-lines-cmap-jet-values.png
4 changes: 2 additions & 2 deletions examples/notebooks/screenshots/nb-lines-cmap-jet.png
4 changes: 2 additions & 2 deletions examples/notebooks/screenshots/nb-lines-cmap-tab-10.png
4 changes: 2 additions & 2 deletions examples/notebooks/screenshots/nb-lines-cmap-viridis.png
4 changes: 2 additions & 2 deletions examples/notebooks/screenshots/nb-lines-cmap-white.png
4 changes: 2 additions & 2 deletions examples/notebooks/screenshots/nb-lines-colors.png
4 changes: 2 additions & 2 deletions examples/notebooks/screenshots/nb-lines-data.png
4 changes: 2 additions & 2 deletions examples/notebooks/screenshots/nb-lines-underlay.png
4 changes: 2 additions & 2 deletions examples/notebooks/screenshots/nb-lines.png
20 changes: 13 additions & 7 deletions fastplotlib/layouts/_plot_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ def center_graphic(self, graphic: Graphic, zoom: float = 1.35):
# probably because camera.show_object uses bounding sphere
self.camera.zoom = zoom

def center_scene(self, zoom: float = 1.35):
def center_scene(self, *, zoom: float = 1.35):
"""
Auto-center the scene, does not scale.

Expand All @@ -481,15 +481,20 @@ def center_scene(self, zoom: float = 1.35):
# probably because camera.show_object uses bounding sphere
camera.zoom = zoom

def auto_scale(self, maintain_aspect: bool = False, zoom: float = 0.8):
def auto_scale(
self,
*, # since this is often used as an event handler, don't want to coerce maintain_aspect = True
maintain_aspect: Union[None, bool] = None,
zoom: float = 0.8
):
"""
Auto-scale the camera w.r.t to the scene

Parameters
----------
maintain_aspect: bool, default ``False``
maintain the camera aspect ratio for all dimensions, if ``False`` the camera
is scaled according to the bounds in each dimension.
maintain_aspect: ``None`` or bool, default ``None``
Maintain the camera aspect ratio for all dimensions. If ``None``, the aspect is left unchanged.
if ``False`` the camera is scaled to the bounding box of the current scene.

zoom: float, default 0.8
zoom value for the camera after auto-scaling, if zoom = 1.0 then the graphics
Expand All @@ -503,8 +508,9 @@ def auto_scale(self, maintain_aspect: bool = False, zoom: float = 0.8):
self.scene.remove(selector.world_object)

self.center_scene()
if not isinstance(maintain_aspect, bool):
maintain_aspect = False # assume False

if maintain_aspect is None: # if not provided keep current setting
maintain_aspect = self.camera.maintain_aspect

# scale all cameras associated with this controller else it looks wonky
for camera in self.controller.cameras:
Expand Down
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