{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "execution": { "iopub.execute_input": "2024-04-17T07:28:02.780131Z", "iopub.status.busy": "2024-04-17T07:28:02.780051Z", "iopub.status.idle": "2024-04-17T07:28:03.102568Z", "shell.execute_reply": "2024-04-17T07:28:03.102246Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import pandas as pd\n", "\n", "from lets_plot import *\n", "LetsPlot.setup_html()" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "execution": { "iopub.execute_input": "2024-04-17T07:28:03.116194Z", "iopub.status.busy": "2024-04-17T07:28:03.116039Z", "iopub.status.idle": "2024-04-17T07:28:03.245738Z", "shell.execute_reply": "2024-04-17T07:28:03.245299Z" } }, "outputs": [], "source": [ "mpg_df=pd.read_csv('https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/mpg.csv')" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "execution": { "iopub.execute_input": "2024-04-17T07:28:03.246921Z", "iopub.status.busy": "2024-04-17T07:28:03.246828Z", "iopub.status.idle": "2024-04-17T07:28:03.280919Z", "shell.execute_reply": "2024-04-17T07:28:03.280715Z" }, "scrolled": false }, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ggplot(mpg_df, aes(x='class')) + \\\n", " geom_bar(aes(fill='class'), alpha=.8) + \\\n", " scale_fill_discrete()" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "execution": { "iopub.execute_input": "2024-04-17T07:28:03.282055Z", "iopub.status.busy": "2024-04-17T07:28:03.281930Z", "iopub.status.idle": "2024-04-17T07:28:03.286338Z", "shell.execute_reply": "2024-04-17T07:28:03.286127Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ggplot(mpg_df) + \\\n", " geom_bar(aes(x='cyl', fill='drv'), color='white', size=0.5)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "execution": { "iopub.execute_input": "2024-04-17T07:28:03.287409Z", "iopub.status.busy": "2024-04-17T07:28:03.287263Z", "iopub.status.idle": "2024-04-17T07:28:03.291362Z", "shell.execute_reply": "2024-04-17T07:28:03.291190Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ggplot(mpg_df) + \\\n", " geom_bar(aes(x='cyl', fill='drv'), position='dodge')" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "execution": { "iopub.execute_input": "2024-04-17T07:28:03.292343Z", "iopub.status.busy": "2024-04-17T07:28:03.292229Z", "iopub.status.idle": "2024-04-17T07:28:03.293621Z", "shell.execute_reply": "2024-04-17T07:28:03.293448Z" } }, "outputs": [], "source": [ "results = {'rating': [5, 4, 3, 4, 3, 4, 5, 3, 5, 3, 4, 3]}" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "execution": { "iopub.execute_input": "2024-04-17T07:28:03.294624Z", "iopub.status.busy": "2024-04-17T07:28:03.294515Z", "iopub.status.idle": "2024-04-17T07:28:03.296748Z", "shell.execute_reply": "2024-04-17T07:28:03.296573Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ggplot(results, aes(x='rating')) + geom_bar(aes(y='..count..',fill='..count..'), width=0.85) + \\\n", " scale_fill_discrete()" ] } ], "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": 2 }