Spaces:
Runtime error
Runtime error
rickystanley76
commited on
Commit
•
5b426bb
1
Parent(s):
518af8c
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
"""
|
3 |
+
Created on Thu Feb 10 11:34:26 2022
|
4 |
+
|
5 |
+
@author: Ricky D Cruze
|
6 |
+
Hans Rosling Gapminder
|
7 |
+
"""
|
8 |
+
|
9 |
+
import plotly_express as px
|
10 |
+
import pandas as pd
|
11 |
+
import streamlit as st
|
12 |
+
|
13 |
+
# emojis: https://www.webfx.com/tools/emoji-cheat-sheet/
|
14 |
+
st.set_page_config(page_title="Hans Rosling's Iconic Animated Motion Chart", page_icon=":purple_heart:", layout= "wide")
|
15 |
+
|
16 |
+
|
17 |
+
### --- LOAD DATAFRAME
|
18 |
+
gapminder = px.data.gapminder()
|
19 |
+
##making variables for later use
|
20 |
+
country = gapminder['country'].unique().tolist()
|
21 |
+
year = gapminder['year'].unique().tolist()
|
22 |
+
continent = gapminder['continent'].unique().tolist()
|
23 |
+
################################################
|
24 |
+
|
25 |
+
st.header('Scatter plot animation using Gapminder dataset!')
|
26 |
+
## Scatter plot animation
|
27 |
+
|
28 |
+
animated_scatter= px.scatter(gapminder, x="gdpPercap", y="lifeExp", animation_frame="year", animation_group="country",
|
29 |
+
size="pop", color="country", hover_name="country",
|
30 |
+
log_x=True, size_max=55, range_x=[100,100000], range_y=[25,90],template= 'plotly_white', width=1000, height=800)
|
31 |
+
st.write(animated_scatter)
|
32 |
+
|
33 |
+
##################
|
34 |
+
|
35 |
+
|
36 |
+
|
37 |
+
st.header('Who is Hans Rosling?')
|
38 |
+
|
39 |
+
head_col1, head_col2 = st.columns(2)
|
40 |
+
with head_col1:
|
41 |
+
st.subheader("From Wikipedia: ")
|
42 |
+
st.write("""Hans Rosling (Swedish pronunciation: [ˈhɑːns ˈrûːslɪŋ]; 27 July 1948 – 7 February 2017) was a Swedish physician,
|
43 |
+
academic, and public speaker. He was a professor of international health at Karolinska Institute[4] and
|
44 |
+
was the co-founder and chairman of the Gapminder Foundation, which developed the Trendalyzer software system.
|
45 |
+
He held presentations around the world, including several TED Talks[5] in which he promoted the use of data
|
46 |
+
(and data visualization) to explore development issues.[6] His posthumously published book Factfulness,
|
47 |
+
coauthored with his daughter-in-law Anna Rosling Rönnlund and son Ola Rosling, became an international bestseller.[7]""")
|
48 |
+
|
49 |
+
|
50 |
+
with head_col2:
|
51 |
+
showpicture = st.checkbox('Like to see his picture: ')
|
52 |
+
if showpicture:
|
53 |
+
st.image("hans.jpg")
|
54 |
+
|
55 |
+
|
56 |
+
|
57 |
+
|
58 |
+
|
59 |
+
|
60 |
+
|
61 |
+
|
62 |
+
|
63 |
+
|
64 |
+
# ---- HIDE STREAMLIT STYLE ----
|
65 |
+
hide_st_style = """
|
66 |
+
<style>
|
67 |
+
#MainMenu {visibility: hidden;}
|
68 |
+
footer {visibility: hidden;}
|
69 |
+
header {visibility: hidden;}
|
70 |
+
</style>
|
71 |
+
"""
|
72 |
+
st.markdown(hide_st_style, unsafe_allow_html=True)
|
73 |
+
|
74 |
+
|
75 |
+
|
76 |
+
|