{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "from lets_plot import *" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "data = dict(\n", " cond=np.repeat(['A','B'], 200),\n", " rating=np.concatenate((np.random.normal(0, 1, 200), np.random.normal(1, 1.5, 200)))\n", ")\n", "\n", "plot = (ggplot(data, aes(x='rating', fill='cond')) \n", " + ggsize(500, 250)\n", " + geom_density(color='dark_green', alpha=.7) + scale_fill_brewer(type='seq')\n", " + theme(axis_line_y='blank')\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# get just SVG (no JS)\n", "import lets_plot._kbridge as kbr\n", "\n", "plot_svg = kbr._generate_svg(plot.as_dict())" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# show svg\n", "from IPython.display import SVG\n", "\n", "SVG(plot_svg)" ] } ], "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.7.10" } }, "nbformat": 4, "nbformat_minor": 4 }