Skip to content

Commit ac707db

Browse files
committed
added dynamically computed margin to ParCoor
1 parent 285d93e commit ac707db

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Version 1.3.9
2+
3+
## Parallel Coordinates
4+
- Set the margin of the graph so it gets dynamically computed depending on the length of the labels.
5+
16
# Version 1.3.6
27

38
## New SMAC version compatibility

deepcave/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class Config:
6969
# Figure related
7070
SAVE_IMAGES = False # The figure will be saved to the cache directory.
7171
FIGURE_MARGIN = dict(t=30, b=0, l=0, r=0)
72-
FIGURE_HEIGHT = "40vh"
72+
FIGURE_HEIGHT = "400vh"
7373
FIGURE_DOWNLOAD_SCALE = 4.0
7474
FIGURE_FONT_SIZE = 20
7575

deepcave/plugins/hyperparameter/parallel_coordinates.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -337,10 +337,17 @@ def get_output_layout(register: Callable) -> dcc.Graph:
337337
dcc.Graph
338338
The layouts for the output block.
339339
"""
340-
return dcc.Graph(
341-
register("graph", "figure"),
342-
style={"height": config.FIGURE_HEIGHT},
343-
config={"toImageButtonOptions": {"scale": config.FIGURE_DOWNLOAD_SCALE}},
340+
return html.Div(
341+
dcc.Graph(
342+
register("graph", "figure"),
343+
config={"toImageButtonOptions": {"scale": config.FIGURE_DOWNLOAD_SCALE}},
344+
style={"width": "1200px", "height": "800px"},
345+
),
346+
style={
347+
"overflowX": "scroll",
348+
"overflowY": "scroll",
349+
"height": "500px",
350+
},
344351
)
345352

346353
@staticmethod
@@ -430,17 +437,26 @@ def load_outputs(run, inputs, outputs) -> go.Figure: # type: ignore
430437
colorscale="aggrnyl",
431438
)
432439

440+
# Margin size is dynamically computed depending on the length of the labels
441+
char_width_px = 8
442+
max_label_length = max([len(label) for label in data.keys()])
443+
top_margin = max_label_length * char_width_px
444+
left_margin = max_label_length * char_width_px
445+
433446
figure = go.Figure(
434447
data=go.Parcoords(
435448
line=line,
436449
dimensions=list([d for d in data.values()]),
437-
labelangle=45,
450+
labelangle=30,
438451
),
439452
layout=dict(
440-
margin=dict(t=150, b=50, l=100, r=0),
453+
margin=dict(t=top_margin, b=50, l=left_margin, r=0),
441454
font=dict(size=config.FIGURE_FONT_SIZE),
442455
),
443456
)
457+
458+
figure.update_layout(width=max(1000, len(list([d for d in data.values()])) * 100))
459+
444460
save_image(figure, "parallel_coordinates.pdf")
445461

446462
return figure

0 commit comments

Comments
 (0)