{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Formatting labels on plots\n", "\n", "In Lets-Plot you can apply a formatting to:\n", "\n", "- axis break values.\n", "- labels displayed by `geom_text()`.\n", "- tooltip text.\n", "- facet labels.\n", "\n", "Using format string you can format values of numeric and date-time types.\n", "\n", "In addition, you can use a *string template*.\n", "\n", "In *string template* the value's format string is surrounded by curly braces: `\"... {.2f} ...\"`.\n", "\n", "An empty placeholder `{}` is also allowed. In this case a default string representation will be shown. This is also applicable to categorical values.\n", "\n", "See [Formatting](https://lets-plot.org/python/pages/formats.html) documentation page to find information about supported format strings and string templates." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "execution": { "iopub.execute_input": "2026-01-27T17:09:34.322042Z", "iopub.status.busy": "2026-01-27T17:09:34.321978Z", "iopub.status.idle": "2026-01-27T17:09:34.324817Z", "shell.execute_reply": "2026-01-27T17:09:34.324492Z" } }, "outputs": [], "source": [ "import pandas as pd\n", "\n", "from lets_plot import *" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "execution": { "iopub.execute_input": "2026-01-27T17:09:34.325612Z", "iopub.status.busy": "2026-01-27T17:09:34.325542Z", "iopub.status.idle": "2026-01-27T17:09:34.327603Z", "shell.execute_reply": "2026-01-27T17:09:34.327055Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "LetsPlot.setup_html()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### The US Unemployment Rates 2000-2016" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "execution": { "iopub.execute_input": "2026-01-27T17:09:34.340401Z", "iopub.status.busy": "2026-01-27T17:09:34.340311Z", "iopub.status.idle": "2026-01-27T17:09:34.442910Z", "shell.execute_reply": "2026-01-27T17:09:34.442537Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(574, 7)\n" ] }, { "data": { "text/html": [ "| \n", " | Unnamed: 0 | \n", "date | \n", "pce | \n", "pop | \n", "psavert | \n", "uempmed | \n", "unemploy | \n", "
|---|---|---|---|---|---|---|---|
| 0 | \n", "1 | \n", "1967-07-01 | \n", "506.7 | \n", "198712.0 | \n", "12.6 | \n", "4.5 | \n", "2944 | \n", "
| 1 | \n", "2 | \n", "1967-08-01 | \n", "509.8 | \n", "198911.0 | \n", "12.6 | \n", "4.7 | \n", "2945 | \n", "
| 2 | \n", "3 | \n", "1967-09-01 | \n", "515.6 | \n", "199113.0 | \n", "11.9 | \n", "4.6 | \n", "2958 | \n", "
| 3 | \n", "4 | \n", "1967-10-01 | \n", "512.2 | \n", "199311.0 | \n", "12.9 | \n", "4.9 | \n", "3143 | \n", "
| 4 | \n", "5 | \n", "1967-11-01 | \n", "517.4 | \n", "199498.0 | \n", "12.8 | \n", "4.7 | \n", "3066 | \n", "