{ "cells": [ { "cell_type": "markdown", "id": "a438d36c-99d6-4273-bce7-52f9830cd4b5", "metadata": {}, "source": [ "# Check alpha/opacity effects" ] }, { "cell_type": "code", "execution_count": 7, "id": "2f0fc161-5877-45e2-9832-272213c0cc77", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from lets_plot import *\n", "import re\n", "\n", "LetsPlot.setup_html() " ] }, { "cell_type": "code", "execution_count": 8, "id": "5623144c-99c3-4bf3-8ef3-0ccb3f83a171", "metadata": {}, "outputs": [], "source": [ "def text_plot(color, alpha):\n", " rgba_alpha = None\n", " m = re.match(r'rgba\\(\\s*\\d+\\s*,\\s*\\d+\\s*,\\s*\\d+\\s*,\\s*([0-9.]+)\\s*\\)', color)\n", " if m:\n", " rgba_alpha = float(m.group(1))\n", " \n", " label = f\"{rgba_alpha}\\n{alpha}\"\n", " \n", " return (\n", " ggplot() +\n", " geom_text(\n", " x=0, y=0,\n", " label=label,\n", " size=24,\n", " color=color,\n", " alpha=alpha\n", " ) +\n", " theme_void() +\n", " theme(panel_grid_major=element_line(size=4)) +\n", " ggsize(300, 200)\n", " )" ] }, { "cell_type": "code", "execution_count": 9, "id": "f6e42fd5-f76e-4a7d-9aad-3332b0e91c3d", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "