You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not sure why, pygfx demo works, fpl is doing something additional I think:
importnumpyasnpimportfastplotlibasfplimportpygfxxs=np.linspace(0, 2*np.pi, 100)
ys=np.sin(xs)
ys_big=np.random.rand(100) *10# create cameras, fov=0 means Orthographic projectioncamera1=pygfx.PerspectiveCamera(fov=0)
camera2=pygfx.PerspectiveCamera(fov=0)
# create controllers, first add the "main" camera for the subplotcontroller1=pygfx.PanZoomController(camera1)
controller2=pygfx.PanZoomController(camera2)
# add the other camera to each controller, but only include the 'x' state, i.e. 'y' for height is not included# this must be done only after adding the "main" cameras to the controller as done abovecontroller1.add_camera(camera2, include_state={"x", "width"})
controller2.add_camera(camera1, include_state={"x", "width"})
# create figure using these cameras and controllersfigure=fpl.Figure(
shape=(2, 1),
cameras=[camera1, camera2],
controllers=[controller1, controller2],
size=(700, 560)
)
figure[0, 0].add_line(np.column_stack([xs, ys_big]))
figure[1, 0].add_line(np.column_stack([xs, ys]))
print(controller1._cameras)
print(controller2._cameras)
forsubplotinfigure:
subplot.camera.zoom=1.0figure.show(maintain_aspect=False, autoscale=False)
I did make the following change to PlotArea:
Index: fastplotlib/layouts/_plot_area.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================diff --git a/fastplotlib/layouts/_plot_area.py b/fastplotlib/layouts/_plot_area.py--- a/fastplotlib/layouts/_plot_area.py +++ b/fastplotlib/layouts/_plot_area.py (date 1743405901011)@@ -79,7 +79,9 @@
self._camera = camera
self._controller = controller
- self.controller.add_camera(self._camera)+ if self.camera not in self.controller.cameras:+ self.controller.add_camera(self._camera)+
self.controller.register_events(
self.viewport,
)
Not sure why, pygfx demo works, fpl is doing something additional I think:
I did make the following change to
PlotArea: