1919
2020import xarray as xr
2121
22- from cubedynamics .plotting .cube_plot import CubePlot , ScaleFillContinuous
22+ from cubedynamics .plotting .cube_plot import (
23+ DEFAULT_CAMERA ,
24+ CubePlot ,
25+ ScaleFillContinuous ,
26+ plotly_camera_to_coord ,
27+ resolve_camera ,
28+ )
2329from cubedynamics .streaming import VirtualCube
2430from cubedynamics .utils import _infer_time_y_x_dims
2531from ..piping import Verb
@@ -39,6 +45,7 @@ class PlotOptions:
3945 thin_time_factor : int = 4
4046 time_dim : str | None = None
4147 clim : tuple [float , float ] | None = None
48+ camera : dict | None = None
4249 fig_id : int | None = None
4350 fig_title : str | None = None
4451 fig_text : str | None = None
@@ -54,6 +61,7 @@ def plot(
5461 thin_time_factor : int = 4 ,
5562 time_dim : str | None = None ,
5663 clim : tuple [float , float ] | None = None ,
64+ camera : dict | None = None ,
5765 fig_id : int | None = None ,
5866 fig_title : str | None = None ,
5967 fig_text : str | None = None ,
@@ -70,6 +78,7 @@ def plot(
7078 thin_time_factor : int = 4 ,
7179 time_dim : str | None = None ,
7280 clim : tuple [float , float ] | None = None ,
81+ camera : dict | None = None ,
7382 fig_id : int | None = None ,
7483 fig_title : str | None = None ,
7584 fig_text : str | None = None ,
@@ -86,6 +95,7 @@ def plot(
8695 thin_time_factor : int = 4 ,
8796 time_dim : str | None = None ,
8897 clim : tuple [float , float ] | None = None ,
98+ camera : dict | None = None ,
8999 fig_id : int | None = None ,
90100 fig_title : str | None = None ,
91101 fig_text : str | None = None ,
@@ -116,6 +126,9 @@ def plot(
116126 Name of the temporal dimension. Inferred when not provided.
117127 clim : tuple of float, optional
118128 Color limits for the continuous scale.
129+ camera : dict, optional
130+ Plotly-style camera configuration used to set the initial cube view.
131+ When omitted, a front-right, zoomed-out default is applied.
119132 fig_id, fig_title, fig_text : optional
120133 Caption metadata used by the viewer export helpers.
121134
@@ -158,6 +171,7 @@ def plot(
158171 thin_time_factor = thin_time_factor ,
159172 time_dim = time_dim ,
160173 clim = clim ,
174+ camera = camera ,
161175 fig_id = fig_id ,
162176 fig_title = fig_title ,
163177 fig_text = fig_text ,
@@ -183,6 +197,9 @@ def _plot(value: xr.DataArray | VirtualCube):
183197 if opts .fig_id is not None or opts .fig_title is not None or opts .fig_text is not None :
184198 caption_payload = {"id" : opts .fig_id , "title" : opts .fig_title , "text" : opts .fig_text }
185199
200+ camera_to_use = resolve_camera (opts .camera or DEFAULT_CAMERA )
201+ coord = plotly_camera_to_coord (camera_to_use )
202+
186203 # 1. Build CubePlot for this cube
187204 cube = CubePlot (
188205 da_value ,
@@ -194,6 +211,8 @@ def _plot(value: xr.DataArray | VirtualCube):
194211 time_dim = resolved_time ,
195212 fill_scale = ScaleFillContinuous (cmap = opts .cmap , limits = opts .clim ),
196213 fig_title = opts .fig_title ,
214+ coord = coord ,
215+ camera = camera_to_use ,
197216 )
198217
199218 # 2. Draw cube
0 commit comments