Plot Title/Subtitle and Caption Positions

The plot_title_position and plot_caption_position parameters set the alignment of the plot title/subtitle and caption.

A value of "panel" (the default) means that titles/caption are aligned with the plot panel. A value of "plot" means that titles/caption are aligned to the entire plot, excluding margins.

In [1]:
import pandas as pd

from lets_plot import *
In [2]:
LetsPlot.setup_html()
In [3]:
mpg_df = pd.read_csv("https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/mpg.csv")
mpg_df.head(3)
Out[3]:
Unnamed: 0 manufacturer model displ year cyl trans drv cty hwy fl class
0 1 audi a4 1.8 1999 4 auto(l5) f 18 29 p compact
1 2 audi a4 1.8 1999 4 manual(m5) f 21 29 p compact
2 3 audi a4 2.0 2008 4 manual(m6) f 20 31 p compact
In [4]:
p = ggplot(mpg_df) + \
    geom_point(aes(x='displ', y='cty', color='drv')) + \
    labs(title = "Title of the plot",
         subtitle = "Subtitle of the plot",
         caption = "Caption of the plot")

By default titles and caption are aligned with the plot panel:

In [5]:
p
Out[5]:

The position can be set relative to the entire plot using the plot_title_position and plot_caption_position parameters of the theme function:

In [6]:
p + theme(plot_title_position='plot', plot_caption_position='plot')
Out[6]: