(layout, secondary_y, x_domain, y_domain, max_subplot_ids=None)
| 988 | |
| 989 | |
| 990 | def _init_subplot_xy(layout, secondary_y, x_domain, y_domain, max_subplot_ids=None): |
| 991 | if max_subplot_ids is None: |
| 992 | max_subplot_ids = _get_initial_max_subplot_ids() |
| 993 | |
| 994 | # Get axis label and anchor |
| 995 | x_cnt = max_subplot_ids["xaxis"] + 1 |
| 996 | y_cnt = max_subplot_ids["yaxis"] + 1 |
| 997 | |
| 998 | # Compute x/y labels (the values of trace.xaxis/trace.yaxis |
| 999 | x_label = "x{cnt}".format(cnt=x_cnt if x_cnt > 1 else "") |
| 1000 | y_label = "y{cnt}".format(cnt=y_cnt if y_cnt > 1 else "") |
| 1001 | |
| 1002 | # Anchor x and y axes to each other |
| 1003 | x_anchor, y_anchor = y_label, x_label |
| 1004 | |
| 1005 | # Build layout.xaxis/layout.yaxis containers |
| 1006 | xaxis_name = "xaxis{cnt}".format(cnt=x_cnt if x_cnt > 1 else "") |
| 1007 | yaxis_name = "yaxis{cnt}".format(cnt=y_cnt if y_cnt > 1 else "") |
| 1008 | x_axis = {"domain": x_domain, "anchor": x_anchor} |
| 1009 | y_axis = {"domain": y_domain, "anchor": y_anchor} |
| 1010 | |
| 1011 | layout[xaxis_name] = x_axis |
| 1012 | layout[yaxis_name] = y_axis |
| 1013 | |
| 1014 | subplot_refs = [ |
| 1015 | SubplotRef( |
| 1016 | subplot_type="xy", |
| 1017 | layout_keys=(xaxis_name, yaxis_name), |
| 1018 | trace_kwargs={"xaxis": x_label, "yaxis": y_label}, |
| 1019 | ) |
| 1020 | ] |
| 1021 | |
| 1022 | if secondary_y: |
| 1023 | y_cnt += 1 |
| 1024 | secondary_yaxis_name = "yaxis{cnt}".format(cnt=y_cnt if y_cnt > 1 else "") |
| 1025 | secondary_y_label = "y{cnt}".format(cnt=y_cnt) |
| 1026 | |
| 1027 | # Add secondary y-axis to subplot reference |
| 1028 | subplot_refs.append( |
| 1029 | SubplotRef( |
| 1030 | subplot_type="xy", |
| 1031 | layout_keys=(xaxis_name, secondary_yaxis_name), |
| 1032 | trace_kwargs={"xaxis": x_label, "yaxis": secondary_y_label}, |
| 1033 | ) |
| 1034 | ) |
| 1035 | |
| 1036 | # Add secondary y axis to layout |
| 1037 | secondary_y_axis = {"anchor": y_anchor, "overlaying": y_label, "side": "right"} |
| 1038 | layout[secondary_yaxis_name] = secondary_y_axis |
| 1039 | |
| 1040 | # increment max_subplot_ids |
| 1041 | max_subplot_ids["xaxis"] = x_cnt |
| 1042 | max_subplot_ids["yaxis"] = y_cnt |
| 1043 | |
| 1044 | return tuple(subplot_refs) |
| 1045 | |
| 1046 | |
| 1047 | def _init_subplot_single( |
no test coverage detected