{ "cells": [ { "cell_type": "markdown", "id": "50816dd6", "metadata": {}, "source": [ "# `stroke` aesthetic\n", "\n", "Affects the thickness of the point boundaries (in case the given shape has a boundary).\n", "\n", "Available for the following geometries: `geom_point()`, `geom_jitter()`, `geom_qq()`, `geom_qq2()`, `geom_pointrange()`, `geom_dotplot()`, `geom_ydotplot()`." ] }, { "cell_type": "code", "execution_count": 1, "id": "4548aaa5", "metadata": { "execution": { "iopub.execute_input": "2024-11-01T20:13:39.473531Z", "iopub.status.busy": "2024-11-01T20:13:39.473440Z", "iopub.status.idle": "2024-11-01T20:13:39.801890Z", "shell.execute_reply": "2024-11-01T20:13:39.801541Z" } }, "outputs": [], "source": [ "from lets_plot import *" ] }, { "cell_type": "code", "execution_count": 2, "id": "e5021e9e", "metadata": { "execution": { "iopub.execute_input": "2024-11-01T20:13:39.803147Z", "iopub.status.busy": "2024-11-01T20:13:39.803039Z", "iopub.status.idle": "2024-11-01T20:13:39.805272Z", "shell.execute_reply": "2024-11-01T20:13:39.805095Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "LetsPlot.setup_html()" ] }, { "cell_type": "code", "execution_count": 3, "id": "7ca0b26d", "metadata": { "execution": { "iopub.execute_input": "2024-11-01T20:13:39.806183Z", "iopub.status.busy": "2024-11-01T20:13:39.806110Z", "iopub.status.idle": "2024-11-01T20:13:39.807737Z", "shell.execute_reply": "2024-11-01T20:13:39.807556Z" } }, "outputs": [], "source": [ "data1 = {\n", " 'x': (list(range(7)) * 4)[:26],\n", " 'y': ([3] * 7 + [2] * 7 + [1] * 7 + [0] * 7)[:26],\n", " 'shape': list(range(26)),\n", "}" ] }, { "cell_type": "code", "execution_count": 4, "id": "1829f639", "metadata": { "execution": { "iopub.execute_input": "2024-11-01T20:13:39.808543Z", "iopub.status.busy": "2024-11-01T20:13:39.808468Z", "iopub.status.idle": "2024-11-01T20:13:39.809928Z", "shell.execute_reply": "2024-11-01T20:13:39.809756Z" } }, "outputs": [], "source": [ "p1 = ggplot(data1, aes('x', 'y')) + scale_shape_identity() + \\\n", " xlim(-1, 7) + ylim(-1, 4) + \\\n", " theme(legend_position='none')" ] }, { "cell_type": "markdown", "id": "c184ec7a", "metadata": {}, "source": [ "#### 1. Default Stroke" ] }, { "cell_type": "code", "execution_count": 5, "id": "4784b085", "metadata": { "execution": { "iopub.execute_input": "2024-11-01T20:13:39.810681Z", "iopub.status.busy": "2024-11-01T20:13:39.810604Z", "iopub.status.idle": "2024-11-01T20:13:39.844534Z", "shell.execute_reply": "2024-11-01T20:13:39.844322Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p1 + geom_point(aes(shape='shape'), size=12, color=\"#54278f\", fill=\"#dd1c77\")" ] }, { "cell_type": "markdown", "id": "f84b550d", "metadata": {}, "source": [ "#### 2. Increased Stroke" ] }, { "cell_type": "code", "execution_count": 6, "id": "56d38045", "metadata": { "execution": { "iopub.execute_input": "2024-11-01T20:13:39.845631Z", "iopub.status.busy": "2024-11-01T20:13:39.845552Z", "iopub.status.idle": "2024-11-01T20:13:39.848378Z", "shell.execute_reply": "2024-11-01T20:13:39.848208Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p1 + geom_point(aes(shape='shape'), size=12, stroke=6, color=\"#54278f\", fill=\"#dd1c77\")" ] }, { "cell_type": "markdown", "id": "4149ce11", "metadata": {}, "source": [ "#### 3. Stroke Scales" ] }, { "cell_type": "code", "execution_count": 7, "id": "317746c5", "metadata": { "execution": { "iopub.execute_input": "2024-11-01T20:13:39.849402Z", "iopub.status.busy": "2024-11-01T20:13:39.849281Z", "iopub.status.idle": "2024-11-01T20:13:39.850670Z", "shell.execute_reply": "2024-11-01T20:13:39.850499Z" } }, "outputs": [], "source": [ "data2 = {\n", " 'x': [0, 1, 2],\n", " 'y': [0, 0, 0],\n", " 'stroke': [4, 16, 8],\n", "}" ] }, { "cell_type": "code", "execution_count": 8, "id": "0a21b011", "metadata": { "execution": { "iopub.execute_input": "2024-11-01T20:13:39.851337Z", "iopub.status.busy": "2024-11-01T20:13:39.851267Z", "iopub.status.idle": "2024-11-01T20:13:39.852717Z", "shell.execute_reply": "2024-11-01T20:13:39.852541Z" } }, "outputs": [], "source": [ "p2 = ggplot(data2, aes('x', 'y')) + \\\n", " geom_point(aes(stroke='stroke'), size=12, shape=21, color=\"#54278f\", fill=\"#dd1c77\")" ] }, { "cell_type": "code", "execution_count": 9, "id": "00fe5e3a", "metadata": { "execution": { "iopub.execute_input": "2024-11-01T20:13:39.853418Z", "iopub.status.busy": "2024-11-01T20:13:39.853310Z", "iopub.status.idle": "2024-11-01T20:13:39.857033Z", "shell.execute_reply": "2024-11-01T20:13:39.856861Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gggrid([\n", " p2 + ggtitle(\"Default scale\"),\n", " p2 + scale_stroke(range=[2, 4]) + ggtitle(\"scale_stroke()\"),\n", " p2 + scale_stroke_identity() + ggtitle(\"scale_stroke_identity()\"),\n", "], ncol=2)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.13" } }, "nbformat": 4, "nbformat_minor": 5 }