Markdown support

In [1]:
from lets_plot import *
LetsPlot.setup_html()
In [2]:
p = ggplot() \
    + geom_blank() \
    + labs(title='*Hello*, **world**', subtitle='_Simple plot_', caption='*Powered by **lets-plot***', x='Title **X**', y='Title **Y**') \
    + ggsize(400, 200)

With markdown disabled (default)

In [3]:
p
Out[3]:

Titles with enabled Markdown

In [4]:
p + theme(title=element_markdown())
Out[4]:

Theme parameteres like color and font size are applicable to markdown elements:

In [5]:
p + theme(
    title=element_markdown(),
    axis_title=element_markdown(color='red'),
    plot_caption=element_markdown(color='blue', size=24)
  )
Out[5]:

Style

In [6]:
p \
    + ggtitle('*Hello*, <span style="color:red">**world**</span>!') \
    + theme(title=element_markdown())
Out[6]:

Span style color overrides theme color

In [7]:
p \
    + ggtitle('*Hello*, <span style="color:orange">**orange**</span> and <span style="color:red">***red***</span>!') \
    + theme(title=element_markdown(color='blue'))
Out[7]:

TODO:

LaTeX

In [8]:
p = ggplot() \
    + geom_blank() \
    + ggtitle("***Markdown title*** **\\( a^2 + b^2 = c^2 \\)**") \
    + ggsize(400, 200)

gggrid([
    p, 
    p + theme(plot_title=element_markdown())]) \
    + ggsize(800, 200)
Out[8]:

br

In [9]:
p = ggplot() \
    + geom_blank() \
    + labs(title='*Hello*, <br/> **world**') \
    + theme(title=element_markdown()) \
    + ggsize(400, 200)
p
Out[9]:

Geoms

In [10]:
ggplot() + geom_label(x=0, y=0, label="*Hello*, **world**") + ggsize(400, 200)
Out[10]:
In [11]:
ggplot() \
    + geom_blank() \
    + ggtitle('*Hello*, [**lets-plot**](https://lets-plot.org)!') \
    + theme(title=element_markdown()) \
    + ggsize(400, 200)
Out[11]:

Tooltips

In [12]:
ggplot() \
    + geom_point(x=0, y=0, tooltips=layer_tooltips().line("*Hello*, [**lets-plot**](https://lets-plot.org)!")) \
    + ggsize(400, 200)
Out[12]: