rajesh1729 commited on
Commit
9bf911d
·
1 Parent(s): 720b5ba

Upload vizzu.ipynb

Browse files
Files changed (1) hide show
  1. vizzu.ipynb +179 -0
vizzu.ipynb ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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": "878b3da3",
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": "ea0d5dd6",
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": "f3818143",
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\"}), style={\"duration\":3, \"delay\": 0.5})\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
+ " style={\"duration\":3,\n",
106
+ " \"delay\": 0.5})\n",
107
+ "\n",
108
+ "\n",
109
+ " \n",
110
+ " chart.animate(\n",
111
+ " Config(\n",
112
+ " {\n",
113
+ " \"channels\": {\n",
114
+ " \"x\": {\"set\": [\"tip\"]},\n",
115
+ " \"y\": {\"set\": [\"time\"]},\n",
116
+ " \"color\": {\"set\": [\"time\"]},\n",
117
+ " \"label\": {\"set\": [\"time\",\"tip\"]},\n",
118
+ " },\n",
119
+ " \"title\": str(gender)+\" tips based on time\",\n",
120
+ " \"coordSystem\": \"polar\",\n",
121
+ " }\n",
122
+ " ),\n",
123
+ " Style(\n",
124
+ " {\n",
125
+ " \"plot\": {\n",
126
+ " \"marker\": {\"label\": {\"fontSize\": 14}},\n",
127
+ " \"xAxis\": {\n",
128
+ " \"title\": {\"color\": \"#ffffff00\"},\n",
129
+ " \"label\": {\"color\": \"#ffffff00\"},\n",
130
+ " \"ticks\": {\"color\": \"#ffffff00\"},\n",
131
+ " \"interlacing\": {\"color\": \"#ffffff00\"},\n",
132
+ " },\n",
133
+ " \"yAxis\": {\n",
134
+ " \"color\": \"#ffffff00\",\n",
135
+ " \"title\": {\"color\": \"#ffffff00\"},\n",
136
+ " \"label\": {\"color\": \"#ffffff00\"},\n",
137
+ " },\n",
138
+ " }\n",
139
+ " }\n",
140
+ " ),\n",
141
+ " style={\"duration\":1,\n",
142
+ " \"delay\": 0.5})\n",
143
+ " \n",
144
+ " "
145
+ ]
146
+ },
147
+ {
148
+ "cell_type": "code",
149
+ "execution_count": null,
150
+ "id": "3ade80c7",
151
+ "metadata": {},
152
+ "outputs": [],
153
+ "source": [
154
+ "draw(gender)"
155
+ ]
156
+ }
157
+ ],
158
+ "metadata": {
159
+ "kernelspec": {
160
+ "display_name": "Python 3 (ipykernel)",
161
+ "language": "python",
162
+ "name": "python3"
163
+ },
164
+ "language_info": {
165
+ "codemirror_mode": {
166
+ "name": "ipython",
167
+ "version": 3
168
+ },
169
+ "file_extension": ".py",
170
+ "mimetype": "text/x-python",
171
+ "name": "python",
172
+ "nbconvert_exporter": "python",
173
+ "pygments_lexer": "ipython3",
174
+ "version": "3.8.13"
175
+ }
176
+ },
177
+ "nbformat": 4,
178
+ "nbformat_minor": 5
179
+ }