{ "cells": [ { "cell_type": "markdown", "id": "a62d5ff5-858f-43c3-9a76-6b3ed8b5b957", "metadata": {}, "source": [ "# Parameter `size_unit` in Geoms `geom_point()`, `geom_text()` and `geom_label()`\n", "\n", "The `size_unit` parameter relates the size of a geometry to the length of the unit step along one of the axes." ] }, { "cell_type": "code", "execution_count": 1, "id": "6afaa8ff-8714-4575-9458-e3ee4434d1ad", "metadata": {}, "outputs": [], "source": [ "from lets_plot import *" ] }, { "cell_type": "code", "execution_count": 2, "id": "3d059f1c-245f-4690-b6bb-69137c4f3150", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "LetsPlot.setup_html()" ] }, { "cell_type": "code", "execution_count": 3, "id": "b5358334-847f-4f63-8e12-4e5f90ca7403", "metadata": {}, "outputs": [], "source": [ "size = 10\n", "data = {\n", " 'x': [0, 0, 0],\n", " 'y': [-size, 0, size],\n", " 'text': ['A', 'b', '0'],\n", "}" ] }, { "cell_type": "code", "execution_count": 4, "id": "ac3bf8eb-5408-4c3c-818c-375e54a552ec", "metadata": {}, "outputs": [], "source": [ "def title(geom_name, size_unit=None):\n", " if size_unit is None:\n", " size_unit_text = \"size_unit - default\"\n", " else:\n", " size_unit_text = \"size_unit='{0}'\".format(size_unit)\n", " return ggtitle(\"{geom}: size={size}, {size_unit_text}\".format(\n", " geom=geom_name,\n", " size=size,\n", " size_unit_text=size_unit_text\n", " ))" ] }, { "cell_type": "code", "execution_count": 5, "id": "f347dd10-0311-4528-8c7c-a6259b5dca67", "metadata": {}, "outputs": [], "source": [ "p = ggplot(data, aes('x', 'y')) + scale_y_continuous(limits=[-size, size], expand=[.15, 0])" ] }, { "cell_type": "code", "execution_count": 6, "id": "4c561e36-6267-4c09-a095-642db5d51605", "metadata": {}, "outputs": [ { "data": { "text/html": [ " \n", " " ], "text/plain": [ "