8000 Do not assign `offsetgroup` to traces in px unless `barmode="group"` by emilykl · Pull Request #4865 · plotly/plotly.py · GitHub
[go: up one dir, main page]

Skip to content

Do not assign offsetgroup to traces in px unless barmode="group" #4865

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Nov 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
handle barmode/offsetgroup edge cases
  • Loading branch information
emilykl committed Nov 14, 2024
commit e41dc36d35c428b00ccece05e994ae6aaea94a6b
12 changes: 9 additions & 3 deletions packages/python/plotly/plotly/express/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,8 +652,6 @@ def set_cartesian_axis_opts(args, axis, letter, orders):


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

nrows = len(fig._grid_ref)
ncols = len(fig._grid_ref[0])
Expand Down Expand Up @@ -2147,6 +2145,9 @@ def process_dataframe_timeline(args):
args["x"] = args["x_end"]
args["base"] = args["x_start"]
del args["x_start"], args["x_end"]

args["barmode"] = "relative"

return args


Expand Down Expand Up @@ -2558,8 +2559,13 @@ def make_figure(args, constructor, trace_patch=None, layout_patch=None):
legendgroup=trace_name,
showlegend=(trace_name != "" and trace_name not in trace_names),
)

# With marginal histogram, if barmode is not set, set to "overlay"
if "histogram" in [args.get("marginal_x"), args.get("marginal_y")] and "barmode" not in args:
layout_patch["barmode"] = "overlay"

# Set 'offsetgroup' only in group barmode (or if no barmode is set)
barmode = args.get("barmode")
barmode = args.get("barmode") or layout_patch.get("barmode")
if (
trace_spec.constructor in [go.Bar, go.Box, go.Violin, go.Histogram]
and (barmode == "group" or barmode is None)
Expand Down
0