Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd2818c7

Browse files
committed
Customizable subplot title font
1 parentf083977 commitd2818c7

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

‎CHANGELOG.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
44

55
##Unreleased
66

7+
###Added
8+
- Add optional`font` parameter for`make_subplots`[[#5393](https://github.com/plotly/plotly.py/pull/5393)]
9+
710
###Updated
811
- Speed up`validate_gantt` function[[#5386](https://github.com/plotly/plotly.py/pull/5386)], with thanks to@misrasaurabh1 for the contribution!
912

‎plotly/_subplots.py‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def make_subplots(
5858
x_title=None,
5959
y_title=None,
6060
figure=None,
61+
font=None,
6162
**kwargs,
6263
):
6364
"""
@@ -235,6 +236,9 @@ def make_subplots(
235236
layout of this figure and this figure will be returned. If the figure
236237
already contains axes, they will be overwritten.
237238
239+
font: dict (default None)
240+
Font used by any title of the subplots.
241+
238242
Examples
239243
--------
240244
@@ -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=None
11671171
):
11681172
# If shared_axes is False (default) use list_of_domains
11691173
# This is used for insets and irregular layouts
@@ -1173,6 +1177,10 @@ def _build_subplot_title_annotations(
11731177
subtitle_pos_x= []
11741178
subtitle_pos_y= []
11751179

1180+
# If no font size is provided, use this fallback
1181+
iffontisNone:
1182+
font=dict(size=16)
1183+
11761184
iftitle_edge=="top":
11771185
text_angle=0
11781186
xanchor="center"
@@ -1236,7 +1244,7 @@ def _build_subplot_title_annotations(
12361244
"yref":"paper",
12371245
"text":subplot_titles[index],
12381246
"showarrow":False,
1239-
"font":dict(size=16),
1247+
"font":font,
12401248
"xanchor":xanchor,
12411249
"yanchor":yanchor,
12421250
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp