Skip to content

Commit 85a0af7

Browse files
committed
Customizable subplot title font
1 parent 11d50b0 commit 85a0af7

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

plotly/_subplots.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def make_subplots(
5757
row_titles=None,
5858
x_title=None,
5959
y_title=None,
60+
font=dict(size=16),
6061
figure=None,
6162
**kwargs,
6263
):
@@ -227,6 +228,9 @@ def make_subplots(
227228
Title to place to the left of the left column of subplots,
228229
centered vertically
229230
231+
font: dict (default dict(size=16))
232+
Font used by any title of the subplots.
233+
230234
figure: go.Figure or None (default None)
231235
If None, a new go.Figure instance will be created and its axes will be
232236
populated with those corresponding to the requested subplot geometry and
@@ -814,7 +818,7 @@ def _check_hv_spacing(dimsize, spacing, name, dimvarname, dimname):
814818

815819
# Add subplot titles
816820
plot_title_annotations = _build_subplot_title_annotations(
817-
subplot_titles, list_of_domains
821+
subplot_titles, list_of_domains, font = font
818822
)
819823

820824
layout["annotations"] = plot_title_annotations
@@ -835,7 +839,7 @@ def _check_hv_spacing(dimsize, spacing, name, dimvarname, dimname):
835839

836840
# Add subplot titles
837841
column_title_annotations = _build_subplot_title_annotations(
838-
column_titles, domains_list
842+
column_titles, domains_list, font = font
839843
)
840844

841845
layout["annotations"] += tuple(column_title_annotations)
@@ -849,7 +853,7 @@ def _check_hv_spacing(dimsize, spacing, name, dimvarname, dimname):
849853

850854
# Add subplot titles
851855
column_title_annotations = _build_subplot_title_annotations(
852-
row_titles, domains_list, title_edge="right"
856+
row_titles, domains_list, title_edge="right", font = font
853857
)
854858

855859
layout["annotations"] += tuple(column_title_annotations)
@@ -859,7 +863,7 @@ def _check_hv_spacing(dimsize, spacing, name, dimvarname, dimname):
859863

860864
# Add subplot titles
861865
column_title_annotations = _build_subplot_title_annotations(
862-
[x_title], domains_list, title_edge="bottom", offset=30
866+
[x_title], domains_list, title_edge="bottom", offset=30, font = font
863867
)
864868

865869
layout["annotations"] += tuple(column_title_annotations)
@@ -869,7 +873,7 @@ def _check_hv_spacing(dimsize, spacing, name, dimvarname, dimname):
869873

870874
# Add subplot titles
871875
column_title_annotations = _build_subplot_title_annotations(
872-
[y_title], domains_list, title_edge="left", offset=40
876+
[y_title], domains_list, title_edge="left", offset=40, font = font
873877
)
874878

875879
layout["annotations"] += tuple(column_title_annotations)
@@ -1163,7 +1167,7 @@ def _get_cartesian_label(x_or_y, r, c, cnt):
11631167

11641168

11651169
def _build_subplot_title_annotations(
1166-
subplot_titles, list_of_domains, title_edge="top", offset=0
1170+
subplot_titles, list_of_domains, title_edge="top", offset=0, font=dict(size=16)
11671171
):
11681172
# If shared_axes is False (default) use list_of_domains
11691173
# This is used for insets and irregular layouts
@@ -1236,7 +1240,7 @@ def _build_subplot_title_annotations(
12361240
"yref": "paper",
12371241
"text": subplot_titles[index],
12381242
"showarrow": False,
1239-
"font": dict(size=16),
1243+
"font": font,
12401244
"xanchor": xanchor,
12411245
"yanchor": yanchor,
12421246
}

0 commit comments

Comments
 (0)