{ "cells": [ { "cell_type": "markdown", "id": "e9d329de-17b6-4c96-ab89-de1ae475f57c", "metadata": {}, "source": [ "# Absolute Unit Specification for `width` and `height` Aesthetics" ] }, { "cell_type": "markdown", "id": "bbba8dfc-38a5-4bb0-be7c-011843f0ae95", "metadata": {}, "source": [ "Previously, the `width` and `height` aesthetics were limited to relative sizing based on data resolution, which sometimes made it difficult to maintain consistent visual dimensions across different data scales.\n", "\n", "Now multiple geometries also support absolute unit specification for their `width` and `height` aesthetics via the new `widthUnit` and `heightUnit` parameters:\n", "\n", "- `geomErrorBar()`\n", "- `geomCrossbar()`\n", "- `geomBoxplot()`\n", "- `geomTile()`\n", "- `geomHex()`\n", "\n", "Available Units:\n", "\n", "- `\"res\"` (default): Value 1 corresponds to the resolution along the axis - the minimum distance between data points\n", "- `\"identity\"`: Value 1 corresponds to the distance from 0 to 1 on the axis\n", "- `\"size\"`: Value 1 corresponds to the diameter of a point of size 1\n", "- `\"px\"`: Value 1 corresponds to 1 pixel" ] }, { "cell_type": "code", "execution_count": 1, "id": "e2026402-68bf-44c0-a619-89ac6ac857f8", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ " \n", " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "%useLatestDescriptors\n", "%use dataframe\n", "%use lets-plot" ] }, { "cell_type": "code", "execution_count": 2, "id": "749f81fa-c367-4d14-8b46-0823707d6cbb", "metadata": {}, "outputs": [], "source": [ "import kotlin.math.sqrt" ] }, { "cell_type": "code", "execution_count": 3, "id": "ed133625-0d37-4727-bfe0-68870f950b7b", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Lets-Plot Kotlin API v.4.10.0. Frontend: Notebook with dynamically loaded JS. Lets-Plot JS v.4.6.1." ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "LetsPlot.getInfo()" ] }, { "cell_type": "code", "execution_count": 4, "id": "151c0d60-dd59-4251-9b2f-1932eb8c78db", "metadata": {}, "outputs": [ { "data": { "application/kotlindataframe+json": "{\"nrow\":5,\"ncol\":13,\"columns\":[\"untitled\",\"manufacturer\",\"model\",\"displ\",\"year\",\"cyl\",\"trans\",\"drv\",\"cty\",\"hwy\",\"fl\",\"class\",\"trans_type\"],\"kotlin_dataframe\":[{\"untitled\":1,\"manufacturer\":\"audi\",\"model\":\"a4\",\"displ\":1.8,\"year\":1999,\"cyl\":4,\"trans\":\"auto(l5)\",\"drv\":\"f\",\"cty\":18,\"hwy\":29,\"fl\":\"p\",\"class\":\"compact\",\"trans_type\":\"auto\"},{\"untitled\":2,\"manufacturer\":\"audi\",\"model\":\"a4\",\"displ\":1.8,\"year\":1999,\"cyl\":4,\"trans\":\"manual(m5)\",\"drv\":\"f\",\"cty\":21,\"hwy\":29,\"fl\":\"p\",\"class\":\"compact\",\"trans_type\":\"manual\"},{\"untitled\":3,\"manufacturer\":\"audi\",\"model\":\"a4\",\"displ\":2.0,\"year\":2008,\"cyl\":4,\"trans\":\"manual(m6)\",\"drv\":\"f\",\"cty\":20,\"hwy\":31,\"fl\":\"p\",\"class\":\"compact\",\"trans_type\":\"manual\"},{\"untitled\":4,\"manufacturer\":\"audi\",\"model\":\"a4\",\"displ\":2.0,\"year\":2008,\"cyl\":4,\"trans\":\"auto(av)\",\"drv\":\"f\",\"cty\":21,\"hwy\":30,\"fl\":\"p\",\"class\":\"compact\",\"trans_type\":\"auto\"},{\"untitled\":5,\"manufacturer\":\"audi\",\"model\":\"a4\",\"displ\":2.8,\"year\":1999,\"cyl\":6,\"trans\":\"auto(l5)\",\"drv\":\"f\",\"cty\":16,\"hwy\":26,\"fl\":\"p\",\"class\":\"compact\",\"trans_type\":\"auto\"}]}", "text/html": [ " \n", " \n", " \n", " \n", " \n", "DataFrame: rowsCount = 5, columnsCount = 13
\n", "| untitled | manufacturer | model | displ | year | cyl | trans | drv | cty | hwy | fl | class | trans_type |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | audi | a4 | 1.800000 | 1999 | 4 | auto(l5) | f | 18 | 29 | p | compact | auto |
| 2 | audi | a4 | 1.800000 | 1999 | 4 | manual(m5) | f | 21 | 29 | p | compact | manual |
| 3 | audi | a4 | 2.000000 | 2008 | 4 | manual(m6) | f | 20 | 31 | p | compact | manual |
| 4 | audi | a4 | 2.000000 | 2008 | 4 | auto(av) | f | 21 | 30 | p | compact | auto |
| 5 | audi | a4 | 2.800000 | 1999 | 6 | auto(l5) | f | 16 | 26 | p | compact | auto |
DataFrame: rowsCount = 5, columnsCount = 4
\n", "| x | y | v | g |
|---|---|---|---|
| 0.000000 | 0 | 0.730968 | group 0 |
| 0.000000 | 2 | 0.385189 | group 0 |
| 1.000000 | 2 | 0.613036 | group 0 |
| 1.000000 | 4 | 0.705175 | group 0 |
| 2.000000 | 2 | 0.984842 | group 0 |