Skip to content

Commit f6496ea

Browse files
committed
Better aspect rations of 2D plots in dashboard
1 parent 697bbf7 commit f6496ea

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

src/beamlime/config/raw_detectors/dream.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import scipp as sc
99
from ess.reduce.live import raw
1010

11-
_res_scale = 8
11+
_res_scale = 12
1212

1313
dream_detectors_config = {
1414
'dashboard': {'nrow': 3, 'ncol': 2},

src/beamlime/services/dashboard.py

+17-9
Original file line numberDiff line numberDiff line change
@@ -282,15 +282,23 @@ def maybe_unit(dim: str) -> str:
282282
unit = data.coords[dim].unit
283283
return f' [{unit}]' if unit is not None else ''
284284

285-
fig.update_layout(
286-
title=key,
287-
width=500,
288-
height=400,
289-
xaxis_title=f'{x_dim}{maybe_unit(x_dim)}',
290-
yaxis_title=f'{y_dim}{maybe_unit(y_dim)}',
291-
uirevision=key,
292-
showlegend=False,
293-
)
285+
size = 800
286+
opts = {
287+
'title': key,
288+
'xaxis_title': f'{x_dim}{maybe_unit(x_dim)}',
289+
'yaxis_title': f'{y_dim}{maybe_unit(y_dim)}',
290+
'uirevision': key,
291+
'showlegend': False,
292+
}
293+
y_size, x_size = data.shape
294+
if y_size < x_size:
295+
fig.update_layout(width=size, **opts)
296+
fig.update_yaxes(scaleanchor="x", scaleratio=1, constrain="domain")
297+
fig.update_xaxes(constrain="domain")
298+
else:
299+
fig.update_layout(height=size, **opts)
300+
fig.update_xaxes(scaleanchor="y", scaleratio=1, constrain="domain")
301+
fig.update_yaxes(constrain="domain")
294302
return fig
295303

296304
def update_plots(self, n: int | None):

0 commit comments

Comments
 (0)