Plot Margins

plot_margin parameter in theme() allows to change the margin areas of a plot using the margin() function.

In [1]:
import numpy as np

from lets_plot import *
In [2]:
LetsPlot.setup_html()
In [3]:
np.random.seed(42)
data = {'x': np.random.randint(10, size=100)}

p = ggplot(data, aes(x='x')) + geom_bar() + ggtitle("Bar Сhart") + \
    theme(plot_background=element_rect(size = 6))

Plot without Margins

In [4]:
p
Out[4]:

Plot with Margins

In [5]:
p + theme(plot_margin=margin(t=20,  # Top
                             r=10,  # Right
                             b=10,  # Bottom
                             l=10)) # Left      
Out[5]: