{ "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", "
\n", "\n", "

DataFrame: rowsCount = 5, columnsCount = 13

\n", "
untitledmanufacturermodeldisplyearcyltransdrvctyhwyflclasstrans_type
1audia41.80000019994auto(l5)f1829pcompactauto
2audia41.80000019994manual(m5)f2129pcompactmanual
3audia42.00000020084manual(m6)f2031pcompactmanual
4audia42.00000020084auto(av)f2130pcompactauto
5audia42.80000019996auto(l5)f1626pcompactauto
\n", " \n", " \n", " " ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "val df = DataFrame.readCSV(\"https://github.com/JetBrains/lets-plot-docs/raw/refs/heads/master/data/mpg.csv\")\n", " .add(\"trans_type\") { row ->\n", " val trans: String? = row[\"trans\"] as? String\n", " trans?.split(\"(\")?.firstOrNull()\n", " }\n", "val dataMap = df.toMap()\n", "df.head()" ] }, { "cell_type": "markdown", "id": "edb60536-d576-4010-b0e3-4b9b91503080", "metadata": {}, "source": [ "### 1. Uniform Width" ] }, { "cell_type": "markdown", "id": "311cf0c4-0f80-46d4-8cef-fdbce6ea7350", "metadata": {}, "source": [ "Suppose we have the following plot, but we are not satisfied that different facets have different whisker widths:" ] }, { "cell_type": "code", "execution_count": 5, "id": "7f647af8-7e5a-41f7-ae23-ab38776f40d1", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/plot+json": { "apply_color_scheme": true, "output": { "data": { "class": [ "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "midsize", "midsize", "midsize", "suv", "suv", "suv", "suv", "suv", "2seater", "2seater", "2seater", "2seater", "2seater", "suv", "suv", "suv", "suv", "midsize", "midsize", "midsize", "midsize", "midsize", "minivan", "minivan", "minivan", "minivan", "minivan", "minivan", "minivan", "minivan", "minivan", "minivan", "minivan", "pickup", "pickup", "pickup", "pickup", "pickup", "pickup", "pickup", "pickup", "pickup", "suv", "suv", "suv", "suv", "suv", "suv", "suv", "pickup", "pickup", "pickup", "pickup", "pickup", "pickup", "pickup", "pickup", "pickup", "pickup", "suv", "suv", "suv", "suv", "suv", "suv", "suv", "suv", "suv", "pickup", "pickup", "pickup", "pickup", "pickup", "pickup", "pickup", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "midsize", "midsize", "midsize", "midsize", "midsize", "midsize", "midsize", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "suv", "suv", "suv", "suv", "suv", "suv", "suv", "suv", "suv", "suv", "suv", "suv", "suv", "suv", "suv", "suv", "suv", "suv", "suv", "compact", "compact", "midsize", "midsize", "midsize", "midsize", "midsize", "midsize", "midsize", "suv", "suv", "suv", "suv", "midsize", "midsize", "midsize", "midsize", "midsize", "suv", "suv", "suv", "suv", "suv", "suv", "subcompact", "subcompact", "subcompact", "subcompact", "compact", "compact", "compact", "compact", "suv", "suv", "suv", "suv", "suv", "suv", "midsize", "midsize", "midsize", "midsize", "midsize", "midsize", "midsize", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "suv", "suv", "pickup", "pickup", "pickup", "pickup", "pickup", "pickup", "pickup", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "midsize", "midsize", "midsize", "midsize", "midsize", "midsize", "midsize" ], "cty": [ 18, 21, 20, 21, 16, 18, 18, 18, 16, 20, 19, 15, 17, 17, 15, 15, 17, 16, 14, 11, 14, 13, 12, 16, 15, 16, 15, 15, 14, 11, 11, 14, 19, 22, 18, 18, 17, 18, 17, 16, 16, 17, 17, 11, 15, 15, 16, 16, 15, 14, 13, 14, 14, 14, 9, 11, 11, 13, 13, 9, 13, 11, 13, 11, 12, 9, 13, 13, 12, 9, 11, 11, 13, 11, 11, 11, 12, 14, 15, 14, 13, 13, 13, 14, 14, 13, 13, 13, 11, 13, 18, 18, 17, 16, 15, 15, 15, 15, 14, 28, 24, 25, 23, 24, 26, 25, 24, 21, 18, 18, 21, 21, 18, 18, 19, 19, 19, 20, 20, 17, 16, 17, 17, 15, 15, 14, 9, 14, 13, 11, 11, 12, 12, 11, 11, 11, 12, 14, 13, 13, 13, 21, 19, 23, 23, 19, 19, 18, 19, 19, 14, 15, 14, 12, 18, 16, 17, 18, 16, 18, 18, 20, 19, 20, 18, 21, 19, 19, 19, 20, 20, 19, 20, 15, 16, 15, 15, 16, 14, 21, 21, 21, 21, 18, 18, 19, 21, 21, 21, 22, 18, 18, 18, 24, 24, 26, 28, 26, 11, 13, 15, 16, 17, 15, 15, 15, 16, 21, 19, 21, 22, 17, 33, 21, 19, 22, 21, 21, 21, 16, 17, 35, 29, 21, 19, 20, 20, 21, 18, 19, 21, 16, 18, 17 ], "cyl": [ 4, 4, 4, 4, 6, 6, 6, 4, 4, 4, 4, 6, 6, 6, 6, 6, 6, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 4, 4, 6, 6, 6, 4, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 8, 8, 8, 8, 8, 6, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 6, 6, 6, 6, 8, 8, 6, 6, 8, 8, 8, 8, 8, 6, 6, 6, 6, 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 6, 6, 4, 4, 4, 4, 6, 6, 6, 6, 6, 6, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 6, 6, 8, 8, 4, 4, 4, 4, 6, 6, 6, 6, 6, 6, 6, 6, 8, 6, 6, 6, 6, 8, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 6, 6, 8, 4, 4, 4, 4, 6, 6, 6, 4, 4, 4, 4, 6, 6, 6, 4, 4, 4, 4, 4, 8, 8, 4, 4, 4, 6, 6, 6, 6, 4, 4, 4, 4, 6, 4, 4, 4, 4, 4, 5, 5, 6, 6, 4, 4, 4, 4, 5, 5, 4, 4, 4, 4, 6, 6, 6 ], "displ": [ 1.8, 1.8, 2, 2, 2.8, 2.8, 3.1, 1.8, 1.8, 2, 2, 2.8, 2.8, 3.1, 3.1, 2.8, 3.1, 4.2, 5.3, 5.3, 5.3, 5.7, 6, 5.7, 5.7, 6.2, 6.2, 7, 5.3, 5.3, 5.7, 6.5, 2.4, 2.4, 3.1, 3.5, 3.6, 2.4, 3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.8, 3.8, 3.8, 4, 3.7, 3.7, 3.9, 3.9, 4.7, 4.7, 4.7, 5.2, 5.2, 3.9, 4.7, 4.7, 4.7, 5.2, 5.7, 5.9, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 5.2, 5.2, 5.7, 5.9, 4.6, 5.4, 5.4, 4, 4, 4, 4, 4.6, 5, 4.2, 4.2, 4.6, 4.6, 4.6, 5.4, 5.4, 3.8, 3.8, 4, 4, 4.6, 4.6, 4.6, 4.6, 5.4, 1.6, 1.6, 1.6, 1.6, 1.6, 1.8, 1.8, 1.8, 2, 2.4, 2.4, 2.4, 2.4, 2.5, 2.5, 3.3, 2, 2, 2, 2, 2.7, 2.7, 2.7, 3, 3.7, 4, 4.7, 4.7, 4.7, 5.7, 6.1, 4, 4.2, 4.4, 4.6, 5.4, 5.4, 5.4, 4, 4, 4.6, 5, 2.4, 2.4, 2.5, 2.5, 3.5, 3.5, 3, 3, 3.5, 3.3, 3.3, 4, 5.6, 3.1, 3.8, 3.8, 3.8, 5.3, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.2, 2.2, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.7, 2.7, 3.4, 3.4, 4, 4.7, 2.2, 2.2, 2.4, 2.4, 3, 3, 3.5, 2.2, 2.2, 2.4, 2.4, 3, 3, 3.3, 1.8, 1.8, 1.8, 1.8, 1.8, 4.7, 5.7, 2.7, 2.7, 2.7, 3.4, 3.4, 4, 4, 2, 2, 2, 2, 2.8, 1.9, 2, 2, 2, 2, 2.5, 2.5, 2.8, 2.8, 1.9, 1.9, 2, 2, 2.5, 2.5, 1.8, 1.8, 2, 2, 2.8, 2.8, 3.6 ], "drv": [ "f", "f", "f", "f", "f", "f", "f", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "4", "4", "4", "4", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "r", "r", "r", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "r", "r", "r", "r", "r", "r", "r", "r", "r", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "r", "r", "r", "4", "4", "4", "4", "f", "f", "f", "f", "f", "f", "f", "f", "f", "4", "4", "4", "4", "f", "f", "f", "f", "f", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "4", "4", "4", "4", "4", "4", "4", "4", "4", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f" ], "fl": [ "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "r", "e", "r", "r", "r", "p", "p", "p", "p", "p", "r", "e", "r", "d", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "e", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "e", "r", "r", "r", "r", "e", "r", "r", "r", "r", "r", "e", "r", "r", "r", "e", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "p", "r", "r", "r", "p", "r", "r", "r", "c", "p", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "d", "r", "r", "r", "e", "r", "r", "p", "p", "r", "r", "p", "r", "p", "r", "r", "r", "r", "r", "r", "r", "r", "r", "p", "p", "r", "r", "p", "r", "r", "p", "p", "r", "p", "r", "r", "p", "r", "r", "r", "p", "r", "p", "r", "r", "r", "r", "p", "r", "p", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "p", "p", "r", "d", "r", "r", "p", "p", "r", "r", "r", "r", "d", "d", "r", "r", "r", "r", "p", "p", "p", "p", "p", "p", "p" ], "hwy": [ 29, 29, 31, 30, 26, 26, 27, 26, 25, 28, 27, 25, 25, 25, 25, 24, 25, 23, 20, 15, 20, 17, 17, 26, 23, 26, 25, 24, 19, 14, 15, 17, 27, 30, 26, 29, 26, 24, 24, 22, 22, 24, 24, 17, 22, 21, 23, 23, 19, 18, 17, 17, 19, 19, 12, 17, 15, 17, 17, 12, 17, 16, 18, 15, 16, 12, 17, 17, 16, 12, 15, 16, 17, 15, 17, 17, 18, 17, 19, 17, 19, 19, 17, 17, 17, 16, 16, 17, 15, 17, 26, 25, 26, 24, 21, 22, 23, 22, 20, 33, 32, 32, 29, 32, 34, 36, 36, 29, 26, 27, 30, 31, 26, 26, 28, 26, 29, 28, 27, 24, 24, 24, 22, 19, 20, 17, 12, 19, 18, 14, 15, 18, 18, 15, 17, 16, 18, 17, 19, 19, 17, 29, 27, 31, 32, 27, 26, 26, 25, 25, 17, 17, 20, 18, 26, 26, 27, 28, 25, 25, 24, 27, 25, 26, 23, 26, 26, 26, 26, 25, 27, 25, 27, 20, 20, 19, 17, 20, 17, 29, 27, 31, 31, 26, 26, 28, 27, 29, 31, 31, 26, 26, 27, 30, 33, 35, 37, 35, 15, 18, 20, 20, 22, 17, 19, 18, 20, 29, 26, 29, 29, 24, 44, 29, 26, 29, 29, 29, 29, 23, 24, 44, 41, 29, 26, 28, 29, 29, 29, 28, 29, 26, 26, 26 ], "manufacturer": [ "audi", "audi", "audi", "audi", "audi", "audi", "audi", "audi", "audi", "audi", "audi", "audi", "audi", "audi", "audi", "audi", "audi", "audi", "chevrolet", "chevrolet", "chevrolet", "chevrolet", "chevrolet", "chevrolet", "chevrolet", "chevrolet", "chevrolet", "chevrolet", "chevrolet", "chevrolet", "chevrolet", "chevrolet", "chevrolet", "chevrolet", "chevrolet", "chevrolet", "chevrolet", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "honda", "honda", "honda", "honda", "honda", "honda", "honda", "honda", "honda", "hyundai", "hyundai", "hyundai", "hyundai", "hyundai", "hyundai", "hyundai", "hyundai", "hyundai", "hyundai", "hyundai", "hyundai", "hyundai", "hyundai", "jeep", "jeep", "jeep", "jeep", "jeep", "jeep", "jeep", "jeep", "land rover", "land rover", "land rover", "land rover", "lincoln", "lincoln", "lincoln", "mercury", "mercury", "mercury", "mercury", "nissan", "nissan", "nissan", "nissan", "nissan", "nissan", "nissan", "nissan", "nissan", "nissan", "nissan", "nissan", "nissan", "pontiac", "pontiac", "pontiac", "pontiac", "pontiac", "subaru", "subaru", "subaru", "subaru", "subaru", "subaru", "subaru", "subaru", "subaru", "subaru", "subaru", "subaru", "subaru", "subaru", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen" ], "model": [ "a4", "a4", "a4", "a4", "a4", "a4", "a4", "a4 quattro", "a4 quattro", "a4 quattro", "a4 quattro", "a4 quattro", "a4 quattro", "a4 quattro", "a4 quattro", "a6 quattro", "a6 quattro", "a6 quattro", "c1500 suburban 2wd", "c1500 suburban 2wd", "c1500 suburban 2wd", "c1500 suburban 2wd", "c1500 suburban 2wd", "corvette", "corvette", "corvette", "corvette", "corvette", "k1500 tahoe 4wd", "k1500 tahoe 4wd", "k1500 tahoe 4wd", "k1500 tahoe 4wd", "malibu", "malibu", "malibu", "malibu", "malibu", "caravan 2wd", "caravan 2wd", "caravan 2wd", "caravan 2wd", "caravan 2wd", "caravan 2wd", "caravan 2wd", "caravan 2wd", "caravan 2wd", "caravan 2wd", "caravan 2wd", "dakota pickup 4wd", "dakota pickup 4wd", "dakota pickup 4wd", "dakota pickup 4wd", "dakota pickup 4wd", "dakota pickup 4wd", "dakota pickup 4wd", "dakota pickup 4wd", "dakota pickup 4wd", "durango 4wd", "durango 4wd", "durango 4wd", "durango 4wd", "durango 4wd", "durango 4wd", "durango 4wd", "ram 1500 pickup 4wd", "ram 1500 pickup 4wd", "ram 1500 pickup 4wd", "ram 1500 pickup 4wd", "ram 1500 pickup 4wd", "ram 1500 pickup 4wd", "ram 1500 pickup 4wd", "ram 1500 pickup 4wd", "ram 1500 pickup 4wd", "ram 1500 pickup 4wd", "expedition 2wd", "expedition 2wd", "expedition 2wd", "explorer 4wd", "explorer 4wd", "explorer 4wd", "explorer 4wd", "explorer 4wd", "explorer 4wd", "f150 pickup 4wd", "f150 pickup 4wd", "f150 pickup 4wd", "f150 pickup 4wd", "f150 pickup 4wd", "f150 pickup 4wd", "f150 pickup 4wd", "mustang", "mustang", "mustang", "mustang", "mustang", "mustang", "mustang", "mustang", "mustang", "civic", "civic", "civic", "civic", "civic", "civic", "civic", "civic", "civic", "sonata", "sonata", "sonata", "sonata", "sonata", "sonata", "sonata", "tiburon", "tiburon", "tiburon", "tiburon", "tiburon", "tiburon", "tiburon", "grand cherokee 4wd", "grand cherokee 4wd", "grand cherokee 4wd", "grand cherokee 4wd", "grand cherokee 4wd", "grand cherokee 4wd", "grand cherokee 4wd", "grand cherokee 4wd", "range rover", "range rover", "range rover", "range rover", "navigator 2wd", "navigator 2wd", "navigator 2wd", "mountaineer 4wd", "mountaineer 4wd", "mountaineer 4wd", "mountaineer 4wd", "altima", "altima", "altima", "altima", "altima", "altima", "maxima", "maxima", "maxima", "pathfinder 4wd", "pathfinder 4wd", "pathfinder 4wd", "pathfinder 4wd", "grand prix", "grand prix", "grand prix", "grand prix", "grand prix", "forester awd", "forester awd", "forester awd", "forester awd", "forester awd", "forester awd", "impreza awd", "impreza awd", "impreza awd", "impreza awd", "impreza awd", "impreza awd", "impreza awd", "impreza awd", "4runner 4wd", "4runner 4wd", "4runner 4wd", "4runner 4wd", "4runner 4wd", "4runner 4wd", "camry", "camry", "camry", "camry", "camry", "camry", "camry", "camry solara", "camry solara", "camry solara", "camry solara", "camry solara", "camry solara", "camry solara", "corolla", "corolla", "corolla", "corolla", "corolla", "land cruiser wagon 4wd", "land cruiser wagon 4wd", "toyota tacoma 4wd", "toyota tacoma 4wd", "toyota tacoma 4wd", "toyota tacoma 4wd", "toyota tacoma 4wd", "toyota tacoma 4wd", "toyota tacoma 4wd", "gti", "gti", "gti", "gti", "gti", "jetta", "jetta", "jetta", "jetta", "jetta", "jetta", "jetta", "jetta", "jetta", "new beetle", "new beetle", "new beetle", "new beetle", "new beetle", "new beetle", "passat", "passat", "passat", "passat", "passat", "passat", "passat" ], "trans": [ "auto(l5)", "manual(m5)", "manual(m6)", "auto(av)", "auto(l5)", "manual(m5)", "auto(av)", "manual(m5)", "auto(l5)", "manual(m6)", "auto(s6)", "auto(l5)", "manual(m5)", "auto(s6)", "manual(m6)", "auto(l5)", "auto(s6)", "auto(s6)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(l4)", "manual(m6)", "auto(l4)", "manual(m6)", "auto(s6)", "manual(m6)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(s6)", "auto(l3)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(l6)", "auto(l6)", "manual(m6)", "auto(l4)", "auto(l4)", "manual(m5)", "auto(l5)", "auto(l5)", "auto(l5)", "manual(m5)", "auto(l4)", "auto(l4)", "auto(l5)", "auto(l5)", "auto(l5)", "auto(l4)", "auto(l5)", "auto(l4)", "manual(m6)", "auto(l5)", "auto(l5)", "auto(l5)", "manual(m6)", "manual(m6)", "auto(l4)", "manual(m5)", "auto(l5)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(l6)", "auto(l5)", "manual(m5)", "auto(l5)", "auto(l5)", "auto(l6)", "auto(l4)", "auto(l4)", "manual(m5)", "manual(m5)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(l4)", "manual(m5)", "auto(l4)", "manual(m5)", "auto(l5)", "auto(l4)", "manual(m5)", "manual(m5)", "auto(l5)", "manual(m6)", "manual(m5)", "auto(l4)", "manual(m5)", "manual(m5)", "auto(l4)", "manual(m5)", "auto(l5)", "auto(l5)", "manual(m6)", "auto(l4)", "manual(m5)", "auto(l4)", "manual(m5)", "auto(l4)", "manual(m5)", "auto(l5)", "auto(l4)", "manual(m5)", "manual(m5)", "auto(l4)", "auto(l4)", "manual(m6)", "manual(m5)", "auto(l5)", "auto(l5)", "auto(l4)", "auto(l4)", "auto(l5)", "auto(l5)", "auto(l5)", "auto(l5)", "auto(l4)", "auto(s6)", "auto(s6)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(l6)", "auto(l5)", "auto(l5)", "auto(l6)", "auto(l4)", "manual(m5)", "auto(l4)", "auto(av)", "manual(m6)", "manual(m6)", "auto(av)", "auto(l4)", "manual(m5)", "auto(av)", "auto(l4)", "manual(m5)", "auto(l5)", "auto(s5)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(s4)", "manual(m5)", "auto(l4)", "manual(m5)", "manual(m5)", "auto(l4)", "auto(l4)", "auto(l4)", "manual(m5)", "manual(m5)", "auto(l4)", "auto(s4)", "auto(s4)", "manual(m5)", "manual(m5)", "manual(m5)", "auto(l4)", "auto(l4)", "manual(m5)", "auto(l5)", "auto(l5)", "manual(m5)", "auto(l4)", "manual(m5)", "auto(l5)", "auto(l4)", "manual(m5)", "auto(s6)", "auto(l4)", "manual(m5)", "manual(m5)", "auto(s5)", "auto(l4)", "manual(m5)", "auto(s5)", "auto(l3)", "auto(l4)", "manual(m5)", "manual(m5)", "auto(l4)", "auto(l4)", "auto(s6)", "manual(m5)", "auto(l4)", "manual(m5)", "manual(m5)", "auto(l4)", "manual(m6)", "auto(l5)", "manual(m5)", "auto(l4)", "manual(m6)", "auto(s6)", "manual(m5)", "manual(m5)", "manual(m5)", "auto(l4)", "auto(s6)", "manual(m6)", "auto(s6)", "manual(m5)", "auto(l4)", "manual(m5)", "manual(m5)", "auto(l4)", "manual(m5)", "auto(l4)", "manual(m5)", "auto(s6)", "manual(m5)", "auto(l5)", "auto(s6)", "manual(m6)", "auto(l5)", "manual(m5)", "auto(s6)" ], "trans_type": [ "auto", "manual", "manual", "auto", "auto", "manual", "auto", "manual", "auto", "manual", "auto", "auto", "manual", "auto", "manual", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "manual", "auto", "manual", "auto", "manual", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "manual", "auto", "auto", "manual", "auto", "auto", "auto", "manual", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "manual", "auto", "auto", "auto", "manual", "manual", "auto", "manual", "auto", "auto", "auto", "auto", "auto", "auto", "manual", "auto", "auto", "auto", "auto", "auto", "manual", "manual", "auto", "auto", "auto", "auto", "manual", "auto", "manual", "auto", "auto", "manual", "manual", "auto", "manual", "manual", "auto", "manual", "manual", "auto", "manual", "auto", "auto", "manual", "auto", "manual", "auto", "manual", "auto", "manual", "auto", "auto", "manual", "manual", "auto", "auto", "manual", "manual", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "manual", "auto", "auto", "manual", "manual", "auto", "auto", "manual", "auto", "auto", "manual", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "manual", "auto", "manual", "manual", "auto", "auto", "auto", "manual", "manual", "auto", "auto", "auto", "manual", "manual", "manual", "auto", "auto", "manual", "auto", "auto", "manual", "auto", "manual", "auto", "auto", "manual", "auto", "auto", "manual", "manual", "auto", "auto", "manual", "auto", "auto", "auto", "manual", "manual", "auto", "auto", "auto", "manual", "auto", "manual", "manual", "auto", "manual", "auto", "manual", "auto", "manual", "auto", "manual", "manual", "manual", "auto", "auto", "manual", "auto", "manual", "auto", "manual", "manual", "auto", "manual", "auto", "manual", "auto", "manual", "auto", "auto", "manual", "auto", "manual", "auto" ], "untitled": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234 ], "year": [ 1999, 1999, 2008, 2008, 1999, 1999, 2008, 1999, 1999, 2008, 2008, 1999, 1999, 2008, 2008, 1999, 2008, 2008, 2008, 2008, 2008, 1999, 2008, 1999, 1999, 2008, 2008, 2008, 2008, 2008, 1999, 1999, 1999, 2008, 1999, 2008, 2008, 1999, 1999, 1999, 1999, 2008, 2008, 2008, 1999, 1999, 2008, 2008, 2008, 2008, 1999, 1999, 2008, 2008, 2008, 1999, 1999, 1999, 2008, 2008, 2008, 1999, 2008, 1999, 2008, 2008, 2008, 2008, 2008, 2008, 1999, 1999, 2008, 1999, 1999, 1999, 2008, 1999, 1999, 1999, 2008, 2008, 1999, 1999, 1999, 1999, 1999, 2008, 1999, 2008, 1999, 1999, 2008, 2008, 1999, 1999, 2008, 2008, 2008, 1999, 1999, 1999, 1999, 1999, 2008, 2008, 2008, 2008, 1999, 1999, 2008, 2008, 1999, 1999, 2008, 1999, 1999, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 1999, 1999, 2008, 2008, 2008, 2008, 1999, 2008, 2008, 1999, 1999, 1999, 2008, 1999, 2008, 2008, 1999, 1999, 1999, 2008, 2008, 2008, 2008, 1999, 1999, 2008, 1999, 1999, 2008, 2008, 1999, 1999, 1999, 2008, 2008, 1999, 1999, 2008, 2008, 2008, 2008, 1999, 1999, 1999, 1999, 2008, 2008, 2008, 2008, 1999, 1999, 1999, 1999, 2008, 2008, 1999, 1999, 2008, 2008, 1999, 1999, 2008, 1999, 1999, 2008, 2008, 1999, 1999, 2008, 1999, 1999, 1999, 2008, 2008, 1999, 2008, 1999, 1999, 2008, 1999, 1999, 2008, 2008, 1999, 1999, 2008, 2008, 1999, 1999, 1999, 1999, 2008, 2008, 2008, 2008, 1999, 1999, 1999, 1999, 1999, 1999, 2008, 2008, 1999, 1999, 2008, 2008, 1999, 1999, 2008 ] }, "data_meta": { "series_annotations": [ { "column": "untitled", "type": "int" }, { "column": "manufacturer", "type": "str" }, { "column": "model", "type": "str" }, { "column": "displ", "type": "float" }, { "column": "year", "type": "int" }, { "column": "cyl", "type": "int" }, { "column": "trans", "type": "str" }, { "column": "cty", "type": "int" }, { "column": "hwy", "type": "int" }, { "column": "class", "type": "str" }, { "column": "trans_type", "type": "str" } ] }, "facet": { "name": "grid", "scales": "free_x", "x": "year", "x_order": 1, "y_order": 1 }, "kind": "plot", "layers": [ { "data_meta": { "mapping_annotations": [ { "aes": "x", "annotation": "as_discrete", "parameters": { "label": "trans", "order": 1 } } ] }, "geom": "errorbar", "mapping": { "color": "trans_type", "x": "trans", "y": "hwy" }, "position": "identity", "size": 1, "stat": "summary", "width": 0.5 } ], "mapping": {}, "scales": [] }, "output_type": "lets_plot_spec", "swing_enabled": true }, "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " auto(l3)\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " auto(l4)\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " auto(l5)\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " manual(m5)\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " manual(m6)\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 15\n", " \n", " \n", " \n", " \n", " \n", " \n", " 20\n", " \n", " \n", " \n", " \n", " \n", " \n", " 25\n", " \n", " \n", " \n", " \n", " \n", " \n", " 30\n", " \n", " \n", " \n", " \n", " \n", " \n", " 35\n", " \n", " \n", " \n", " \n", " \n", " \n", " 40\n", " \n", " \n", " \n", " \n", " \n", " \n", " 45\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 1999.0\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", " \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", " auto(av)\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " auto(l4)\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " auto(l5)\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " auto(l6)\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " auto(s4)\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " auto(s5)\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " auto(s6)\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " manual(m5)\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " manual(m6)\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 2008.0\n", " \n", " \n", " \n", " \n", " \n", " hwy\n", " \n", " \n", " \n", " \n", " trans\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " trans_type\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " auto\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " manual\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", " " ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "letsPlot(dataMap) +\n", " geomErrorBar(stat = Stat.summary(), size = 1, width = .5)\n", " { x = asDiscrete(\"trans\", order = 1); y = \"hwy\"; color = \"trans_type\" } +\n", " facetGrid(x = \"year\", scales = \"free_x\")" ] }, { "cell_type": "markdown", "id": "2ffd450e-1b99-400c-b14b-b0bc6e6f0b96", "metadata": {}, "source": [ "We can make the widths uniform by setting the absolute unit of measurement for them. For example, in pixels:" ] }, { "cell_type": "code", "execution_count": 6, "id": "1cb17475-f00b-4446-ab51-9f29be18de4b", "metadata": {}, "outputs": [ { "data": { "application/plot+json": { "apply_color_scheme": true, "output": { "data": { "class": [ "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "midsize", "midsize", "midsize", "suv", "suv", "suv", "suv", "suv", "2seater", "2seater", "2seater", "2seater", "2seater", "suv", "suv", "suv", "suv", "midsize", "midsize", "midsize", "midsize", "midsize", "minivan", "minivan", "minivan", "minivan", "minivan", "minivan", "minivan", "minivan", "minivan", "minivan", "minivan", "pickup", "pickup", "pickup", "pickup", "pickup", "pickup", "pickup", "pickup", "pickup", "suv", "suv", "suv", "suv", "suv", "suv", "suv", "pickup", "pickup", "pickup", "pickup", "pickup", "pickup", "pickup", "pickup", "pickup", "pickup", "suv", "suv", "suv", "suv", "suv", "suv", "suv", "suv", "suv", "pickup", "pickup", "pickup", "pickup", "pickup", "pickup", "pickup", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "midsize", "midsize", "midsize", "midsize", "midsize", "midsize", "midsize", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "suv", "suv", "suv", "suv", "suv", "suv", "suv", "suv", "suv", "suv", "suv", "suv", "suv", "suv", "suv", "suv", "suv", "suv", "suv", "compact", "compact", "midsize", "midsize", "midsize", "midsize", "midsize", "midsize", "midsize", "suv", "suv", "suv", "suv", "midsize", "midsize", "midsize", "midsize", "midsize", "suv", "suv", "suv", "suv", "suv", "suv", "subcompact", "subcompact", "subcompact", "subcompact", "compact", "compact", "compact", "compact", "suv", "suv", "suv", "suv", "suv", "suv", "midsize", "midsize", "midsize", "midsize", "midsize", "midsize", "midsize", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "suv", "suv", "pickup", "pickup", "pickup", "pickup", "pickup", "pickup", "pickup", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "compact", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "subcompact", "midsize", "midsize", "midsize", "midsize", "midsize", "midsize", "midsize" ], "cty": [ 18, 21, 20, 21, 16, 18, 18, 18, 16, 20, 19, 15, 17, 17, 15, 15, 17, 16, 14, 11, 14, 13, 12, 16, 15, 16, 15, 15, 14, 11, 11, 14, 19, 22, 18, 18, 17, 18, 17, 16, 16, 17, 17, 11, 15, 15, 16, 16, 15, 14, 13, 14, 14, 14, 9, 11, 11, 13, 13, 9, 13, 11, 13, 11, 12, 9, 13, 13, 12, 9, 11, 11, 13, 11, 11, 11, 12, 14, 15, 14, 13, 13, 13, 14, 14, 13, 13, 13, 11, 13, 18, 18, 17, 16, 15, 15, 15, 15, 14, 28, 24, 25, 23, 24, 26, 25, 24, 21, 18, 18, 21, 21, 18, 18, 19, 19, 19, 20, 20, 17, 16, 17, 17, 15, 15, 14, 9, 14, 13, 11, 11, 12, 12, 11, 11, 11, 12, 14, 13, 13, 13, 21, 19, 23, 23, 19, 19, 18, 19, 19, 14, 15, 14, 12, 18, 16, 17, 18, 16, 18, 18, 20, 19, 20, 18, 21, 19, 19, 19, 20, 20, 19, 20, 15, 16, 15, 15, 16, 14, 21, 21, 21, 21, 18, 18, 19, 21, 21, 21, 22, 18, 18, 18, 24, 24, 26, 28, 26, 11, 13, 15, 16, 17, 15, 15, 15, 16, 21, 19, 21, 22, 17, 33, 21, 19, 22, 21, 21, 21, 16, 17, 35, 29, 21, 19, 20, 20, 21, 18, 19, 21, 16, 18, 17 ], "cyl": [ 4, 4, 4, 4, 6, 6, 6, 4, 4, 4, 4, 6, 6, 6, 6, 6, 6, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 4, 4, 6, 6, 6, 4, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 8, 8, 8, 8, 8, 6, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 6, 6, 6, 6, 8, 8, 6, 6, 8, 8, 8, 8, 8, 6, 6, 6, 6, 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 6, 6, 4, 4, 4, 4, 6, 6, 6, 6, 6, 6, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 6, 6, 8, 8, 4, 4, 4, 4, 6, 6, 6, 6, 6, 6, 6, 6, 8, 6, 6, 6, 6, 8, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 6, 6, 8, 4, 4, 4, 4, 6, 6, 6, 4, 4, 4, 4, 6, 6, 6, 4, 4, 4, 4, 4, 8, 8, 4, 4, 4, 6, 6, 6, 6, 4, 4, 4, 4, 6, 4, 4, 4, 4, 4, 5, 5, 6, 6, 4, 4, 4, 4, 5, 5, 4, 4, 4, 4, 6, 6, 6 ], "displ": [ 1.8, 1.8, 2, 2, 2.8, 2.8, 3.1, 1.8, 1.8, 2, 2, 2.8, 2.8, 3.1, 3.1, 2.8, 3.1, 4.2, 5.3, 5.3, 5.3, 5.7, 6, 5.7, 5.7, 6.2, 6.2, 7, 5.3, 5.3, 5.7, 6.5, 2.4, 2.4, 3.1, 3.5, 3.6, 2.4, 3, 3.3, 3.3, 3.3, 3.3, 3.3, 3.8, 3.8, 3.8, 4, 3.7, 3.7, 3.9, 3.9, 4.7, 4.7, 4.7, 5.2, 5.2, 3.9, 4.7, 4.7, 4.7, 5.2, 5.7, 5.9, 4.7, 4.7, 4.7, 4.7, 4.7, 4.7, 5.2, 5.2, 5.7, 5.9, 4.6, 5.4, 5.4, 4, 4, 4, 4, 4.6, 5, 4.2, 4.2, 4.6, 4.6, 4.6, 5.4, 5.4, 3.8, 3.8, 4, 4, 4.6, 4.6, 4.6, 4.6, 5.4, 1.6, 1.6, 1.6, 1.6, 1.6, 1.8, 1.8, 1.8, 2, 2.4, 2.4, 2.4, 2.4, 2.5, 2.5, 3.3, 2, 2, 2, 2, 2.7, 2.7, 2.7, 3, 3.7, 4, 4.7, 4.7, 4.7, 5.7, 6.1, 4, 4.2, 4.4, 4.6, 5.4, 5.4, 5.4, 4, 4, 4.6, 5, 2.4, 2.4, 2.5, 2.5, 3.5, 3.5, 3, 3, 3.5, 3.3, 3.3, 4, 5.6, 3.1, 3.8, 3.8, 3.8, 5.3, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.2, 2.2, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.7, 2.7, 3.4, 3.4, 4, 4.7, 2.2, 2.2, 2.4, 2.4, 3, 3, 3.5, 2.2, 2.2, 2.4, 2.4, 3, 3, 3.3, 1.8, 1.8, 1.8, 1.8, 1.8, 4.7, 5.7, 2.7, 2.7, 2.7, 3.4, 3.4, 4, 4, 2, 2, 2, 2, 2.8, 1.9, 2, 2, 2, 2, 2.5, 2.5, 2.8, 2.8, 1.9, 1.9, 2, 2, 2.5, 2.5, 1.8, 1.8, 2, 2, 2.8, 2.8, 3.6 ], "drv": [ "f", "f", "f", "f", "f", "f", "f", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "4", "4", "4", "4", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "r", "r", "r", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "r", "r", "r", "r", "r", "r", "r", "r", "r", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "r", "r", "r", "4", "4", "4", "4", "f", "f", "f", "f", "f", "f", "f", "f", "f", "4", "4", "4", "4", "f", "f", "f", "f", "f", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "4", "4", "4", "4", "4", "4", "4", "4", "4", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f" ], "fl": [ "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "r", "e", "r", "r", "r", "p", "p", "p", "p", "p", "r", "e", "r", "d", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "e", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "e", "r", "r", "r", "r", "e", "r", "r", "r", "r", "r", "e", "r", "r", "r", "e", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "p", "r", "r", "r", "p", "r", "r", "r", "c", "p", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "d", "r", "r", "r", "e", "r", "r", "p", "p", "r", "r", "p", "r", "p", "r", "r", "r", "r", "r", "r", "r", "r", "r", "p", "p", "r", "r", "p", "r", "r", "p", "p", "r", "p", "r", "r", "p", "r", "r", "r", "p", "r", "p", "r", "r", "r", "r", "p", "r", "p", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "r", "p", "p", "r", "d", "r", "r", "p", "p", "r", "r", "r", "r", "d", "d", "r", "r", "r", "r", "p", "p", "p", "p", "p", "p", "p" ], "hwy": [ 29, 29, 31, 30, 26, 26, 27, 26, 25, 28, 27, 25, 25, 25, 25, 24, 25, 23, 20, 15, 20, 17, 17, 26, 23, 26, 25, 24, 19, 14, 15, 17, 27, 30, 26, 29, 26, 24, 24, 22, 22, 24, 24, 17, 22, 21, 23, 23, 19, 18, 17, 17, 19, 19, 12, 17, 15, 17, 17, 12, 17, 16, 18, 15, 16, 12, 17, 17, 16, 12, 15, 16, 17, 15, 17, 17, 18, 17, 19, 17, 19, 19, 17, 17, 17, 16, 16, 17, 15, 17, 26, 25, 26, 24, 21, 22, 23, 22, 20, 33, 32, 32, 29, 32, 34, 36, 36, 29, 26, 27, 30, 31, 26, 26, 28, 26, 29, 28, 27, 24, 24, 24, 22, 19, 20, 17, 12, 19, 18, 14, 15, 18, 18, 15, 17, 16, 18, 17, 19, 19, 17, 29, 27, 31, 32, 27, 26, 26, 25, 25, 17, 17, 20, 18, 26, 26, 27, 28, 25, 25, 24, 27, 25, 26, 23, 26, 26, 26, 26, 25, 27, 25, 27, 20, 20, 19, 17, 20, 17, 29, 27, 31, 31, 26, 26, 28, 27, 29, 31, 31, 26, 26, 27, 30, 33, 35, 37, 35, 15, 18, 20, 20, 22, 17, 19, 18, 20, 29, 26, 29, 29, 24, 44, 29, 26, 29, 29, 29, 29, 23, 24, 44, 41, 29, 26, 28, 29, 29, 29, 28, 29, 26, 26, 26 ], "manufacturer": [ "audi", "audi", "audi", "audi", "audi", "audi", "audi", "audi", "audi", "audi", "audi", "audi", "audi", "audi", "audi", "audi", "audi", "audi", "chevrolet", "chevrolet", "chevrolet", "chevrolet", "chevrolet", "chevrolet", "chevrolet", "chevrolet", "chevrolet", "chevrolet", "chevrolet", "chevrolet", "chevrolet", "chevrolet", "chevrolet", "chevrolet", "chevrolet", "chevrolet", "chevrolet", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "dodge", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "ford", "honda", "honda", "honda", "honda", "honda", "honda", "honda", "honda", "honda", "hyundai", "hyundai", "hyundai", "hyundai", "hyundai", "hyundai", "hyundai", "hyundai", "hyundai", "hyundai", "hyundai", "hyundai", "hyundai", "hyundai", "jeep", "jeep", "jeep", "jeep", "jeep", "jeep", "jeep", "jeep", "land rover", "land rover", "land rover", "land rover", "lincoln", "lincoln", "lincoln", "mercury", "mercury", "mercury", "mercury", "nissan", "nissan", "nissan", "nissan", "nissan", "nissan", "nissan", "nissan", "nissan", "nissan", "nissan", "nissan", "nissan", "pontiac", "pontiac", "pontiac", "pontiac", "pontiac", "subaru", "subaru", "subaru", "subaru", "subaru", "subaru", "subaru", "subaru", "subaru", "subaru", "subaru", "subaru", "subaru", "subaru", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "toyota", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen", "volkswagen" ], "model": [ "a4", "a4", "a4", "a4", "a4", "a4", "a4", "a4 quattro", "a4 quattro", "a4 quattro", "a4 quattro", "a4 quattro", "a4 quattro", "a4 quattro", "a4 quattro", "a6 quattro", "a6 quattro", "a6 quattro", "c1500 suburban 2wd", "c1500 suburban 2wd", "c1500 suburban 2wd", "c1500 suburban 2wd", "c1500 suburban 2wd", "corvette", "corvette", "corvette", "corvette", "corvette", "k1500 tahoe 4wd", "k1500 tahoe 4wd", "k1500 tahoe 4wd", "k1500 tahoe 4wd", "malibu", "malibu", "malibu", "malibu", "malibu", "caravan 2wd", "caravan 2wd", "caravan 2wd", "caravan 2wd", "caravan 2wd", "caravan 2wd", "caravan 2wd", "caravan 2wd", "caravan 2wd", "caravan 2wd", "caravan 2wd", "dakota pickup 4wd", "dakota pickup 4wd", "dakota pickup 4wd", "dakota pickup 4wd", "dakota pickup 4wd", "dakota pickup 4wd", "dakota pickup 4wd", "dakota pickup 4wd", "dakota pickup 4wd", "durango 4wd", "durango 4wd", "durango 4wd", "durango 4wd", "durango 4wd", "durango 4wd", "durango 4wd", "ram 1500 pickup 4wd", "ram 1500 pickup 4wd", "ram 1500 pickup 4wd", "ram 1500 pickup 4wd", "ram 1500 pickup 4wd", "ram 1500 pickup 4wd", "ram 1500 pickup 4wd", "ram 1500 pickup 4wd", "ram 1500 pickup 4wd", "ram 1500 pickup 4wd", "expedition 2wd", "expedition 2wd", "expedition 2wd", "explorer 4wd", "explorer 4wd", "explorer 4wd", "explorer 4wd", "explorer 4wd", "explorer 4wd", "f150 pickup 4wd", "f150 pickup 4wd", "f150 pickup 4wd", "f150 pickup 4wd", "f150 pickup 4wd", "f150 pickup 4wd", "f150 pickup 4wd", "mustang", "mustang", "mustang", "mustang", "mustang", "mustang", "mustang", "mustang", "mustang", "civic", "civic", "civic", "civic", "civic", "civic", "civic", "civic", "civic", "sonata", "sonata", "sonata", "sonata", "sonata", "sonata", "sonata", "tiburon", "tiburon", "tiburon", "tiburon", "tiburon", "tiburon", "tiburon", "grand cherokee 4wd", "grand cherokee 4wd", "grand cherokee 4wd", "grand cherokee 4wd", "grand cherokee 4wd", "grand cherokee 4wd", "grand cherokee 4wd", "grand cherokee 4wd", "range rover", "range rover", "range rover", "range rover", "navigator 2wd", "navigator 2wd", "navigator 2wd", "mountaineer 4wd", "mountaineer 4wd", "mountaineer 4wd", "mountaineer 4wd", "altima", "altima", "altima", "altima", "altima", "altima", "maxima", "maxima", "maxima", "pathfinder 4wd", "pathfinder 4wd", "pathfinder 4wd", "pathfinder 4wd", "grand prix", "grand prix", "grand prix", "grand prix", "grand prix", "forester awd", "forester awd", "forester awd", "forester awd", "forester awd", "forester awd", "impreza awd", "impreza awd", "impreza awd", "impreza awd", "impreza awd", "impreza awd", "impreza awd", "impreza awd", "4runner 4wd", "4runner 4wd", "4runner 4wd", "4runner 4wd", "4runner 4wd", "4runner 4wd", "camry", "camry", "camry", "camry", "camry", "camry", "camry", "camry solara", "camry solara", "camry solara", "camry solara", "camry solara", "camry solara", "camry solara", "corolla", "corolla", "corolla", "corolla", "corolla", "land cruiser wagon 4wd", "land cruiser wagon 4wd", "toyota tacoma 4wd", "toyota tacoma 4wd", "toyota tacoma 4wd", "toyota tacoma 4wd", "toyota tacoma 4wd", "toyota tacoma 4wd", "toyota tacoma 4wd", "gti", "gti", "gti", "gti", "gti", "jetta", "jetta", "jetta", "jetta", "jetta", "jetta", "jetta", "jetta", "jetta", "new beetle", "new beetle", "new beetle", "new beetle", "new beetle", "new beetle", "passat", "passat", "passat", "passat", "passat", "passat", "passat" ], "trans": [ "auto(l5)", "manual(m5)", "manual(m6)", "auto(av)", "auto(l5)", "manual(m5)", "auto(av)", "manual(m5)", "auto(l5)", "manual(m6)", "auto(s6)", "auto(l5)", "manual(m5)", "auto(s6)", "manual(m6)", "auto(l5)", "auto(s6)", "auto(s6)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(l4)", "manual(m6)", "auto(l4)", "manual(m6)", "auto(s6)", "manual(m6)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(s6)", "auto(l3)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(l6)", "auto(l6)", "manual(m6)", "auto(l4)", "auto(l4)", "manual(m5)", "auto(l5)", "auto(l5)", "auto(l5)", "manual(m5)", "auto(l4)", "auto(l4)", "auto(l5)", "auto(l5)", "auto(l5)", "auto(l4)", "auto(l5)", "auto(l4)", "manual(m6)", "auto(l5)", "auto(l5)", "auto(l5)", "manual(m6)", "manual(m6)", "auto(l4)", "manual(m5)", "auto(l5)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(l6)", "auto(l5)", "manual(m5)", "auto(l5)", "auto(l5)", "auto(l6)", "auto(l4)", "auto(l4)", "manual(m5)", "manual(m5)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(l4)", "manual(m5)", "auto(l4)", "manual(m5)", "auto(l5)", "auto(l4)", "manual(m5)", "manual(m5)", "auto(l5)", "manual(m6)", "manual(m5)", "auto(l4)", "manual(m5)", "manual(m5)", "auto(l4)", "manual(m5)", "auto(l5)", "auto(l5)", "manual(m6)", "auto(l4)", "manual(m5)", "auto(l4)", "manual(m5)", "auto(l4)", "manual(m5)", "auto(l5)", "auto(l4)", "manual(m5)", "manual(m5)", "auto(l4)", "auto(l4)", "manual(m6)", "manual(m5)", "auto(l5)", "auto(l5)", "auto(l4)", "auto(l4)", "auto(l5)", "auto(l5)", "auto(l5)", "auto(l5)", "auto(l4)", "auto(s6)", "auto(s6)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(l6)", "auto(l5)", "auto(l5)", "auto(l6)", "auto(l4)", "manual(m5)", "auto(l4)", "auto(av)", "manual(m6)", "manual(m6)", "auto(av)", "auto(l4)", "manual(m5)", "auto(av)", "auto(l4)", "manual(m5)", "auto(l5)", "auto(s5)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(l4)", "auto(s4)", "manual(m5)", "auto(l4)", "manual(m5)", "manual(m5)", "auto(l4)", "auto(l4)", "auto(l4)", "manual(m5)", "manual(m5)", "auto(l4)", "auto(s4)", "auto(s4)", "manual(m5)", "manual(m5)", "manual(m5)", "auto(l4)", "auto(l4)", "manual(m5)", "auto(l5)", "auto(l5)", "manual(m5)", "auto(l4)", "manual(m5)", "auto(l5)", "auto(l4)", "manual(m5)", "auto(s6)", "auto(l4)", "manual(m5)", "manual(m5)", "auto(s5)", "auto(l4)", "manual(m5)", "auto(s5)", "auto(l3)", "auto(l4)", "manual(m5)", "manual(m5)", "auto(l4)", "auto(l4)", "auto(s6)", "manual(m5)", "auto(l4)", "manual(m5)", "manual(m5)", "auto(l4)", "manual(m6)", "auto(l5)", "manual(m5)", "auto(l4)", "manual(m6)", "auto(s6)", "manual(m5)", "manual(m5)", "manual(m5)", "auto(l4)", "auto(s6)", "manual(m6)", "auto(s6)", "manual(m5)", "auto(l4)", "manual(m5)", "manual(m5)", "auto(l4)", "manual(m5)", "auto(l4)", "manual(m5)", "auto(s6)", "manual(m5)", "auto(l5)", "auto(s6)", "manual(m6)", "auto(l5)", "manual(m5)", "auto(s6)" ], "trans_type": [ "auto", "manual", "manual", "auto", "auto", "manual", "auto", "manual", "auto", "manual", "auto", "auto", "manual", "auto", "manual", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "manual", "auto", "manual", "auto", "manual", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "manual", "auto", "auto", "manual", "auto", "auto", "auto", "manual", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "manual", "auto", "auto", "auto", "manual", "manual", "auto", "manual", "auto", "auto", "auto", "auto", "auto", "auto", "manual", "auto", "auto", "auto", "auto", "auto", "manual", "manual", "auto", "auto", "auto", "auto", "manual", "auto", "manual", "auto", "auto", "manual", "manual", "auto", "manual", "manual", "auto", "manual", "manual", "auto", "manual", "auto", "auto", "manual", "auto", "manual", "auto", "manual", "auto", "manual", "auto", "auto", "manual", "manual", "auto", "auto", "manual", "manual", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "manual", "auto", "auto", "manual", "manual", "auto", "auto", "manual", "auto", "auto", "manual", "auto", "auto", "auto", "auto", "auto", "auto", "auto", "manual", "auto", "manual", "manual", "auto", "auto", "auto", "manual", "manual", "auto", "auto", "auto", "manual", "manual", "manual", "auto", "auto", "manual", "auto", "auto", "manual", "auto", "manual", "auto", "auto", "manual", "auto", "auto", "manual", "manual", "auto", "auto", "manual", "auto", "auto", "auto", "manual", "manual", "auto", "auto", "auto", "manual", "auto", "manual", "manual", "auto", "manual", "auto", "manual", "auto", "manual", "auto", "manual", "manual", "manual", "auto", "auto", "manual", "auto", "manual", "auto", "manual", "manual", "auto", "manual", "auto", "manual", "auto", "manual", "auto", "auto", "manual", "auto", "manual", "auto" ], "untitled": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234 ], "year": [ 1999, 1999, 2008, 2008, 1999, 1999, 2008, 1999, 1999, 2008, 2008, 1999, 1999, 2008, 2008, 1999, 2008, 2008, 2008, 2008, 2008, 1999, 2008, 1999, 1999, 2008, 2008, 2008, 2008, 2008, 1999, 1999, 1999, 2008, 1999, 2008, 2008, 1999, 1999, 1999, 1999, 2008, 2008, 2008, 1999, 1999, 2008, 2008, 2008, 2008, 1999, 1999, 2008, 2008, 2008, 1999, 1999, 1999, 2008, 2008, 2008, 1999, 2008, 1999, 2008, 2008, 2008, 2008, 2008, 2008, 1999, 1999, 2008, 1999, 1999, 1999, 2008, 1999, 1999, 1999, 2008, 2008, 1999, 1999, 1999, 1999, 1999, 2008, 1999, 2008, 1999, 1999, 2008, 2008, 1999, 1999, 2008, 2008, 2008, 1999, 1999, 1999, 1999, 1999, 2008, 2008, 2008, 2008, 1999, 1999, 2008, 2008, 1999, 1999, 2008, 1999, 1999, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 1999, 1999, 2008, 2008, 2008, 2008, 1999, 2008, 2008, 1999, 1999, 1999, 2008, 1999, 2008, 2008, 1999, 1999, 1999, 2008, 2008, 2008, 2008, 1999, 1999, 2008, 1999, 1999, 2008, 2008, 1999, 1999, 1999, 2008, 2008, 1999, 1999, 2008, 2008, 2008, 2008, 1999, 1999, 1999, 1999, 2008, 2008, 2008, 2008, 1999, 1999, 1999, 1999, 2008, 2008, 1999, 1999, 2008, 2008, 1999, 1999, 2008, 1999, 1999, 2008, 2008, 1999, 1999, 2008, 1999, 1999, 1999, 2008, 2008, 1999, 2008, 1999, 1999, 2008, 1999, 1999, 2008, 2008, 1999, 1999, 2008, 2008, 1999, 1999, 1999, 1999, 2008, 2008, 2008, 2008, 1999, 1999, 1999, 1999, 1999, 1999, 2008, 2008, 1999, 1999, 2008, 2008, 1999, 1999, 2008 ] }, "data_meta": { "series_annotations": [ { "column": "untitled", "type": "int" }, { "column": "manufacturer", "type": "str" }, { "column": "model", "type": "str" }, { "column": "displ", "type": "float" }, { "column": "year", "type": "int" }, { "column": "cyl", "type": "int" }, { "column": "trans", "type": "str" }, { "column": "cty", "type": "int" }, { "column": "hwy", "type": "int" }, { "column": "class", "type": "str" }, { "column": "trans_type", "type": "str" } ] }, "facet": { "name": "grid", "scales": "free_x", "x": "year", "x_order": 1, "y_order": 1 }, "kind": "plot", "layers": [ { "data_meta": { "mapping_annotations": [ { "aes": "x", "annotation": "as_discrete", "parameters": { "label": "trans", "order": 1 } } ] }, "geom": "errorbar", "mapping": { "color": "trans_type", "x": "trans", "y": "hwy" }, "position": "identity", "size": 1, "stat": "summary", "width": 10, "width_unit": "px" } ], "mapping": {}, "scales": [] }, "output_type": "lets_plot_spec", "swing_enabled": true }, "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " auto(l3)\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " auto(l4)\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " auto(l5)\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " manual(m5)\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " manual(m6)\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 15\n", " \n", " \n", " \n", " \n", " \n", " \n", " 20\n", " \n", " \n", " \n", " \n", " \n", " \n", " 25\n", " \n", " \n", " \n", " \n", " \n", " \n", " 30\n", " \n", " \n", " \n", " \n", " \n", " \n", " 35\n", " \n", " \n", " \n", " \n", " \n", " \n", " 40\n", " \n", " \n", " \n", " \n", " \n", " \n", " 45\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 1999.0\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", " \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", " auto(av)\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " auto(l4)\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " auto(l5)\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " auto(l6)\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " auto(s4)\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " auto(s5)\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " auto(s6)\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " manual(m5)\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " manual(m6)\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 2008.0\n", " \n", " \n", " \n", " \n", " \n", " hwy\n", " \n", " \n", " \n", " \n", " trans\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " trans_type\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " auto\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " manual\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", " " ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "letsPlot(dataMap) +\n", " geomErrorBar(stat = Stat.summary(), size = 1,\n", " width = 10, // <-- set width - 10 px\n", " widthUnit = \"px\")\n", " { x = asDiscrete(\"trans\", order = 1); y = \"hwy\"; color = \"trans_type\" } +\n", " facetGrid(x = \"year\", scales = \"free_x\")" ] }, { "cell_type": "markdown", "id": "95a6eb65-4816-4992-824f-2463cbec7ad9", "metadata": {}, "source": [ "### 2. Matching 2D Grid" ] }, { "cell_type": "markdown", "id": "55cbada0-8ece-427e-806d-d501acbc5cd5", "metadata": {}, "source": [ "When using `geomHex()` with the `Stat.identity`, you must prepare the data yourself to fit into a hexagonal grid.\n", "\n", "Let's assume you have prepared the following dataset:" ] }, { "cell_type": "code", "execution_count": 7, "id": "dc1033c3-55a6-452b-8c11-04d46835086d", "metadata": {}, "outputs": [ { "data": { "application/kotlindataframe+json": "{\"nrow\":5,\"ncol\":4,\"columns\":[\"x\",\"y\",\"v\",\"g\"],\"kotlin_dataframe\":[{\"x\":0.0,\"y\":0,\"v\":0.73096776,\"g\":\"group 0\"},{\"x\":0.0,\"y\":2,\"v\":0.38518918,\"g\":\"group 0\"},{\"x\":1.0,\"y\":2,\"v\":0.61303574,\"g\":\"group 0\"},{\"x\":1.0,\"y\":4,\"v\":0.70517474,\"g\":\"group 0\"},{\"x\":2.0,\"y\":2,\"v\":0.9848415,\"g\":\"group 0\"}]}", "text/html": [ " \n", " \n", " \n", " \n", " \n", "
\n", "\n", "

DataFrame: rowsCount = 5, columnsCount = 4

\n", "
xyvg
0.00000000.730968group 0
0.00000020.385189group 0
1.00000020.613036group 0
1.00000040.705175group 0
2.00000020.984842group 0
\n", " \n", " \n", " " ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fun getData(n: Int, m: Int, sizes: List, seed: Long): DataFrame<*> {\n", " val rand = java.util.Random(seed)\n", " fun generateFullDataset(): DataFrame<*> {\n", " return dataFrameOf(\n", " \"x\" to (0 until m).map { i -> (0 until n).map { j -> j + ((i % 2) / 2.0) } }.flatten(),\n", " \"y\" to (0 until m).map { j -> (0 until n).map { i -> j } }.flatten(),\n", " \"v\" to List(n * m) { rand.nextFloat() }\n", " )\n", " }\n", " fun getRandomSample(df: DataFrame<*>, size: Int, reg: Boolean = false): DataFrame<*> {\n", " val subDf = if (reg) {\n", " df.filter { \"y\"() % 2 == 0 }.sortBy(\"x\", \"y\")\n", " } else {\n", " df\n", " }\n", " val limit = min(subDf.rowsCount(), size)\n", " val indices = (0 until subDf.rowsCount()).shuffled(java.util.Random(seed)).take(limit)\n", " return subDf.filter { index() in indices }\n", " }\n", " return sizes.mapIndexed { i, size -> getRandomSample(generateFullDataset(), size, i == 0).add(\"g\") { \"group $i\" } }.concat()\n", "}\n", "\n", "val df = getData(6, 5, listOf(8, 9, 7), seed = 0)\n", "val dataMap = df.toMap()\n", "df.head()" ] }, { "cell_type": "markdown", "id": "a86c035a-8db1-4508-b595-9ab111a1baf0", "metadata": {}, "source": [ "The Lets-Plot tries to choose the sizes of the hexagons by itself, but in some situations the result may be unsatisfactory, as in the plot below. Namely in the facet with 'group 0', the hexagons are too large to fit into the grid:" ] }, { "cell_type": "markdown", "id": "497817ef-a93b-4aef-9f7a-901746401514", "metadata": {}, "source": [ "#### - The Problem: data resolution varies across the plot facets." ] }, { "cell_type": "code", "execution_count": 8, "id": "db7d0946-cb57-4fdb-8a0f-00acc5b20e51", "metadata": {}, "outputs": [ { "data": { "application/plot+json": { "apply_color_scheme": true, "output": { "data": { "g": [ "group 0", "group 0", "group 0", "group 0", "group 0", "group 0", "group 0", "group 0", "group 1", "group 1", "group 1", "group 1", "group 1", "group 1", "group 1", "group 1", "group 1", "group 2", "group 2", "group 2", "group 2", "group 2", "group 2", "group 2" ], "v": [ 0.7309677600860596, 0.3851891756057739, 0.6130357384681702, 0.7051747441291809, 0.984841525554657, 0.02323812246322632, 0.9828194975852966, 0.3090505599975586, 0.5629496574401855, 0.6251463294029236, 0.014927029609680176, 0.7763122320175171, 0.9766978025436401, 0.7331520318984985, 0.8388903141021729, 0.08306235074996948, 0.1859896183013916, 0.7150309681892395, 0.3591653108596802, 0.46295779943466187, 0.27424705028533936, 0.3387696146965027, 0.9715469479560852, 0.21757036447525024 ], "x": [ 0, 0, 1, 1, 2, 2, 3, 5, 1, 4, 1.5, 2.5, 3.5, 4, 2.5, 4, 5, 4, 1.5, 2.5, 3.5, 4, 2.5, 4 ], "y": [ 0, 2, 2, 4, 2, 4, 2, 0, 0, 0, 1, 1, 1, 2, 3, 4, 4, 0, 1, 1, 1, 2, 3, 4 ] }, "data_meta": { "series_annotations": [ { "column": "x", "type": "float" }, { "column": "y", "type": "int" }, { "column": "v", "type": "float" }, { "column": "g", "type": "str" } ] }, "facet": { "dir": "h", "facets": "g", "name": "wrap", "nrow": 1, "order": 1 }, "kind": "plot", "layers": [ { "geom": "hex", "mapping": {}, "position": "identity", "size": 0.5, "stat": "identity" } ], "mapping": { "fill": "v", "x": "x", "y": "y" }, "scales": [] }, "output_type": "lets_plot_spec", "swing_enabled": true }, "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", " \n", " 0\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 2\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 4\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 6\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " -1\n", " \n", " \n", " \n", " \n", " \n", " \n", " 0\n", " \n", " \n", " \n", " \n", " \n", " \n", " 1\n", " \n", " \n", " \n", " \n", " \n", " \n", " 2\n", " \n", " \n", " \n", " \n", " \n", " \n", " 3\n", " \n", " \n", " \n", " \n", " \n", " \n", " 4\n", " \n", " \n", " \n", " \n", " \n", " \n", " 5\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " group 0\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", " \n", " \n", " \n", " 0\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 2\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 4\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 6\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " group 1\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", " 0\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 2\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 4\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 6\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " group 2\n", " \n", " \n", " \n", " \n", " \n", " y\n", " \n", " \n", " \n", " \n", " x\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " v\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", " 0.2\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.4\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.6\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.8\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", " " ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "letsPlot(dataMap) { x = \"x\"; y = \"y\"; fill = \"v\" } +\n", " geomHex(stat = Stat.identity, size = .5) +\n", " facetWrap(facets = \"g\", nrow = 1)" ] }, { "cell_type": "markdown", "id": "c1bbd1ec-1860-4b81-9b9c-5822c3a1bde3", "metadata": {}, "source": [ "Since the data resolution varies across facets, simply resizing the `hexagons` isn't sufficient.\n", "\n", "By default, `width` and `height` use the `'res'` unit, which is relative to the resolution (minimum distance between hexagon centers) in each individual facet:" ] }, { "cell_type": "code", "execution_count": 9, "id": "46755077-e80f-4856-9a57-82826c904a97", "metadata": {}, "outputs": [ { "data": { "application/plot+json": { "apply_color_scheme": true, "output": { "data": { "g": [ "group 0", "group 0", "group 0", "group 0", "group 0", "group 0", "group 0", "group 0", "group 1", "group 1", "group 1", "group 1", "group 1", "group 1", "group 1", "group 1", "group 1", "group 2", "group 2", "group 2", "group 2", "group 2", "group 2", "group 2" ], "v": [ 0.7309677600860596, 0.3851891756057739, 0.6130357384681702, 0.7051747441291809, 0.984841525554657, 0.02323812246322632, 0.9828194975852966, 0.3090505599975586, 0.5629496574401855, 0.6251463294029236, 0.014927029609680176, 0.7763122320175171, 0.9766978025436401, 0.7331520318984985, 0.8388903141021729, 0.08306235074996948, 0.1859896183013916, 0.7150309681892395, 0.3591653108596802, 0.46295779943466187, 0.27424705028533936, 0.3387696146965027, 0.9715469479560852, 0.21757036447525024 ], "x": [ 0, 0, 1, 1, 2, 2, 3, 5, 1, 4, 1.5, 2.5, 3.5, 4, 2.5, 4, 5, 4, 1.5, 2.5, 3.5, 4, 2.5, 4 ], "y": [ 0, 2, 2, 4, 2, 4, 2, 0, 0, 0, 1, 1, 1, 2, 3, 4, 4, 0, 1, 1, 1, 2, 3, 4 ] }, "data_meta": { "series_annotations": [ { "column": "x", "type": "float" }, { "column": "y", "type": "int" }, { "column": "v", "type": "float" }, { "column": "g", "type": "str" } ] }, "facet": { "dir": "h", "facets": "g", "name": "wrap", "nrow": 1, "order": 1 }, "kind": "plot", "layers": [ { "geom": "hex", "height": 0.5, "mapping": {}, "position": "identity", "size": 0.5, "stat": "identity", "width": 0.5 } ], "mapping": { "fill": "v", "x": "x", "y": "y" }, "scales": [] }, "output_type": "lets_plot_spec", "swing_enabled": true }, "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", " \n", " 0\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 1\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 2\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 3\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 4\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 5\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 0\n", " \n", " \n", " \n", " \n", " \n", " \n", " 1\n", " \n", " \n", " \n", " \n", " \n", " \n", " 2\n", " \n", " \n", " \n", " \n", " \n", " \n", " 3\n", " \n", " \n", " \n", " \n", " \n", " \n", " 4\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " group 0\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", " \n", " \n", " \n", " 0\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 1\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 2\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 3\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 4\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 5\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " group 1\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", " 0\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 1\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 2\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 3\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 4\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 5\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " group 2\n", " \n", " \n", " \n", " \n", " \n", " y\n", " \n", " \n", " \n", " \n", " x\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " v\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", " 0.2\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.4\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.6\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.8\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", " " ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "letsPlot(dataMap) { x = \"x\"; y = \"y\"; fill = \"v\" } +\n", " geomHex(stat = Stat.identity, size = .5,\n", " width = .5, height = .5) +\n", " facetWrap(facets = \"g\", nrow = 1)" ] }, { "cell_type": "markdown", "id": "49209742-0a26-4ede-b19e-85f5c65b315b", "metadata": {}, "source": [ "#### - The Solution: switch to `'identity'` units to express hexagon `width`/`height` in consistent X/Y-axis units." ] }, { "cell_type": "code", "execution_count": 10, "id": "17a77b72-8391-45a6-8a5e-c301f997cfd2", "metadata": {}, "outputs": [ { "data": { "application/plot+json": { "apply_color_scheme": true, "output": { "data": { "g": [ "group 0", "group 0", "group 0", "group 0", "group 0", "group 0", "group 0", "group 0", "group 1", "group 1", "group 1", "group 1", "group 1", "group 1", "group 1", "group 1", "group 1", "group 2", "group 2", "group 2", "group 2", "group 2", "group 2", "group 2" ], "v": [ 0.7309677600860596, 0.3851891756057739, 0.6130357384681702, 0.7051747441291809, 0.984841525554657, 0.02323812246322632, 0.9828194975852966, 0.3090505599975586, 0.5629496574401855, 0.6251463294029236, 0.014927029609680176, 0.7763122320175171, 0.9766978025436401, 0.7331520318984985, 0.8388903141021729, 0.08306235074996948, 0.1859896183013916, 0.7150309681892395, 0.3591653108596802, 0.46295779943466187, 0.27424705028533936, 0.3387696146965027, 0.9715469479560852, 0.21757036447525024 ], "x": [ 0, 0, 1, 1, 2, 2, 3, 5, 1, 4, 1.5, 2.5, 3.5, 4, 2.5, 4, 5, 4, 1.5, 2.5, 3.5, 4, 2.5, 4 ], "y": [ 0, 2, 2, 4, 2, 4, 2, 0, 0, 0, 1, 1, 1, 2, 3, 4, 4, 0, 1, 1, 1, 2, 3, 4 ] }, "data_meta": { "series_annotations": [ { "column": "x", "type": "float" }, { "column": "y", "type": "int" }, { "column": "v", "type": "float" }, { "column": "g", "type": "str" } ] }, "facet": { "dir": "h", "facets": "g", "name": "wrap", "nrow": 1, "order": 1 }, "kind": "plot", "layers": [ { "geom": "hex", "height": 1.1547005383792517, "height_unit": "identity", "mapping": {}, "position": "identity", "size": 0.5, "stat": "identity", "width": 1, "width_unit": "identity" } ], "mapping": { "fill": "v", "x": "x", "y": "y" }, "scales": [] }, "output_type": "lets_plot_spec", "swing_enabled": true }, "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", " \n", " 0\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 1\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 2\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 3\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 4\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 5\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 0\n", " \n", " \n", " \n", " \n", " \n", " \n", " 1\n", " \n", " \n", " \n", " \n", " \n", " \n", " 2\n", " \n", " \n", " \n", " \n", " \n", " \n", " 3\n", " \n", " \n", " \n", " \n", " \n", " \n", " 4\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " group 0\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", " \n", " \n", " \n", " 0\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 1\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 2\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 3\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 4\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 5\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " group 1\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", " 0\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 1\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 2\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 3\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 4\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 5\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " group 2\n", " \n", " \n", " \n", " \n", " \n", " y\n", " \n", " \n", " \n", " \n", " x\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " v\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", " 0.2\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.4\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.6\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 0.8\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", " " ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "letsPlot(dataMap) { x = \"x\"; y = \"y\"; fill = \"v\" } +\n", " geomHex(stat = Stat.identity, size = .5,\n", " widthUnit = \"identity\", width = 1, // <-- Set width in data units\n", " heightUnit = \"identity\", height = 2.0/sqrt(3.0) // <-- Set height in data units\n", " ) +\n", " facetWrap(facets = \"g\", nrow = 1)" ] }, { "cell_type": "markdown", "id": "cdfcbb56-917b-4813-8cfe-424ca344bbd6", "metadata": {}, "source": [ "### 3. Unit Comparison: Pixel, Size, Identity and Resolution" ] }, { "cell_type": "markdown", "id": "f3cf873c-25ee-434d-ab7a-c31b9c44de6d", "metadata": {}, "source": [ "Note that when using `\"px\"` or `\"size\"` units the axis scales do not automatically expand to accommodate the dimensions of geometry." ] }, { "cell_type": "code", "execution_count": 11, "id": "e50a23f5-9eb9-430b-9513-bbdc7b3dba62", "metadata": {}, "outputs": [ { "data": { "application/plot+json": { "apply_color_scheme": true, "output": { "figures": [ { "coord": { "flip": false, "name": "fixed" }, "data": { "c": [ "a", "b", "c", "d" ], "x": [ -7, -7, 7, 7 ], "y": [ -5, 5, -5, 5 ] }, "data_meta": { "series_annotations": [ { "column": "x", "type": "int" }, { "column": "y", "type": "int" }, { "column": "c", "type": "str" } ] }, "ggtitle": { "text": "width=0.9, width_unit=\"res\"\nheight=0.9, height_unit=\"res\"" }, "kind": "plot", "layers": [ { "geom": "tile", "height": 0.9, "height_unit": "res", "mapping": {}, "position": "identity", "show_legend": false, "stat": "identity", "width": 0.9, "width_unit": "res" }, { "fill": "white", "geom": "point", "mapping": {}, "position": "identity", "shape": 21, "stat": "identity" } ], "mapping": { "fill": "c", "x": "x", "y": "y" }, "scales": [] }, { "coord": { "flip": false, "name": "fixed" }, "data": { "c": [ "a", "b", "c", "d" ], "x": [ -7, -7, 7, 7 ], "y": [ -5, 5, -5, 5 ] }, "data_meta": { "series_annotations": [ { "column": "x", "type": "int" }, { "column": "y", "type": "int" }, { "column": "c", "type": "str" } ] }, "ggtitle": { "text": "width=12.0, width_unit=\"identity\"\nheight=8.0, height_unit=\"identity\"" }, "kind": "plot", "layers": [ { "geom": "tile", "height": 8, "height_unit": "identity", "mapping": {}, "position": "identity", "show_legend": false, "stat": "identity", "width": 12, "width_unit": "identity" }, { "fill": "white", "geom": "point", "mapping": {}, "position": "identity", "shape": 21, "stat": "identity" } ], "mapping": { "fill": "c", "x": "x", "y": "y" }, "scales": [] }, { "coord": { "flip": false, "name": "fixed" }, "data": { "c": [ "a", "b", "c", "d" ], "x": [ -7, -7, 7, 7 ], "y": [ -5, 5, -5, 5 ] }, "data_meta": { "series_annotations": [ { "column": "x", "type": "int" }, { "column": "y", "type": "int" }, { "column": "c", "type": "str" } ] }, "ggtitle": { "text": "width=100.0, width_unit=\"size\"\nheight=70.0, height_unit=\"size\"" }, "kind": "plot", "layers": [ { "geom": "tile", "height": 70, "height_unit": "size", "mapping": {}, "position": "identity", "show_legend": false, "stat": "identity", "width": 100, "width_unit": "size" }, { "fill": "white", "geom": "point", "mapping": {}, "position": "identity", "shape": 21, "stat": "identity" } ], "mapping": { "fill": "c", "x": "x", "y": "y" }, "scales": [] }, { "coord": { "flip": false, "name": "fixed" }, "data": { "c": [ "a", "b", "c", "d" ], "x": [ -7, -7, 7, 7 ], "y": [ -5, 5, -5, 5 ] }, "data_meta": { "series_annotations": [ { "column": "x", "type": "int" }, { "column": "y", "type": "int" }, { "column": "c", "type": "str" } ] }, "ggtitle": { "text": "width=200.0, width_unit=\"px\"\nheight=150.0, height_unit=\"px\"" }, "kind": "plot", "layers": [ { "geom": "tile", "height": 150, "height_unit": "px", "mapping": {}, "position": "identity", "show_legend": false, "stat": "identity", "width": 200, "width_unit": "px" }, { "fill": "white", "geom": "point", "mapping": {}, "position": "identity", "shape": 21, "stat": "identity" } ], "mapping": { "fill": "c", "x": "x", "y": "y" }, "scales": [] } ], "kind": "subplots", "layout": { "align": false, "fit": true, "name": "grid", "ncol": 2, "nrow": 2 } }, "output_type": "lets_plot_spec", "swing_enabled": true }, "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", " -10\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " -5\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 0\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 5\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 10\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " -10\n", " \n", " \n", " \n", " \n", " \n", " \n", " -5\n", " \n", " \n", " \n", " \n", " \n", " \n", " 0\n", " \n", " \n", " \n", " \n", " \n", " \n", " 5\n", " \n", " \n", " \n", " \n", " \n", " \n", " 10\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " width=0.9, width_unit="res"\n", " \n", " \n", " height=0.9, height_unit="res"\n", " \n", " \n", " \n", " \n", " y\n", " \n", " \n", " \n", " \n", " x\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", " -10\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " -5\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 0\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 5\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 10\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " -5\n", " \n", " \n", " \n", " \n", " \n", " \n", " 0\n", " \n", " \n", " \n", " \n", " \n", " \n", " 5\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " width=12.0, width_unit="identity"\n", " \n", " \n", " height=8.0, height_unit="identity"\n", " \n", " \n", " \n", " \n", " y\n", " \n", " \n", " \n", " \n", " x\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", " -5\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 0\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 5\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " -4\n", " \n", " \n", " \n", " \n", " \n", " \n", " -2\n", " \n", " \n", " \n", " \n", " \n", " \n", " 0\n", " \n", " \n", " \n", " \n", " \n", " \n", " 2\n", " \n", " \n", " \n", " \n", " \n", " \n", " 4\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " width=100.0, width_unit="size"\n", " \n", " \n", " height=70.0, height_unit="size"\n", " \n", " \n", " \n", " \n", " y\n", " \n", " \n", " \n", " \n", " x\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", " -5\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 0\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 5\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " -4\n", " \n", " \n", " \n", " \n", " \n", " \n", " -2\n", " \n", " \n", " \n", " \n", " \n", " \n", " 0\n", " \n", " \n", " \n", " \n", " \n", " \n", " 2\n", " \n", " \n", " \n", " \n", " \n", " \n", " 4\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " width=200.0, width_unit="px"\n", " \n", " \n", " height=150.0, height_unit="px"\n", " \n", " \n", " \n", " \n", " y\n", " \n", " \n", " \n", " \n", " x\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", " " ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fun getPlot(\n", " width: Double,\n", " height: Double,\n", " widthUnit: String,\n", " heightUnit: String\n", "): org.jetbrains.letsPlot.intern.Plot {\n", " val w = 7\n", " val h = 5\n", " val dataMap = mapOf(\n", " \"x\" to listOf(-w, -w, w, w),\n", " \"y\" to listOf(-h, h, -h, h),\n", " \"c\" to listOf(\"a\", \"b\", \"c\", \"d\")\n", " )\n", " return letsPlot(dataMap) { x = \"x\"; y = \"y\"; fill = \"c\" } +\n", " geomTile(width = width, widthUnit = widthUnit,\n", " height = height, heightUnit = heightUnit,\n", " showLegend = false) +\n", " geomPoint(shape = 21, fill = \"white\") +\n", " coordFixed() +\n", " ggtitle(\"width=$width, width_unit=\\\"$widthUnit\\\"\\nheight=$height, height_unit=\\\"$heightUnit\\\"\")\n", "}\n", "\n", "gggrid(listOf(\n", " getPlot(.9, .9, \"res\", \"res\"),\n", " getPlot(12.0, 8.0, \"identity\", \"identity\"),\n", " getPlot(100.0, 70.0, \"size\", \"size\"),\n", " getPlot(200.0, 150.0, \"px\", \"px\"),\n", "), ncol = 2)" ] } ], "metadata": { "kernelspec": { "display_name": "Kotlin", "language": "kotlin", "name": "kotlin" }, "language_info": { "codemirror_mode": "text/x-kotlin", "file_extension": ".kt", "mimetype": "text/x-kotlin", "name": "kotlin", "nbconvert_exporter": "", "pygments_lexer": "kotlin", "version": "1.9.23" } }, "nbformat": 4, "nbformat_minor": 5 }