Skip to content

Commit bbc22bc

Browse files
smarter histfunc defaults
1 parent 18e1c00 commit bbc22bc

File tree

1 file changed

+10
-0
lines changed
  • packages/python/plotly/plotly/express

1 file changed

+10
-0
lines changed

packages/python/plotly/plotly/express/_core.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,6 +1292,9 @@ def infer_config(args, constructor, trace_patch, layout_patch):
12921292
args["orientation"] = "v"
12931293

12941294
if constructor == go.Histogram:
1295+
if has_x and has_y and args["histfunc"] is None:
1296+
args["histfunc"] = trace_patch["histfunc"] = "sum"
1297+
12951298
orientation = args["orientation"]
12961299
nbins = args["nbins"]
12971300
trace_patch["nbinsx"] = nbins if orientation == "v" else None
@@ -1309,6 +1312,13 @@ def infer_config(args, constructor, trace_patch, layout_patch):
13091312
if layout_patch[mode] is None:
13101313
layout_patch[mode] = "group"
13111314

1315+
if (
1316+
constructor == go.Histogram2d
1317+
and args["z"] is not None
1318+
and args["histfunc"] is None
1319+
):
1320+
args["histfunc"] = trace_patch["histfunc"] = "sum"
1321+
13121322
if constructor in [go.Histogram2d, go.Densitymapbox]:
13131323
show_colorbar = True
13141324
trace_patch["coloraxis"] = "coloraxis1"

0 commit comments

Comments
 (0)