{ "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": "2024-08-23T10:40:00.616663Z", "iopub.status.busy": "2024-08-23T10:40:00.616584Z", "iopub.status.idle": "2024-08-23T10:40:00.945753Z", "shell.execute_reply": "2024-08-23T10:40:00.945212Z" } }, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd\n", "\n", "from lets_plot import *" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "execution": { "iopub.execute_input": "2024-08-23T10:40:00.948153Z", "iopub.status.busy": "2024-08-23T10:40:00.947980Z", "iopub.status.idle": "2024-08-23T10:40:00.950553Z", "shell.execute_reply": "2024-08-23T10:40:00.950292Z" } }, "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": "2024-08-23T10:40:00.964785Z", "iopub.status.busy": "2024-08-23T10:40:00.964682Z", "iopub.status.idle": "2024-08-23T10:40:01.120506Z", "shell.execute_reply": "2024-08-23T10:40:01.120137Z" } }, "outputs": [ { "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", "