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

Displacement and narrowing of overlapping marks along orientation axis.

empty{‘keep’, ‘drop’, ‘fill’}

Size of gap between dodged marks.

bylist of variable names

Variables to apply the movement to, otherwise use all.


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())

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())

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

p.add(so.Bar(), so.Count(), so.Dodge(empty="fill"))

Or center the marks while using a consistent width:

p.add(so.Bar(), so.Count(), so.Dodge(empty="drop"))

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))

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

p.add(so.Dot(), so.Dodge(), fill="smoker")

Use by to dodge only a subset of variables:

p.add(so.Dot(), so.Dodge(by=["color"]), fill="smoker")

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())