@@ -157,6 +157,7 @@ def plot_field(
157
157
vmin : Optional [float ] = None ,
158
158
vmax : Optional [float ] = None ,
159
159
ax : Ax = None ,
160
+ swap_axes : bool = False ,
160
161
** sel_kwargs ,
161
162
) -> Ax :
162
163
"""Plot the data for a monitor with simulation plot overlaid.
@@ -252,6 +253,7 @@ def plot_field(
252
253
vmax = vmax ,
253
254
cbar_kwargs = {"label" : field_name },
254
255
grid = False ,
256
+ swap_axes = swap_axes ,
255
257
)
256
258
257
259
# compute parameters for structures overlay plot
@@ -260,10 +262,8 @@ def plot_field(
260
262
261
263
# compute plot bounds
262
264
field_data_bounds = field_data .bounds
263
- min_bounds = list (field_data_bounds [0 ])
264
- max_bounds = list (field_data_bounds [1 ])
265
- min_bounds .pop (axis )
266
- max_bounds .pop (axis )
265
+ _ , min_bounds = self .pop_axis_and_swap (field_data_bounds [0 ], axis , swap_axes = swap_axes )
266
+ _ , max_bounds = self .pop_axis_and_swap (field_data_bounds [1 ], axis , swap_axes = swap_axes )
267
267
268
268
if isinstance (field_data , SpatialDataArray ):
269
269
# interp out any monitor.size==0 dimensions
@@ -315,8 +315,8 @@ def plot_field(
315
315
axis = "xyz" .index (planar_coord )
316
316
position = float (field_data .coords [planar_coord ])
317
317
318
- xy_coord_labels = list ("xyz" )
319
- xy_coord_labels . pop ( axis )
318
+ _ , xy_coord_labels = self . pop_axis_and_swap ( list ("xyz" ), axis = axis , swap_axes = swap_axes )
319
+
320
320
x_coord_label , y_coord_label = xy_coord_labels [0 ], xy_coord_labels [1 ]
321
321
field_data .plot (
322
322
ax = ax ,
@@ -327,6 +327,7 @@ def plot_field(
327
327
vmax = vmax ,
328
328
robust = robust ,
329
329
cbar_kwargs = {"label" : field_name },
330
+ swap_axes = swap_axes ,
330
331
)
331
332
332
333
# compute plot bounds
@@ -344,6 +345,7 @@ def plot_field(
344
345
alpha = structures_alpha ,
345
346
ax = ax ,
346
347
property = property_to_plot ,
348
+ swap_axes = swap_axes ,
347
349
** interp_kwarg ,
348
350
)
349
351
0 commit comments