{ "cells": [ { "cell_type": "markdown", "id": "d37b1904", "metadata": {}, "source": [ "# Parameter `alpha_stroke` in `geom_label()`\n", "\n", "\n", "\n", "Use the `alpha_stroke` parameter to enable the applying of `alpha` to `color` (label text and border)." ] }, { "cell_type": "code", "execution_count": 1, "id": "0aa1a2a7", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "\n", "from lets_plot import *" ] }, { "cell_type": "code", "execution_count": 2, "id": "9350f0ee", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "LetsPlot.setup_html()" ] }, { "cell_type": "code", "execution_count": 3, "id": "69b367d1", "metadata": {}, "outputs": [], "source": [ "x = np.arange(1, 10)\n", "y = x[::-1]\n", "data = {'x': x, 'y': y, 'alpha': x}" ] }, { "cell_type": "code", "execution_count": 4, "id": "cde65d4b", "metadata": {}, "outputs": [], "source": [ "p = ggplot(data, aes(x='x', y='y', alpha='y')) + \\\n", " geom_bar(stat='identity', fill='#2b8cbe', tooltips='none') + \\\n", " guides(alpha='none')" ] }, { "cell_type": "code", "execution_count": 5, "id": "13dd84d6", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p + geom_label(aes(label='y'), nudge_y=1, label_format='.1f', fill='#2b8cbe')" ] }, { "cell_type": "markdown", "id": "6c389fe2", "metadata": {}, "source": [ "#### Use `alpha_stroke` Parameter to Apply `alpha` to `color`" ] }, { "cell_type": "code", "execution_count": 6, "id": "b1b29160", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p + geom_label(aes(label='y'), nudge_y=1, label_format='.1f', fill='#2b8cbe', alpha_stroke=True)" ] } ], "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.15" } }, "nbformat": 4, "nbformat_minor": 5 }