MCPcopy Index your code
hub / github.com/plotly/plotly.py / init_figure

Function init_figure

plotly/express/_core.py:2841–2934  ·  view source on GitHub ↗
(args, subplot_type, frame_list, nrows, ncols, col_labels, row_labels)

Source from the content-addressed store, hash-verified

2839
2840
2841def init_figure(args, subplot_type, frame_list, nrows, ncols, col_labels, row_labels):
2842 # Build subplot specs
2843 specs = [[dict(type=subplot_type or "domain")] * ncols for _ in range(nrows)]
2844
2845 # Default row/column widths uniform
2846 column_widths = [1.0] * ncols
2847 row_heights = [1.0] * nrows
2848 facet_col_wrap = args.get("facet_col_wrap", 0)
2849
2850 # Build column_widths/row_heights
2851 if subplot_type == "xy":
2852 if args.get("marginal_x") is not None:
2853 if args["marginal_x"] == "histogram" or ("color" in args and args["color"]):
2854 main_size = 0.74
2855 else:
2856 main_size = 0.84
2857
2858 row_heights = [main_size] * (nrows - 1) + [1 - main_size]
2859 vertical_spacing = 0.01
2860 elif facet_col_wrap:
2861 vertical_spacing = args.get("facet_row_spacing") or 0.07
2862 else:
2863 vertical_spacing = args.get("facet_row_spacing") or 0.03
2864
2865 if args.get("marginal_y") is not None:
2866 if args["marginal_y"] == "histogram" or ("color" in args and args["color"]):
2867 main_size = 0.74
2868 else:
2869 main_size = 0.84
2870
2871 column_widths = [main_size] * (ncols - 1) + [1 - main_size]
2872 horizontal_spacing = 0.005
2873 else:
2874 horizontal_spacing = args.get("facet_col_spacing") or 0.02
2875 else:
2876 # Other subplot types:
2877 # 'scene', 'geo', 'polar', 'ternary', 'mapbox', 'domain', None
2878 #
2879 # We can customize subplot spacing per type once we enable faceting
2880 # for all plot types
2881 if facet_col_wrap:
2882 vertical_spacing = args.get("facet_row_spacing") or 0.07
2883 else:
2884 vertical_spacing = args.get("facet_row_spacing") or 0.03
2885 horizontal_spacing = args.get("facet_col_spacing") or 0.02
2886
2887 if facet_col_wrap:
2888 subplot_labels = [None] * nrows * ncols
2889 while len(col_labels) < nrows * ncols:
2890 col_labels.append(None)
2891 for i in range(nrows):
2892 for j in range(ncols):
2893 subplot_labels[i * ncols + j] = col_labels[(nrows - 1 - i) * ncols + j]
2894
2895 def _spacing_error_translator(e, direction, facet_arg):
2896 """
2897 Translates the spacing errors thrown by the underlying make_subplots
2898 routine into one that describes an argument adjustable through px.

Callers 2

make_figureFunction · 0.85
imshowFunction · 0.85

Calls 4

make_subplotsFunction · 0.90
getMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected