Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Commit 2ea22c6

Browse files
more complete *mode support
1 parent e72a8cf commit 2ea22c6

4 files changed

Lines changed: 27 additions & 8 deletions

File tree

gallery.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jupyter:
55
text_representation:
66
extension: .md
77
format_name: markdown
8-
format_version: "1.1"
8+
format_version: '1.1'
99
jupytext_version: 1.1.1
1010
kernelspec:
1111
display_name: Python 3

plotly_express/_chart_types.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ def violin(
267267
color_discrete_sequence=default_qualitative,
268268
color_discrete_map={},
269269
orientation="v",
270+
violinmode="group",
270271
log_x=False,
271272
log_y=False,
272273
range_x=None,
@@ -290,8 +291,10 @@ def violin(
290291
points=points,
291292
box=dict(visible=box),
292293
scalegroup=True,
294+
x0=" ",
295+
y0=" ",
293296
),
294-
layout_patch=dict(violinmode="group"),
297+
layout_patch=dict(violinmode=violinmode),
295298
)
296299

297300

@@ -314,6 +317,7 @@ def box(
314317
color_discrete_sequence=default_qualitative,
315318
color_discrete_map={},
316319
orientation="v",
320+
boxmode="group",
317321
log_x=False,
318322
log_y=False,
319323
range_x=None,
@@ -332,8 +336,10 @@ def box(
332336
return make_figure(
333337
args=locals(),
334338
constructor=go.Box,
335-
trace_patch=dict(orientation=orientation, boxpoints=points, notched=notched),
336-
layout_patch=dict(boxmode="group"),
339+
trace_patch=dict(
340+
orientation=orientation, boxpoints=points, notched=notched, x0=" ", y0=" "
341+
),
342+
layout_patch=dict(boxmode=boxmode),
337343
)
338344

339345

plotly_express/_core.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,6 @@ def configure_cartesian_marginal_axes(args, orders):
286286
layout = dict()
287287
if "histogram" in [args["marginal_x"], args["marginal_y"]]:
288288
layout["barmode"] = "overlay"
289-
if "violin" in [args["marginal_x"], args["marginal_y"]]:
290-
layout["violinmode"] = "overlay"
291289
for letter in ["x", "y"]:
292290
layout[letter + "axis1"] = dict(
293291
title=get_decorated_label(args, args[letter], letter)
@@ -628,7 +626,11 @@ def infer_config(args, constructor, trace_patch):
628626

629627
trace_patch = trace_patch.copy()
630628
if "opacity" in args:
631-
trace_patch["marker"] = dict(opacity=args["opacity"])
629+
if args["opacity"] is None:
630+
if "barmode" in args and args["barmode"] == "overlay":
631+
trace_patch["marker"] = dict(opacity=0.5)
632+
else:
633+
trace_patch["marker"] = dict(opacity=args["opacity"])
632634
if "line_group" in args:
633635
trace_patch["mode"] = "lines" + ("+markers+text" if args["text"] else "")
634636
elif constructor != go.Splom and (

plotly_express/_doc.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,21 @@
268268
"`'percent'` is the same but multiplied by 100 to show percentages.",
269269
],
270270
barmode=[
271-
"(string, one of `'group'` or `'relative'`. Default is `'relative'`)",
271+
"(string, one of `'group'`, `'overlay'` or `'relative'`. Default is `'relative'`)",
272272
"In `'relative'` mode, bars are stacked above zero for positive values and below zero for negative values.",
273+
"In `'overlay'` mode, bars are on drawn top of one another.",
273274
"In `'group'` mode, bars are placed beside each other.",
274275
],
276+
boxmode=[
277+
"(string, one of `'group'` or `'overlay'`. Default is `'group'`)",
278+
"In `'overlay'` mode, boxes are on drawn top of one another.",
279+
"In `'group'` mode, baxes are placed beside each other.",
280+
],
281+
violinmode=[
282+
"(string, one of `'group'` or `'overlay'`. Default is `'group'`)",
283+
"In `'overlay'` mode, violins are on drawn top of one another.",
284+
"In `'group'` mode, violins are placed beside each other.",
285+
],
275286
zoom=["(integer between 0 and 20, default is 8)", "Sets map zoom level."],
276287
orientation=["(string, one of `'h'` or `'v'`)", "Default is `'v'`."],
277288
line_close=[

0 commit comments

Comments
 (0)