{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Dot Plots" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Preparation" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "execution": { "iopub.execute_input": "2024-03-26T14:33:22.073149Z", "iopub.status.busy": "2024-03-26T14:33:22.073065Z", "iopub.status.idle": "2024-03-26T14:33:22.393968Z", "shell.execute_reply": "2024-03-26T14:33:22.393697Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import numpy as np\n", "import pandas as pd\n", "\n", "from lets_plot import *\n", "from lets_plot.mapping import as_discrete\n", "LetsPlot.setup_html()" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "execution": { "iopub.execute_input": "2024-03-26T14:33:22.407633Z", "iopub.status.busy": "2024-03-26T14:33:22.407330Z", "iopub.status.idle": "2024-03-26T14:33:22.410065Z", "shell.execute_reply": "2024-03-26T14:33:22.409860Z" } }, "outputs": [], "source": [ "def plot_matrix(plots=[], width=500, height=375, columns=2):\n", " bunch = GGBunch()\n", " for i in range(len(plots)):\n", " row = int(i / columns)\n", " column = i % columns\n", " bunch.add_plot(plots[i], column * width, row * height, width, height)\n", " return bunch.show()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "execution": { "iopub.execute_input": "2024-03-26T14:33:22.411237Z", "iopub.status.busy": "2024-03-26T14:33:22.411078Z", "iopub.status.idle": "2024-03-26T14:33:22.556309Z", "shell.execute_reply": "2024-03-26T14:33:22.555996Z" } }, "outputs": [ { "data": { "text/html": [ "\n", " | manufacturer | \n", "model | \n", "displ | \n", "year | \n", "cyl | \n", "trans | \n", "drv | \n", "cty | \n", "hwy | \n", "fl | \n", "class | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "dodge | \n", "ram 1500 pickup 4wd | \n", "4.7 | \n", "2008 | \n", "8 | \n", "manual(m6) | \n", "4 | \n", "9 | \n", "12 | \n", "e | \n", "pickup | \n", "
1 | \n", "toyota | \n", "toyota tacoma 4wd | \n", "4.0 | \n", "2008 | \n", "6 | \n", "auto(l5) | \n", "4 | \n", "16 | \n", "20 | \n", "r | \n", "pickup | \n", "
2 | \n", "toyota | \n", "camry | \n", "2.2 | \n", "1999 | \n", "4 | \n", "auto(l4) | \n", "f | \n", "21 | \n", "27 | \n", "r | \n", "midsize | \n", "
3 | \n", "audi | \n", "a4 quattro | \n", "2.0 | \n", "2008 | \n", "4 | \n", "manual(m6) | \n", "4 | \n", "20 | \n", "28 | \n", "p | \n", "compact | \n", "
4 | \n", "jeep | \n", "grand cherokee 4wd | \n", "4.7 | \n", "2008 | \n", "8 | \n", "auto(l5) | \n", "4 | \n", "14 | \n", "19 | \n", "r | \n", "suv | \n", "