{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "f6625271", "metadata": { "execution": { "iopub.execute_input": "2024-04-17T07:27:59.508942Z", "iopub.status.busy": "2024-04-17T07:27:59.508636Z", "iopub.status.idle": "2024-04-17T07:27:59.822698Z", "shell.execute_reply": "2024-04-17T07:27:59.822378Z" }, "pycharm": { "name": "#%%\n" } }, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from lets_plot import *\n", "LetsPlot.setup_html()" ] }, { "cell_type": "code", "execution_count": 2, "id": "4c799fdf", "metadata": { "execution": { "iopub.execute_input": "2024-04-17T07:27:59.823933Z", "iopub.status.busy": "2024-04-17T07:27:59.823822Z", "iopub.status.idle": "2024-04-17T07:27:59.825699Z", "shell.execute_reply": "2024-04-17T07:27:59.825485Z" }, "pycharm": { "name": "#%%\n" } }, "outputs": [], "source": [ "data = {'x': list(range(-32, 32))}\n", "\n", "p = ggplot(data) + coord_cartesian() + ggsize(600, 200)" ] }, { "cell_type": "code", "execution_count": 3, "id": "35d9531a", "metadata": { "execution": { "iopub.execute_input": "2024-04-17T07:27:59.826795Z", "iopub.status.busy": "2024-04-17T07:27:59.826644Z", "iopub.status.idle": "2024-04-17T07:27:59.858444Z", "shell.execute_reply": "2024-04-17T07:27:59.858229Z" }, "pycharm": { "name": "#%%\n" } }, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p + geom_tile(aes(x='x', fill='x')) + \\\n", " scale_fill_gradientn(colors=['#2b83ba', 'green', '#d7191c'])" ] }, { "cell_type": "code", "execution_count": 4, "id": "a1220fae", "metadata": { "execution": { "iopub.execute_input": "2024-04-17T07:27:59.859527Z", "iopub.status.busy": "2024-04-17T07:27:59.859417Z", "iopub.status.idle": "2024-04-17T07:27:59.862115Z", "shell.execute_reply": "2024-04-17T07:27:59.861942Z" }, "pycharm": { "name": "#%%\n" } }, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p + geom_tile(aes(x='x', color='x'), fill='white', size=2) + \\\n", " scale_color_gradientn(colors=['#2b83ba', 'green', '#d7191c'])" ] }, { "cell_type": "code", "execution_count": 5, "id": "466166f7", "metadata": { "execution": { "iopub.execute_input": "2024-04-17T07:27:59.863088Z", "iopub.status.busy": "2024-04-17T07:27:59.862965Z", "iopub.status.idle": "2024-04-17T07:27:59.865299Z", "shell.execute_reply": "2024-04-17T07:27:59.865127Z" }, "pycharm": { "name": "#%%\n" } }, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p + geom_tile(aes(x='x', fill='x')) + \\\n", " scale_fill_gradientn(colors=['red', 'orange', 'yellow', 'green', 'light_blue', 'blue', 'magenta'])" ] }, { "cell_type": "code", "execution_count": 6, "id": "530ccef0", "metadata": { "execution": { "iopub.execute_input": "2024-04-17T07:27:59.866088Z", "iopub.status.busy": "2024-04-17T07:27:59.866017Z", "iopub.status.idle": "2024-04-17T07:27:59.868269Z", "shell.execute_reply": "2024-04-17T07:27:59.868095Z" }, "pycharm": { "name": "#%%\n" } }, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Asymmetric gradient\n", "p + geom_tile(aes(x='x', fill='x')) + \\\n", " scale_fill_gradientn(colors=[*['#2b83ba']*4, 'green', '#d7191c'])" ] } ], "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 }