| 1167 | |
| 1168 | |
| 1169 | def _build_subplot_title_annotations( |
| 1170 | subplot_titles, list_of_domains, title_edge="top", offset=0, font=None |
| 1171 | ): |
| 1172 | # If shared_axes is False (default) use list_of_domains |
| 1173 | # This is used for insets and irregular layouts |
| 1174 | # if not shared_xaxes and not shared_yaxes: |
| 1175 | x_dom = list_of_domains[::2] |
| 1176 | y_dom = list_of_domains[1::2] |
| 1177 | subtitle_pos_x = [] |
| 1178 | subtitle_pos_y = [] |
| 1179 | |
| 1180 | # If no font size is provided, use this fallback |
| 1181 | if font is None: |
| 1182 | font = dict(size=16) |
| 1183 | |
| 1184 | if title_edge == "top": |
| 1185 | text_angle = 0 |
| 1186 | xanchor = "center" |
| 1187 | yanchor = "bottom" |
| 1188 | |
| 1189 | for x_domains in x_dom: |
| 1190 | subtitle_pos_x.append(sum(x_domains) / 2.0) |
| 1191 | for y_domains in y_dom: |
| 1192 | subtitle_pos_y.append(y_domains[1]) |
| 1193 | |
| 1194 | yshift = offset |
| 1195 | xshift = 0 |
| 1196 | elif title_edge == "bottom": |
| 1197 | text_angle = 0 |
| 1198 | xanchor = "center" |
| 1199 | yanchor = "top" |
| 1200 | |
| 1201 | for x_domains in x_dom: |
| 1202 | subtitle_pos_x.append(sum(x_domains) / 2.0) |
| 1203 | for y_domains in y_dom: |
| 1204 | subtitle_pos_y.append(y_domains[0]) |
| 1205 | |
| 1206 | yshift = -offset |
| 1207 | xshift = 0 |
| 1208 | elif title_edge == "right": |
| 1209 | text_angle = 90 |
| 1210 | xanchor = "left" |
| 1211 | yanchor = "middle" |
| 1212 | |
| 1213 | for x_domains in x_dom: |
| 1214 | subtitle_pos_x.append(x_domains[1]) |
| 1215 | for y_domains in y_dom: |
| 1216 | subtitle_pos_y.append(sum(y_domains) / 2.0) |
| 1217 | |
| 1218 | yshift = 0 |
| 1219 | xshift = offset |
| 1220 | elif title_edge == "left": |
| 1221 | text_angle = -90 |
| 1222 | xanchor = "right" |
| 1223 | yanchor = "middle" |
| 1224 | |
| 1225 | for x_domains in x_dom: |
| 1226 | subtitle_pos_x.append(x_domains[0]) |