{ "cells": [ { "cell_type": "markdown", "id": "e18c42f4", "metadata": {}, "source": [ "# geom_pie()" ] }, { "cell_type": "markdown", "id": "65348da9", "metadata": {}, "source": [ "A pie chart is a circular statistical graphic, which is divided into slices to illustrate numerical proportion." ] }, { "cell_type": "markdown", "id": "4e5b3651", "metadata": {}, "source": [ "1. [Default presentation](#1.-Default-presentation)\n", "\n", " 1.1. [Basic pie chart](#1.1.-Basic-pie-chart)\n", "\n", " 1.2. [Improve appearance](#1.2.-Improve-appearance) \n", "\n", " 1.3. [Adding labels to pie sectors](#1.3.-Adding-labels-to-pie-sectors) \n", "\n", " 1.4. [Use \"count2d\" statistical transformation](#1.4.-Use-\"count2d\"-statistical-transformation)\n", "\n", "\n", "2. [Pie size depending on data](#2.-Pie-size-depending-on-data)\n", "\n", "\n", "3. [Explode](#3.-Explode)" ] }, { "cell_type": "code", "execution_count": 1, "id": "de93dd34", "metadata": { "execution": { "iopub.execute_input": "2024-04-17T07:31:10.172971Z", "iopub.status.busy": "2024-04-17T07:31:10.172889Z", "iopub.status.idle": "2024-04-17T07:31:10.493361Z", "shell.execute_reply": "2024-04-17T07:31:10.493032Z" } }, "outputs": [], "source": [ "from lets_plot import *\n", "from lets_plot.mapping import *" ] }, { "cell_type": "code", "execution_count": 2, "id": "53eadd20", "metadata": { "execution": { "iopub.execute_input": "2024-04-17T07:31:10.494821Z", "iopub.status.busy": "2024-04-17T07:31:10.494704Z", "iopub.status.idle": "2024-04-17T07:31:10.496701Z", "shell.execute_reply": "2024-04-17T07:31:10.496529Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "LetsPlot.setup_html() " ] }, { "cell_type": "code", "execution_count": 3, "id": "d5962f75", "metadata": { "execution": { "iopub.execute_input": "2024-04-17T07:31:10.497720Z", "iopub.status.busy": "2024-04-17T07:31:10.497552Z", "iopub.status.idle": "2024-04-17T07:31:10.499241Z", "shell.execute_reply": "2024-04-17T07:31:10.499064Z" } }, "outputs": [], "source": [ "w,h = 400,250\n", "\n", "df = {\n", " 'name': ['a', 'b', 'c', 'd', 'b'],\n", " 'value': [40, 90, 10, 50, 20 ],\n", "}\n", "\n", "p = ggplot(df) + ggsize(w,h)" ] }, { "cell_type": "markdown", "id": "3920b3eb", "metadata": {}, "source": [ "## 1. Default presentation" ] }, { "cell_type": "markdown", "id": "131ea087", "metadata": {}, "source": [ "### 1.1. Basic pie chart" ] }, { "cell_type": "markdown", "id": "b9807822", "metadata": {}, "source": [ "Use \"identity\" statistical transformation to leave the data unchanged." ] }, { "cell_type": "code", "execution_count": 4, "id": "2a268816", "metadata": { "execution": { "iopub.execute_input": "2024-04-17T07:31:10.500143Z", "iopub.status.busy": "2024-04-17T07:31:10.500069Z", "iopub.status.idle": "2024-04-17T07:31:10.531588Z", "shell.execute_reply": "2024-04-17T07:31:10.531291Z" } }, "outputs": [ { "data": { "text/html": [ " \n", " " ], "text/plain": [ "