Skip to content

Commit e41dc36

Browse files
committed
handle barmode/offsetgroup edge cases
1 parent ac8af46 commit e41dc36

File tree

1 file changed

+9
-3
lines changed
  • packages/python/plotly/plotly/express

1 file changed

+9
-3
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -652,8 +652,6 @@ def set_cartesian_axis_opts(args, axis, letter, orders):
652652

653653

654654
def configure_cartesian_marginal_axes(args, fig, orders):
655-
if "histogram" in [args["marginal_x"], args["marginal_y"]]:
656-
fig.layout["barmode"] = "overlay"
657655

658656
nrows = len(fig._grid_ref)
659657
ncols = len(fig._grid_ref[0])
@@ -2147,6 +2145,9 @@ def process_dataframe_timeline(args):
21472145
args["x"] = args["x_end"]
21482146
args["base"] = args["x_start"]
21492147
del args["x_start"], args["x_end"]
2148+
2149+
args["barmode"] = "relative"
2150+
21502151
return args
21512152

21522153

@@ -2558,8 +2559,13 @@ def make_figure(args, constructor, trace_patch=None, layout_patch=None):
25582559
legendgroup=trace_name,
25592560
showlegend=(trace_name != "" and trace_name not in trace_names),
25602561
)
2562+
2563+
# With marginal histogram, if barmode is not set, set to "overlay"
2564+
if "histogram" in [args.get("marginal_x"), args.get("marginal_y")] and "barmode" not in args:
2565+
layout_patch["barmode"] = "overlay"
2566+
25612567
# Set 'offsetgroup' only in group barmode (or if no barmode is set)
2562-
barmode = args.get("barmode")
2568+
barmode = args.get("barmode") or layout_patch.get("barmode")
25632569
if (
25642570
trace_spec.constructor in [go.Bar, go.Box, go.Violin, go.Histogram]
25652571
and (barmode == "group" or barmode is None)

0 commit comments

Comments
 (0)