Commit
·
0808938
1
Parent(s):
316913f
Upload vizzu.ipynb
Browse files- vizzu.ipynb +176 -0
vizzu.ipynb
ADDED
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "raw",
|
5 |
+
"id": "d5e8b09c",
|
6 |
+
"metadata": {},
|
7 |
+
"source": [
|
8 |
+
"---\n",
|
9 |
+
"title: Animated Data Visualization with Mercury and Ipyvizzu\n",
|
10 |
+
"description: Interactive animated visualizations using Mercury and Ipyvizzu\n",
|
11 |
+
"show-code: False\n",
|
12 |
+
"params:\n",
|
13 |
+
" gender:\n",
|
14 |
+
" input: select\n",
|
15 |
+
" label: select the gender\n",
|
16 |
+
" choices: [Male, Female]\n",
|
17 |
+
" multi: False\n",
|
18 |
+
"---"
|
19 |
+
]
|
20 |
+
},
|
21 |
+
{
|
22 |
+
"cell_type": "markdown",
|
23 |
+
"id": "00d80735",
|
24 |
+
"metadata": {},
|
25 |
+
"source": [
|
26 |
+
"## Interactive animated visualization of Tips dataset\n",
|
27 |
+
"### Choose the gender in the sidebar to get the different visualizations for corresponding gender"
|
28 |
+
]
|
29 |
+
},
|
30 |
+
{
|
31 |
+
"cell_type": "code",
|
32 |
+
"execution_count": null,
|
33 |
+
"id": "63c88b05",
|
34 |
+
"metadata": {},
|
35 |
+
"outputs": [],
|
36 |
+
"source": [
|
37 |
+
"gender = 'Male'"
|
38 |
+
]
|
39 |
+
},
|
40 |
+
{
|
41 |
+
"cell_type": "code",
|
42 |
+
"execution_count": null,
|
43 |
+
"id": "ec20b668",
|
44 |
+
"metadata": {
|
45 |
+
"scrolled": true
|
46 |
+
},
|
47 |
+
"outputs": [],
|
48 |
+
"source": [
|
49 |
+
"import pandas as pd\n",
|
50 |
+
"import seaborn as sns\n",
|
51 |
+
"from ipyvizzu import Chart, Data, Config, Style\n",
|
52 |
+
"\n",
|
53 |
+
"df = pd.read_csv('tips.csv')"
|
54 |
+
]
|
55 |
+
},
|
56 |
+
{
|
57 |
+
"cell_type": "code",
|
58 |
+
"execution_count": null,
|
59 |
+
"id": "97a176a6",
|
60 |
+
"metadata": {},
|
61 |
+
"outputs": [],
|
62 |
+
"source": [
|
63 |
+
"df['count'] = [1 for i in range(244)]"
|
64 |
+
]
|
65 |
+
},
|
66 |
+
{
|
67 |
+
"cell_type": "code",
|
68 |
+
"execution_count": null,
|
69 |
+
"id": "f6b357dc",
|
70 |
+
"metadata": {},
|
71 |
+
"outputs": [],
|
72 |
+
"source": [
|
73 |
+
"def draw(gender):\n",
|
74 |
+
" data = Data()\n",
|
75 |
+
" data.add_data_frame(df.loc[(df.sex==gender)])\n",
|
76 |
+
" chart = Chart()\n",
|
77 |
+
" chart.animate(data)\n",
|
78 |
+
" chart.animate(Config({\"x\": [\"smoker\",'day'] ,\"y\": [\"total_bill\"] ,\"label\":['day','smoker', 'count'], \"color\": \"day\", \"title\": str(gender)+ \" smoker total bill based on days\"}))\n",
|
79 |
+
" chart.animate(Config({\"y\": [\"smoker\",'day'] ,\"x\": [\"tip\"] ,\"label\":['day','smoker', 'count'], \"color\": \"day\", \"title\":str(gender)+\" tips based on days\"}))\n",
|
80 |
+
" chart.animate(\n",
|
81 |
+
" Config(\n",
|
82 |
+
" {\n",
|
83 |
+
" \"channels\": {\n",
|
84 |
+
" \"x\": {\"set\": [\"total_bill\"]},\n",
|
85 |
+
" \"y\": {\"set\": [\"day\"]},\n",
|
86 |
+
" \"color\": {\"set\": [\"day\"]},\n",
|
87 |
+
" \"label\": {\"set\": [\"total_bill\"]},\n",
|
88 |
+
" },\n",
|
89 |
+
" \"title\": str(gender)+\" total bill day wise\",\n",
|
90 |
+
" \"coordSystem\": \"polar\",\n",
|
91 |
+
" }\n",
|
92 |
+
" ),\n",
|
93 |
+
" Style(\n",
|
94 |
+
" {\n",
|
95 |
+
" \"plot\": {\n",
|
96 |
+
" \"yAxis\": {\"color\": \"#ffffff00\", \"label\": {\"paddingRight\": 20}},\n",
|
97 |
+
" \"xAxis\": {\n",
|
98 |
+
" \"title\": {\"color\": \"#ffffff00\"},\n",
|
99 |
+
" \"label\": {\"color\": \"#ffffff00\"},\n",
|
100 |
+
" \"interlacing\": {\"color\": \"#ffffff00\"},\n",
|
101 |
+
" },\n",
|
102 |
+
" }\n",
|
103 |
+
" }\n",
|
104 |
+
" ),\n",
|
105 |
+
")\n",
|
106 |
+
"\n",
|
107 |
+
" \n",
|
108 |
+
" chart.animate(\n",
|
109 |
+
" Config(\n",
|
110 |
+
" {\n",
|
111 |
+
" \"channels\": {\n",
|
112 |
+
" \"x\": {\"set\": [\"tip\"]},\n",
|
113 |
+
" \"y\": {\"set\": [\"time\"]},\n",
|
114 |
+
" \"color\": {\"set\": [\"time\"]},\n",
|
115 |
+
" \"label\": {\"set\": [\"time\",\"tip\"]},\n",
|
116 |
+
" },\n",
|
117 |
+
" \"title\": str(gender)+\" tips based on time\",\n",
|
118 |
+
" \"coordSystem\": \"polar\",\n",
|
119 |
+
" }\n",
|
120 |
+
" ),\n",
|
121 |
+
" Style(\n",
|
122 |
+
" {\n",
|
123 |
+
" \"plot\": {\n",
|
124 |
+
" \"marker\": {\"label\": {\"fontSize\": 14}},\n",
|
125 |
+
" \"xAxis\": {\n",
|
126 |
+
" \"title\": {\"color\": \"#ffffff00\"},\n",
|
127 |
+
" \"label\": {\"color\": \"#ffffff00\"},\n",
|
128 |
+
" \"ticks\": {\"color\": \"#ffffff00\"},\n",
|
129 |
+
" \"interlacing\": {\"color\": \"#ffffff00\"},\n",
|
130 |
+
" },\n",
|
131 |
+
" \"yAxis\": {\n",
|
132 |
+
" \"color\": \"#ffffff00\",\n",
|
133 |
+
" \"title\": {\"color\": \"#ffffff00\"},\n",
|
134 |
+
" \"label\": {\"color\": \"#ffffff00\"},\n",
|
135 |
+
" },\n",
|
136 |
+
" }\n",
|
137 |
+
" }\n",
|
138 |
+
" ),\n",
|
139 |
+
")\n",
|
140 |
+
" \n",
|
141 |
+
" "
|
142 |
+
]
|
143 |
+
},
|
144 |
+
{
|
145 |
+
"cell_type": "code",
|
146 |
+
"execution_count": null,
|
147 |
+
"id": "22c92725",
|
148 |
+
"metadata": {},
|
149 |
+
"outputs": [],
|
150 |
+
"source": [
|
151 |
+
"draw(gender)"
|
152 |
+
]
|
153 |
+
}
|
154 |
+
],
|
155 |
+
"metadata": {
|
156 |
+
"kernelspec": {
|
157 |
+
"display_name": "Python 3 (ipykernel)",
|
158 |
+
"language": "python",
|
159 |
+
"name": "python3"
|
160 |
+
},
|
161 |
+
"language_info": {
|
162 |
+
"codemirror_mode": {
|
163 |
+
"name": "ipython",
|
164 |
+
"version": 3
|
165 |
+
},
|
166 |
+
"file_extension": ".py",
|
167 |
+
"mimetype": "text/x-python",
|
168 |
+
"name": "python",
|
169 |
+
"nbconvert_exporter": "python",
|
170 |
+
"pygments_lexer": "ipython3",
|
171 |
+
"version": "3.8.13"
|
172 |
+
}
|
173 |
+
},
|
174 |
+
"nbformat": 4,
|
175 |
+
"nbformat_minor": 5
|
176 |
+
}
|