Repository navigation
Expand file tree
/
Copy pathplot_theme.py
More file actions
90 lines (80 loc) · 2.51 KB
/
Copy pathplot_theme.py
File metadata and controls
90 lines (80 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
"""Shared Lets-Plot theme for the site."""
from lets_plot import (
element_blank,
element_line,
element_rect,
element_text,
scale_color_manual,
scale_fill_manual,
theme,
theme_minimal,
)
COLORS_CUSTOM = (
"#2563eb",
"#0d9488",
"#db2777",
"#7c3aed",
"#d97706",
"#16a34a",
"#ea580c",
"#0891b2",
)
COLOR_CUSTOM = COLORS_CUSTOM[0]
PLOT_BACKGROUND = "#ffffff"
PLOT_TEXT = "#0f172a"
PLOT_MUTED = "#64748b"
PLOT_RULE = "#cbd5e1"
def _typography(text: str, muted: str, title: str):
return theme(
text=element_text(family="Inter", size=11, color=text),
plot_title=element_text(
family="Inter", face="bold", size=18, color=title, hjust=0
),
plot_subtitle=element_text(
family="Inter", size=12, color=muted, hjust=0
),
plot_caption=element_text(
family="JetBrains Mono", size=9, color=muted, hjust=1
),
axis_title=element_text(
family="Inter", face="bold", size=10, color=text
),
axis_text=element_text(family="Inter", size=10, color=muted),
legend_title=element_text(
family="JetBrains Mono", face="bold", size=9, color=muted
),
legend_text=element_text(family="Inter", size=10, color=text),
legend_position="bottom",
legend_direction="horizontal",
legend_box="vertical",
legend_box_just="left",
legend_spacing=8,
legend_key_size=16,
plot_margin=18,
)
def theme_custom():
return (
theme_minimal()
+ _typography(PLOT_TEXT, PLOT_MUTED, PLOT_TEXT)
+ theme(
plot_background=element_rect(
fill=PLOT_BACKGROUND, color=PLOT_BACKGROUND
),
panel_background=element_rect(
fill=PLOT_BACKGROUND, color=PLOT_BACKGROUND
),
panel_grid_major_x=element_blank(),
panel_grid_minor=element_blank(),
panel_grid_major_y=element_line(color="#e2e8f0", size=0.8),
axis_ticks=element_blank(),
axis_line=element_blank(),
legend_background=element_rect(
fill=PLOT_BACKGROUND, color=PLOT_BACKGROUND
),
legend_key=element_rect(fill=PLOT_BACKGROUND, color=PLOT_BACKGROUND),
)
)
def scale_color_custom(**kwargs):
return scale_color_manual(values=list(COLORS_CUSTOM), **kwargs)
def scale_fill_custom(**kwargs):
return scale_fill_manual(values=list(COLORS_CUSTOM), **kwargs)