You can control spacing in multipanel (faceted) plots.
strip_spacing - the gap between the facet strip (title bar) and the plot panel. By default, there is no gap.panel_spacing - the gap between plot panels in both directions (default: 10).strip_spacing_x, strip_spacing_y, panel_spacing_x, panel_spacing_y - directional overrides to control spacing horizontally (suffix _x) or vertically (suffix _y) only.import pandas as pd
from lets_plot import *
LetsPlot.setup_html()
df = pd.read_csv("https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/mpg.csv")
print(df.shape)
df.head()
# Base plot
p = ggplot(df, aes(x="cty", y="hwy")) + \
geom_point(aes(color="class"), shape=21) + \
theme_light() + \
facet_grid(x="cyl", y="year")
p
# Increase the gap between facet strip and panel
p + theme(strip_spacing=10)
# Make panels closer together for a more compact view
p + theme(panel_spacing=3)
# Fine-tune horizontal and vertical spacing independently
p + theme(strip_spacing_y=5, panel_spacing_x=1, panel_spacing_y=5)