{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "adult-article", "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": 2, "id": "adjacent-suicide", "metadata": {}, "outputs": [], "source": [ "data = {\n", " 'x': [1, 1, 2, 2, 2],\n", " 'y' : [1, 3, 2, 1, -3],\n", " 'grp': [\"a\", \"b\", \"a\", \"b\", \"c\"]\n", "}\n", "\n", "p = ggplot(data, aes('x', 'y', group = 'grp')) + \\\n", " geom_bar(aes(fill = 'grp'), stat = 'identity', color = 'black') + \\\n", " scale_fill_brewer(palette = \"Pastel1\")" ] }, { "cell_type": "code", "execution_count": 3, "id": "attended-jacksonville", "metadata": {}, "outputs": [ { "data": { "text/html": [ " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "w, h = 600, 400\n", "\n", "bunch = GGBunch()\n", "bunch.add_plot(p + geom_label(aes(label = 'y'), position = 'stack') + ggtitle(\"Default\"), 0, 0)\n", "bunch.add_plot(p + geom_label(aes(label = 'y'), position = position_stack(0.0)) + ggtitle(\"vjust = 0.0\"), w, 0)\n", "bunch.add_plot(p + geom_label(aes(label = 'y'), position = position_stack(0.3)) + ggtitle(\"vjust = 0.3\"), 0, h)\n", "bunch.add_plot(p + geom_label(aes(label = 'y'), position = position_stack(0.5)) + ggtitle(\"vjust = 0.5\"), w, h)\n", "bunch.add_plot(p + geom_label(aes(label = 'y'), position = position_stack(0.7)) + ggtitle(\"vjust = 0.7\"), 0, 2*h)\n", "bunch.add_plot(p + geom_label(aes(label = 'y'), position = position_stack(1.0)) + ggtitle(\"vjust = 1.0\"), w, 2*h)\n", "bunch.show()" ] }, { "cell_type": "code", "execution_count": 4, "id": "decent-enterprise", "metadata": {}, "outputs": [ { "data": { "text/html": [ " \n", " " ], "text/plain": [ "