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

Function make_figure

plotly/express/_core.py:2507–2838  ·  view source on GitHub ↗
(args, constructor, trace_patch=None, layout_patch=None)

Source from the content-addressed store, hash-verified

2505
2506
2507def make_figure(args, constructor, trace_patch=None, layout_patch=None):
2508 trace_patch = trace_patch or {}
2509 layout_patch = layout_patch or {}
2510 # Track if color_continuous_scale was explicitly provided by user
2511 # (before apply_default_cascade fills it from template/defaults)
2512 user_provided_colorscale = args.get("color_continuous_scale") is not None
2513 apply_default_cascade(args, constructor=constructor)
2514
2515 args = build_dataframe(args, constructor)
2516 if constructor in [go.Treemap, go.Sunburst, go.Icicle] and args["path"] is not None:
2517 args = process_dataframe_hierarchy(args)
2518 if constructor in [go.Pie]:
2519 args, trace_patch = process_dataframe_pie(args, trace_patch)
2520 if constructor == "timeline":
2521 constructor = go.Bar
2522 args = process_dataframe_timeline(args)
2523
2524 # If we have marginal histograms, set barmode to "overlay"
2525 if "histogram" in [args.get("marginal_x"), args.get("marginal_y")]:
2526 layout_patch["barmode"] = "overlay"
2527
2528 trace_specs, grouped_mappings, sizeref, show_colorbar = infer_config(
2529 args, constructor, trace_patch, layout_patch
2530 )
2531 grouper = [x.grouper or one_group for x in grouped_mappings] or [one_group]
2532 groups, orders = get_groups_and_orders(args, grouper)
2533
2534 col_labels = []
2535 row_labels = []
2536 nrows = ncols = 1
2537 for m in grouped_mappings:
2538 if m.grouper not in orders:
2539 m.val_map[""] = m.sequence[0]
2540 else:
2541 sorted_values = orders[m.grouper]
2542 if m.facet == "col":
2543 prefix = get_label(args, args["facet_col"]) + "="
2544 col_labels = [prefix + str(s) for s in sorted_values]
2545 ncols = len(col_labels)
2546 if m.facet == "row":
2547 prefix = get_label(args, args["facet_row"]) + "="
2548 row_labels = [prefix + str(s) for s in sorted_values]
2549 nrows = len(row_labels)
2550 for val in sorted_values:
2551 if val not in m.val_map: # always False if it's an IdentityMap
2552 m.val_map[val] = m.sequence[len(m.val_map) % len(m.sequence)]
2553
2554 subplot_type = _subplot_type_for_trace_type(constructor().type)
2555
2556 trace_names_by_frame = {}
2557 frames = OrderedDict()
2558 trendline_rows = []
2559 trace_name_labels = None
2560 facet_col_wrap = args.get("facet_col_wrap", 0)
2561 for group_name, group in groups.items():
2562 mapping_labels = OrderedDict()
2563 trace_name_labels = OrderedDict()
2564 frame_name = ""

Callers 15

scatterFunction · 0.85
density_contourFunction · 0.85
density_heatmapFunction · 0.85
lineFunction · 0.85
areaFunction · 0.85
barFunction · 0.85
timelineFunction · 0.85
histogramFunction · 0.85
ecdfFunction · 0.85
violinFunction · 0.85
boxFunction · 0.85
stripFunction · 0.85

Calls 15

validate_coerceMethod · 0.95
ColorscaleValidatorClass · 0.90
apply_default_cascadeFunction · 0.85
build_dataframeFunction · 0.85
process_dataframe_pieFunction · 0.85
infer_configFunction · 0.85
get_groups_and_ordersFunction · 0.85
get_labelFunction · 0.85

Tested by

no test coverage detected