from plotnine import ggplot, aes, geom_point, geom_boxplot, theme, element_rect
from plotnine.composition import plot_spacer
from plotnine.data import mtcars
In [1]:
In [2]:
= ggplot(mtcars, aes("wt", "mpg")) + geom_point()
p1 = ggplot(mtcars, aes("wt", "disp")) + geom_point()
p2 = ggplot(mtcars, aes("factor(cyl)", "wt")) + geom_boxplot()
p3
| plot_spacer() | p2 p1
In [3]:
| (p2 / plot_spacer() / p3) p1
Change the color of the space.
In [4]:
| plot_spacer("#FF000022") | p2 p1
Which is the same as
In [5]:
| (plot_spacer() + theme(plot_background=element_rect(fill="#FF000022"))) | p2 p1