from IPython.display import HTML
HTML('''<script>
code_show=false;
function code_toggle() {
if (code_show){
$('div.input').show();
} else {
$('div.input').hide();
}
code_show = !code_show
}
$( document ).ready(code_toggle);
</script>
<form action="javascript:code_toggle()"><input type="submit" value="Click here to toggle on/off the raw code."></form>''')
import pandas as pd
import holoviews as hv
hv.extension('bokeh')
# 100% width
from IPython.core.display import display, HTML
display(HTML("<style>.container { width:100% !important; }</style>"))
import plotly.express as px
df = px.data.gapminder()
df.head(10)
display('We have a total of # countries : {0}'.format(len(df.country.unique())))
countries = df.country.unique()
# we can narrow down to these countries
#countries = ['United States', 'United Kingdom', 'Japan', 'Rwanda','Guatemala', 'China', 'India', ]
df_filtered = df[df['country'].isin(countries)]
fig = px.scatter(df_filtered, x = "gdpPercap", y = "lifeExp", animation_frame = "year", animation_group = "country",
size = "pop", color = "country", log_x = True, size_max = 45,
range_x = [100, 100000], range_y = [25, 90], height=800
#text = 'country'
)
fig.show()