Skip to content

Commit 16cfa8b

Browse files
clean plot styling
1 parent 519bc2f commit 16cfa8b

6 files changed

+38
-23
lines changed

content/9.0_Generation_for_Antibody_Engineering.ipynb

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
},
4848
{
4949
"cell_type": "code",
50-
"execution_count": 57,
50+
"execution_count": 2,
5151
"id": "b8ed5dc9",
5252
"metadata": {
5353
"scrolled": true
@@ -70,11 +70,8 @@
7070
"from Bio.PDB import *\n",
7171
"\n",
7272
"from biolmai import BioLM\n",
73-
"from matplotlib.font_manager import fontManager, FontProperties\n",
74-
"font_path = \"../font/Geist-Regular.ttf\"\n",
75-
"fontManager.addfont(font_path)\n",
76-
"prop = FontProperties(fname=font_path)\n",
77-
"sns.set_theme(font=prop.get_name(), style=\"white\", context='notebook', palette='pastel')"
73+
"from helpers.styling import apply_plot_styling\n",
74+
"apply_plot_styling()"
7875
]
7976
},
8077
{

content/9.1_Intrinsic_Scoring_for_Antibody_Engineering.ipynb

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
},
5454
{
5555
"cell_type": "code",
56-
"execution_count": 3,
56+
"execution_count": 1,
5757
"id": "b8ed5dc9",
5858
"metadata": {},
5959
"outputs": [],
@@ -73,11 +73,8 @@
7373
"from Bio.PDB import *\n",
7474
"\n",
7575
"from biolmai import BioLM\n",
76-
"from matplotlib.font_manager import fontManager, FontProperties\n",
77-
"font_path = \"../font/Geist-Regular.ttf\"\n",
78-
"fontManager.addfont(font_path)\n",
79-
"prop = FontProperties(fname=font_path)\n",
80-
"sns.set_theme(font=prop.get_name(), style=\"white\", context='notebook', palette='pastel')"
76+
"from helpers.styling import apply_plot_styling\n",
77+
"apply_plot_styling()"
8178
]
8279
},
8380
{

content/9.2_Structural_Scoring_for_Antibody_Engineering.ipynb

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
},
4747
{
4848
"cell_type": "code",
49-
"execution_count": 36,
49+
"execution_count": 1,
5050
"id": "b8ed5dc9",
5151
"metadata": {},
5252
"outputs": [],
@@ -66,11 +66,8 @@
6666
"from Bio.PDB import *\n",
6767
"import os\n",
6868
"from biolmai import BioLM\n",
69-
"from matplotlib.font_manager import fontManager, FontProperties\n",
70-
"font_path = \"../font/Geist-Regular.ttf\"\n",
71-
"fontManager.addfont(font_path)\n",
72-
"prop = FontProperties(fname=font_path)\n",
73-
"sns.set_theme(font=prop.get_name(), style=\"white\", context='notebook', palette='pastel')"
69+
"from helpers.styling import apply_plot_styling\n",
70+
"apply_plot_styling()"
7471
]
7572
},
7673
{

content/9.3_Downstream_for_Antibody_Engineering.ipynb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,8 @@
6868
"from Bio.PDB import *\n",
6969
"\n",
7070
"from biolmai import BioLM\n",
71-
"from matplotlib.font_manager import fontManager, FontProperties\n",
72-
"font_path = \"../font/Geist-Regular.ttf\"\n",
73-
"fontManager.addfont(font_path)\n",
74-
"prop = FontProperties(fname=font_path)\n",
75-
"sns.set_theme(font=prop.get_name(), style=\"white\", context='notebook', palette='pastel')"
71+
"from helpers.styling import apply_plot_styling\n",
72+
"apply_plot_styling()"
7673
]
7774
},
7875
{

content/helpers/styling.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import seaborn as sns
2+
import os
3+
from matplotlib import rcParams
4+
from matplotlib.font_manager import fontManager, FontProperties
5+
6+
def apply_plot_styling(font_filename="Geist-Regular.ttf"):
7+
"""
8+
Applies custom font and Seaborn theme styling for consistent plot visuals.
9+
10+
Parameters:
11+
font_filename (str): Name of the .ttf font file located in the same directory as this script.
12+
"""
13+
current_dir = os.path.dirname(os.path.abspath(__file__))
14+
font_path = os.path.join(current_dir, font_filename)
15+
16+
fontManager.addfont(font_path)
17+
prop = FontProperties(fname=font_path)
18+
font_name = prop.get_name()
19+
20+
sns.set_theme(
21+
font=font_name,
22+
style="white",
23+
context="notebook",
24+
palette="pastel"
25+
)
26+
27+
rcParams['font.family'] = font_name

0 commit comments

Comments
 (0)