{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "9bcfb6f2-51c4-4b60-8700-4bbe9566efe2", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from lets_plot import *\n", "import pandas as pd\n", "\n", "LetsPlot.setup_html()" ] }, { "cell_type": "code", "execution_count": 2, "id": "6cc8dd57-fab8-4a5e-9971-826752410179", "metadata": {}, "outputs": [], "source": [ "iris = pd.read_csv('https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/iris.csv')\n", "\n", "p = ggplot(iris, aes(x='petal_length', fill='species')) + facet_wrap(facets='species', scales='free_x')" ] }, { "cell_type": "code", "execution_count": 3, "id": "a55b4bfa-d992-476d-99e8-0a0c33ccff9b", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gggrid([\n", " ggplot(iris, aes(x='petal_length', fill='species')) \\\n", " + facet_wrap(facets='species', scales='free_x') \\\n", " + geom_histogram(alpha=.5, bins=3, threshold=0, show_legend=False),\n", " ggplot(iris, aes(x='petal_length', fill='species')) \\\n", " + facet_wrap(facets='species') \\\n", " + geom_histogram(alpha=.5, bins=3, threshold=0, show_legend=False)\n", "])" ] }, { "cell_type": "code", "execution_count": 4, "id": "f1732195-f907-4e32-99d1-571c065effcb", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ggplot(iris, aes(x='petal_length', fill='species')) \\\n", " + facet_wrap(facets='species', scales='free_x') \\\n", " + geom_histogram(alpha=.5, bins=4, threshold=0)" ] }, { "cell_type": "code", "execution_count": 5, "id": "88a34ca8-c1d3-4a81-ade9-e61592336fa8", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p + geom_histogram(alpha=.5, bins=4, threshold=0)" ] }, { "cell_type": "code", "execution_count": 6, "id": "11fff3c8-a21f-4f17-8725-0317747378f6", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import numpy as np\n", "np.random.seed(42)\n", "x = np.random.poisson(size=100)\n", "\n", "ggplot({'x': x}, aes(x='x')) + geom_histogram() + scale_y_log2()" ] }, { "cell_type": "code", "execution_count": null, "id": "0aaef597-e0ef-4621-a539-5a39d37570de", "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.18" } }, "nbformat": 4, "nbformat_minor": 5 }