Skip to content

Commit 745f75e

Browse files
authored
improve default legend for bokeh (#324)
1 parent c16be99 commit 745f75e

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

src/arviz_plots/backend/bokeh/legend.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ def legend(
1919
artist_type="line",
2020
artist_kwargs=None,
2121
legend_target=None,
22-
side="auto",
23-
legend_placement_threshold=600, # Magic number
22+
side="right",
2423
**kwargs,
2524
):
2625
"""Generate a legend on a figure given lists of labels and property kwargs.
@@ -38,6 +37,9 @@ def legend(
3837
artist_kwargs = {}
3938
if legend_target is None:
4039
legend_target = (0, -1)
40+
if side == "right":
41+
kwargs.setdefault("margin", -55)
42+
4143
# TODO: improve selection of Figure object from what is stored as "figure"
4244
children = target.children
4345
if not isinstance(children[0], tuple):
@@ -63,17 +65,11 @@ def legend(
6365
glyph = artist_fun(**{**artist_kwargs, **kws})
6466
glyph_list.append(glyph)
6567

66-
if side == "auto":
67-
plot_width = target_plot.width
68-
if plot_width >= legend_placement_threshold:
69-
side = "right"
70-
else:
71-
side = "center"
72-
7368
leg = Legend(
7469
items=[(str(label), [glyph]) for label, glyph in zip(label_list, glyph_list)],
7570
title=title,
7671
**kwargs,
7772
)
73+
7874
target_plot.add_layout(leg, side)
7975
return leg

src/arviz_plots/styles/arviz-tumma.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ attrs:
2222
label_text_color: '#D9D9D9'
2323
background_fill_alpha: 0
2424
border_line_alpha: 0
25+
title_text_color: '#D9D9D9'
2526
Cycler:
2627
colors : [
2728
"#36acc6", "#f66d7f", "#fac364", "#7c2695",

0 commit comments

Comments
 (0)