{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "6b62b6fd", "metadata": { "execution": { "iopub.execute_input": "2024-04-17T07:36:08.253151Z", "iopub.status.busy": "2024-04-17T07:36:08.253049Z", "iopub.status.idle": "2024-04-17T07:36:08.567018Z", "shell.execute_reply": "2024-04-17T07:36:08.566779Z" } }, "outputs": [], "source": [ "import pandas as pd\n", "\n", "from lets_plot import *" ] }, { "cell_type": "code", "execution_count": 2, "id": "29cafaa2", "metadata": { "execution": { "iopub.execute_input": "2024-04-17T07:36:08.568539Z", "iopub.status.busy": "2024-04-17T07:36:08.568388Z", "iopub.status.idle": "2024-04-17T07:36:08.570443Z", "shell.execute_reply": "2024-04-17T07:36:08.570268Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "LetsPlot.setup_html()" ] }, { "cell_type": "code", "execution_count": 3, "id": "9d0f002d", "metadata": { "execution": { "iopub.execute_input": "2024-04-17T07:36:08.571502Z", "iopub.status.busy": "2024-04-17T07:36:08.571376Z", "iopub.status.idle": "2024-04-17T07:36:08.872903Z", "shell.execute_reply": "2024-04-17T07:36:08.872701Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(234, 12)\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Unnamed: 0manufacturermodeldisplyearcyltransdrvctyhwyflclass
01audia41.819994auto(l5)f1829pcompact
12audia41.819994manual(m5)f2129pcompact
23audia42.020084manual(m6)f2031pcompact
34audia42.020084auto(av)f2130pcompact
45audia42.819996auto(l5)f1626pcompact
\n", "
" ], "text/plain": [ " Unnamed: 0 manufacturer model displ year cyl trans drv cty hwy \\\n", "0 1 audi a4 1.8 1999 4 auto(l5) f 18 29 \n", "1 2 audi a4 1.8 1999 4 manual(m5) f 21 29 \n", "2 3 audi a4 2.0 2008 4 manual(m6) f 20 31 \n", "3 4 audi a4 2.0 2008 4 auto(av) f 21 30 \n", "4 5 audi a4 2.8 1999 6 auto(l5) f 16 26 \n", "\n", " fl class \n", "0 p compact \n", "1 p compact \n", "2 p compact \n", "3 p compact \n", "4 p compact " ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = pd.read_csv(\"https://raw.githubusercontent.com/JetBrains/lets-plot-kotlin/master/docs/examples/data/mpg.csv\")\n", "print(df.shape)\n", "df.head()" ] }, { "cell_type": "code", "execution_count": 4, "id": "8ee71092", "metadata": { "execution": { "iopub.execute_input": "2024-04-17T07:36:08.873960Z", "iopub.status.busy": "2024-04-17T07:36:08.873877Z", "iopub.status.idle": "2024-04-17T07:36:08.901911Z", "shell.execute_reply": "2024-04-17T07:36:08.901544Z" } }, "outputs": [], "source": [ "p = ggplot(df, aes(\"cty\", \"hwy\", color=\"drv\")) + geom_point()" ] }, { "cell_type": "code", "execution_count": 5, "id": "a303ee75", "metadata": { "execution": { "iopub.execute_input": "2024-04-17T07:36:08.903119Z", "iopub.status.busy": "2024-04-17T07:36:08.903032Z", "iopub.status.idle": "2024-04-17T07:36:08.922282Z", "shell.execute_reply": "2024-04-17T07:36:08.922097Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gggrid([\n", " p + ggtitle(\"theme_minimal2() - the default\"),\n", " p + theme_void() + ggtitle(\"theme_void()\"),\n", " p + theme_grey() + ggtitle(\"theme_grey()\"),\n", " p + theme_bw() + ggtitle(\"theme_bw()\"),\n", " p + theme_light() + ggtitle(\"theme_light()\"),\n", " p + theme_classic() + ggtitle(\"theme_classic()\"),\n", " p + theme_minimal() + ggtitle(\"theme_minimal()\"),\n", "], ncol=3)" ] }, { "cell_type": "code", "execution_count": 6, "id": "d58ccbd4", "metadata": { "execution": { "iopub.execute_input": "2024-04-17T07:36:08.923323Z", "iopub.status.busy": "2024-04-17T07:36:08.923238Z", "iopub.status.idle": "2024-04-17T07:36:08.924620Z", "shell.execute_reply": "2024-04-17T07:36:08.924443Z" } }, "outputs": [], "source": [ "pf = p + facet_grid(x=\"drv\")" ] }, { "cell_type": "code", "execution_count": 7, "id": "00e0c9d9", "metadata": { "execution": { "iopub.execute_input": "2024-04-17T07:36:08.925664Z", "iopub.status.busy": "2024-04-17T07:36:08.925523Z", "iopub.status.idle": "2024-04-17T07:36:08.944452Z", "shell.execute_reply": "2024-04-17T07:36:08.944259Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gggrid([\n", " pf + ggtitle(\"theme_minimal2() - the default\"),\n", " pf + theme_void() + ggtitle(\"theme_void()\"),\n", " pf + theme_grey() + ggtitle(\"theme_grey()\"),\n", " pf + theme_bw() + ggtitle(\"theme_bw()\"),\n", " pf + theme_light() + ggtitle(\"theme_light()\"),\n", " pf + theme_classic() + ggtitle(\"theme_classic()\"),\n", " pf + theme_minimal() + ggtitle(\"theme_minimal()\"),\n", "], ncol=1)" ] } ], "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 }