seaborn.objects.Dodge#

class seaborn.objects.Dodge(empty='keep', gap=0, by=None)#

Displacement and narrowing of overlapping marks along orientation axis.

Parameters:
empty{‘keep’, ‘drop’, ‘fill’}
gapfloat

Size of gap between dodged marks.

bylist of variable names

Variables to apply the movement to, otherwise use all.

Examples

This transform modifies both the width and position (along the orientation axis) of marks that would otherwise overlap:

(
    so.Plot(tips, "day", color="time")
    .add(so.Bar(), so.Count(), so.Dodge())
)
../_images/objects.Dodge_1_0.png

By default, empty space may appear when variables are not fully crossed:

p = so.Plot(tips, "day", color="time")
p.add(so.Bar(), so.Count(), so.Dodge())
../_images/objects.Dodge_3_0.png

The empty parameter handles this case; use it to fill out the space:

p.add(so.Bar(), so.Count(), so.Dodge(empty="fill"))
../_images/objects.Dodge_5_0.png

Or center the marks while using a consistent width:

p.add(so.Bar(), so.Count(), so.Dodge(empty="drop"))
../_images/objects.Dodge_7_0.png

Use gap to add a bit of spacing between dodged marks:

p = so.Plot(tips, "day", "total_bill", color="sex")
p.add(so.Bar(), so.Agg("sum"), so.Dodge(gap=.1))
../_images/objects.Dodge_9_0.png

When multiple semantic variables are used, each distinct group will be dodged:

p.add(so.Dot(), so.Dodge(), fill="smoker")
../_images/objects.Dodge_11_0.png

Use by to dodge only a subset of variables:

p.add(so.Dot(), so.Dodge(by=["color"]), fill="smoker")
../_images/objects.Dodge_13_0.png

When combining with other transforms (such as Jitter or Stack), be mindful of the order that they are applied in:

p.add(so.Dot(), so.Dodge(), so.Jitter())
../_images/objects.Dodge_15_0.png