{ "cells": [ { "cell_type": "code", "execution_count": 2, "id": "8a72c7c1", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from lets_plot import *\n", "\n", "LetsPlot.setup_html()" ] }, { "cell_type": "code", "execution_count": 6, "id": "a633a87d", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dat = dict(\n", " x = [0, 2],\n", " y = [0, 2],\n", " c = [\"a\", \"b\"],\n", " s = [\"a\", \"b\"]\n", ")\n", "\n", "p = ggplot(dat) + geom_point(aes(\"x\", \"y\", shape=\"s\", color=\"c\"), size=10)\n", "p" ] }, { "cell_type": "code", "execution_count": 10, "id": "63c7d9f5", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p + scale_color_manual(name=\"O\", values=[\"red\", \"blue\"]) #+ scale_shape(name=\"O\")" ] }, { "cell_type": "code", "execution_count": 13, "id": "94351cdd", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p1 = ggplot(dat) + geom_tile(aes(\"x\", \"y\", fill=\"c\"))\n", "p1" ] }, { "cell_type": "code", "execution_count": 15, "id": "e9c96610", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p1 + scale_fill_manual(name=\"O\", values=[\"red\", \"blue\"], labels=['No', 'Yes'])" ] }, { "cell_type": "code", "execution_count": 25, "id": "3871b3bb", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dat2 = dict(\n", " x = [\"a\", \"a\", \"b\"],\n", ")\n", "\n", "\n", "(ggplot(dat2) + \n", " geom_bar(aes(\"x\", fill=\"x\")) + \n", " scale_fill_manual(name=\"O\", values=[\"red\", \"blue\"], labels=['No', 'Yes'])\n", ")\n" ] }, { "cell_type": "code", "execution_count": 24, "id": "0c7035db", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from lets_plot.mapping import as_discrete\n", "\n", "\n", "(ggplot(dat2) + \n", " geom_bar(aes(\"x\", fill=as_discrete(\"x\"))) + \n", " scale_fill_manual(name=\"O\", values=[\"red\", \"blue\"], labels=['No', 'Yes'])\n", ")\n" ] }, { "cell_type": "code", "execution_count": null, "id": "8b90a77a", "metadata": {}, "outputs": [], "source": [] } ], "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 }