plotnine.coords.coord_fixed

class plotnine.coords.coord_fixed(ratio: float = 1, xlim: TupleFloat2 | None = None, ylim: TupleFloat2 | None = None, expand: bool = True)[source]

Cartesian coordinates with fixed relationship between x and y scales

Parameters:
ratiofloat

Desired aspect_ratio (\(y/x\)) of the panel(s). Default is 1.

xlimNone | (float, float)

Limits for x axis. If None, then they are automatically computed.

ylimNone | (float, float)

Limits for y axis. If None, then they are automatically computed.

expandbool

If True, expand the coordinate axes by some factor. If False, use the limits from the data.

Notes

To specify aspect ratio of the visual size for the axes use the aspect_ratio themeable:

ggplot(data, aes('x', 'y')) + theme(aspect_ratio=0.5)

When changing the aspect_ratio in either way, the width of the panel remains constant (as derived from the plotnine.themes.themeable.figure_size themeable) and the height is altered to achieve desired ratio.