{ "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": {}, "outputs": [], "source": [ "from lets_plot import *" ] }, { "cell_type": "code", "execution_count": 2, "id": "e5021e9e", "metadata": {}, "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": {}, "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": {}, "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": {}, "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": {}, "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=8, color=\"#54278f\", fill=\"#dd1c77\")" ] }, { "cell_type": "markdown", "id": "4149ce11", "metadata": {}, "source": [ "#### 3. Stroke Scales" ] }, { "cell_type": "code", "execution_count": 7, "id": "317746c5", "metadata": {}, "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": {}, "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": {}, "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.8.16" } }, "nbformat": 4, "nbformat_minor": 5 }