Debian Codegraph @

bqplot/examples/Plotting Widgets/Radar.ipynb

raw
1 {
2 "cells": [
3 {
4 "cell_type": "code",
5 "execution_count": null,
6 "id": "aa2c2c2a",
7 "metadata": {},
8 "outputs": [],
9 "source": [
10 "from bqplot import Radar"
11 ]
12 },
13 {
14 "cell_type": "code",
15 "execution_count": null,
16 "id": "e24060e0",
17 "metadata": {},
18 "outputs": [],
19 "source": [
20 "import pandas as pd\n",
21 "import numpy as np\n",
22 "\n",
23 "df = pd.DataFrame(np.random.rand(7, 4), columns=list(\"ABCD\"),\n",
24 " index=[f\"R{i+1}\" for i in range(7)])\n",
25 "radar = Radar(data=df, data_range=[0, 1], fill=True, num_bands=5, band_type=\"circle\", animation_duration=1000)\n",
26 "\n",
27 "# radar is a figure so we can update its title\n",
28 "radar.title = \"Radar\"\n",
29 "\n",
30 "# since radar is a figure (which is a DOM widget) we can directly render it\n",
31 "radar"
32 ]
33 },
34 {
35 "cell_type": "code",
36 "execution_count": null,
37 "id": "bb23866d",
38 "metadata": {},
39 "outputs": [],
40 "source": [
41 "#update data\n",
42 "radar.data = pd.DataFrame(np.random.rand(10, 5), columns=list(\"ABCDE\"),\n",
43 " index=[f\"R{i+1}\" for i in range(10)])"
44 ]
45 },
46 {
47 "cell_type": "code",
48 "execution_count": null,
49 "id": "6e27b684",
50 "metadata": {},
51 "outputs": [],
52 "source": [
53 "# change radar type\n",
54 "radar.band_type = \"polygon\""
55 ]
56 },
57 {
58 "cell_type": "code",
59 "execution_count": null,
60 "id": "9ad12e64",
61 "metadata": {},
62 "outputs": [],
63 "source": [
64 "# no fill\n",
65 "radar.fill = False"
66 ]
67 },
68 {
69 "cell_type": "code",
70 "execution_count": null,
71 "id": "a460a607",
72 "metadata": {},
73 "outputs": [],
74 "source": [
75 "# set number of bands to 8\n",
76 "radar.num_bands = 8"
77 ]
78 },
79 {
80 "cell_type": "code",
81 "execution_count": null,
82 "id": "27719f18",
83 "metadata": {},
84 "outputs": [],
85 "source": [
86 "# since radar is a figure composed of primitive marks we can directly change the internals\n",
87 "# update loop colors\n",
88 "radar.loops.colors = [\"red\", \"magenta\", \"green\", \"orange\"]"
89 ]
90 },
91 {
92 "cell_type": "code",
93 "execution_count": null,
94 "id": "f35dff18",
95 "metadata": {},
96 "outputs": [],
97 "source": [
98 "# remove the band labels\n",
99 "radar.band_labels.text = []"
100 ]
101 },
102 {
103 "cell_type": "code",
104 "execution_count": null,
105 "id": "42d98577",
106 "metadata": {},
107 "outputs": [],
108 "source": [
109 "# remove the spoke labels\n",
110 "radar.spoke_labels.text = []"
111 ]
112 }
113 ],
114 "metadata": {
115 "kernelspec": {
116 "display_name": "Python 3 (ipykernel)",
117 "language": "python",
118 "name": "python3"
119 },
120 "language_info": {
121 "codemirror_mode": {
122 "name": "ipython",
123 "version": 3
124 },
125 "file_extension": ".py",
126 "mimetype": "text/x-python",
127 "name": "python",
128 "nbconvert_exporter": "python",
129 "pygments_lexer": "ipython3",
130 "version": "3.7.12"
131 }
132 },
133 "nbformat": 4,
134 "nbformat_minor": 5
135 }