Skip to content

Commit 0f5655c

Browse files
authored
fix flip button (#307)
* fix flip, update simple notebook * change flip icon to arrow in direction of y-axis * change tooltip
1 parent 4fbf6ac commit 0f5655c

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

examples/notebooks/simple.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
"source": [
109109
"**Use the handle on the bottom right corner of the _canvas_ to resize it. You can also pan and zoom using your mouse!**\n",
110110
"\n",
111-
"By default the origin is on the bottom left, you can click the flip button to flip the y-axis, or use `plot.camera.world.scale_y *= -1`"
111+
"By default the origin is on the bottom left, you can click the flip button to flip the y-axis, or use `plot.camera.local.scale_y *= -1`"
112112
]
113113
},
114114
{
@@ -120,7 +120,7 @@
120120
},
121121
"outputs": [],
122122
"source": [
123-
"plot.camera.world.scale_y *= -1"
123+
"plot.camera.local.scale_y *= -1"
124124
]
125125
},
126126
{
@@ -464,7 +464,7 @@
464464
},
465465
"outputs": [],
466466
"source": [
467-
"plot_rgb.camera.world.scale_y *= -1"
467+
"plot_rgb.camera.local.scale_y *= -1"
468468
]
469469
},
470470
{

fastplotlib/layouts/_gridplot.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,9 +415,9 @@ def __init__(self, plot: GridPlot):
415415
self.flip_camera_button = Button(
416416
value=False,
417417
disabled=False,
418-
icon="arrows-v",
418+
icon="arrow-up",
419419
layout=Layout(width="auto"),
420-
tooltip="flip",
420+
tooltip="y-axis direction",
421421
)
422422

423423
self.record_button = ToggleButton(
@@ -490,7 +490,11 @@ def maintain_aspect(self, obj):
490490

491491
def flip_camera(self, obj):
492492
current = self.current_subplot
493-
current.camera.world.scale_y *= -1
493+
current.camera.local.scale_y *= -1
494+
if current.camera.local.scale_y == -1:
495+
self.flip_camera_button.icon = "arrow-down"
496+
else:
497+
self.flip_camera_button.icon = "arrow-up"
494498

495499
def update_current_subplot(self, ev):
496500
for subplot in self.plot:

fastplotlib/layouts/_plot.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def __init__(self, plot: Plot):
170170
self.flip_camera_button = Button(
171171
value=False,
172172
disabled=False,
173-
icon="arrows-v",
173+
icon="arrow-up",
174174
layout=Layout(width="auto"),
175175
tooltip="flip",
176176
)
@@ -224,7 +224,11 @@ def maintain_aspect(self, obj):
224224
self.plot.camera.maintain_aspect = self.maintain_aspect_button.value
225225

226226
def flip_camera(self, obj):
227-
self.plot.camera.world.scale_y *= -1
227+
self.plot.camera.local.scale_y *= -1
228+
if self.plot.camera.local.scale_y == -1:
229+
self.flip_camera_button.icon = "arrow-down"
230+
else:
231+
self.flip_camera_button.icon = "arrow-up"
228232

229233
def add_polygon(self, obj):
230234
ps = PolygonSelector(edge_width=3, edge_color="magenta")

0 commit comments

Comments
 (0)
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