{ "cells": [ { "cell_type": "markdown", "id": "b688f244-c275-48fa-a578-21f84a87e384", "metadata": {}, "source": [ "# Markdown Support\n", "Markdown can be used in titles only and is disabled by default. To enable it, set `element_markdown()` for the appropriate element in `theme()`.\n", "\n", "Currently supported features:\n", "\n", "- Emphasis (`*`, `**`, `***`, `_`, `__`, `___`)\n", "- Coloring with inline style (`text`)\n", "- Links with anchor tags (`Lets-Plot`)\n", "- Multiple lines using double space and a newline delimiter (` \\n`)\n", "\n", "Not supported features:\n", "\n", "- Tag `
` for line splitting\n", "- Links styling\n", "- Links with Markdown syntax (`[Lets-Plot](https://lets-plot.org)`)" ] }, { "cell_type": "code", "execution_count": 1, "id": "8f15dd53-32d7-402b-8d4e-d6f3267f3227", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd\n", "\n", "from lets_plot import *" ] }, { "cell_type": "code", "execution_count": 2, "id": "d6d30a4f-4a19-4f3f-8593-46d690ebbfa6", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "LetsPlot.setup_html()" ] }, { "cell_type": "code", "execution_count": 3, "id": "62e90f3c-3feb-4111-a8d0-b7b8669fc3aa", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(234, 11)\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
manufacturermodeldisplyearcyltransdrvctyhwyflclass
0audia41.819994auto(l5)f1829pcompact
1audia41.819994manual(m5)f2129pcompact
2audia42.020084manual(m6)f2031pcompact
3audia42.020084auto(av)f2130pcompact
4audia42.819996auto(l5)f1626pcompact
\n", "
" ], "text/plain": [ " manufacturer model displ year cyl trans drv cty hwy fl class\n", "0 audi a4 1.8 1999 4 auto(l5) f 18 29 p compact\n", "1 audi a4 1.8 1999 4 manual(m5) f 21 29 p compact\n", "2 audi a4 2.0 2008 4 manual(m6) f 20 31 p compact\n", "3 audi a4 2.0 2008 4 auto(av) f 21 30 p compact\n", "4 audi a4 2.8 1999 6 auto(l5) f 16 26 p compact" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = pd.read_csv(\"https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/mpg.csv\")\n", "df.drop(columns=[\"Unnamed: 0\"], inplace=True)\n", "print(df.shape)\n", "df.head()" ] }, { "cell_type": "code", "execution_count": 4, "id": "e3957a0f-350c-4321-a7a8-791a3d0485d3", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "(ggplot(df) \n", " + geom_point(aes(x='displ', y='cty', color='drv'), size=8) \n", " + scale_color_manual(['#66c2a5', '#fc8d62', '#8da0cb'], guide='none') \n", "\n", " # Enable Markdown in all titles\n", " + theme(title=element_markdown()) \n", "\n", " # Adjust style of title and subtitle\n", " + theme(plot_title=element_text(size=30, family='Georgia', hjust=0.5), \n", " plot_subtitle=element_text(family='Georgia', hjust=0.5)) \n", "\n", " + labs(\n", "\n", " # Span styling, mixing style and emphasis\n", " title=\n", " \"\"\"**Forward**, \"\"\"\n", " \"\"\"**Rear** and \"\"\"\n", " \"\"\"**4WD** Drivetrain\"\"\",\n", "\n", " # Simple emphasis\n", " subtitle='**City milage** *vs* **displacement**', \n", "\n", " # multiline caption, multiline style span, links \n", " caption=\"\"\n", " \"Powered by Lets-Plot. \\n\"\n", " \"Visit the issue tracker for feedback.\" \n", " \"\",\n", "\n", " # Axis titles\n", " x='Displacement (***inches***)',\n", " y='Miles per gallon (***cty***)'\n", " )\n", ")\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.19" } }, "nbformat": 4, "nbformat_minor": 5 }