First of all: Thank you for plotly_express. I like the API and itโs very comfortable to use for me.
but recently I had a problem: I was trying to recreate the gapminder plot from https://www.plotly.express, and post it on my plotly profile:
So, I did this in my Jupyter Notebook:
import plotly_express as px
import plotly.plotly as py
import plotly.graph_objs as go
gapminder = px.data.gapminder()
fig = px.scatter(gapminder, x="gdpPercap", y="lifeExp",size="pop", size_max=60, color="continent", hover_name="country",
animation_frame="year", animation_group="country", log_x=True, range_x=[100,100000], range_y=[25,90],
labels=dict(pop="Population", gdpPercap="GDP per Capita", lifeExp="Life Expectancy"),)
fig.update(layout = dict(title = 'The famous Gapminder Plot',annotations=[{
"x": 0.0,
"y": -0.1,
'font':{'family':'Arial','size':12,'color':'rgb(150,150,150)'},
"showarrow": False,
"text": 'Inspired by <a href=\"https://www.gapminder.org/\">https://www.gapminder.org</a><br>Produced with <a href=\"https://www.plotly.express/\">https://www.plotly.express</a>',
"xref": "paper",
"yref": "paper"
}]))
This worked fine. Then I tried to iplot the whole thing:
fig = px.scatter(gapminder, x="gdpPercap", y="lifeExp",size="pop", size_max=60, color="continent", hover_name="country",
animation_frame="year", animation_group="country", log_x=True, range_x=[100,100000], range_y=[25,90],
labels=dict(pop="Population", gdpPercap="GDP per Capita", lifeExp="Life Expectancy"))
fig.update(layout = dict(title = 'The famous Gapminder Plot',annotations=[{
"x": 0.0,
"y": -0.1,
'font':{'family':'Arial','size':12,'color':'rgb(150,150,150)'},
"showarrow": False,
"text": 'Inspired by <a href=\"https://www.gapminder.org/\">https://www.gapminder.org</a><br>Produced with <a href=\"https://www.plotly.express/\">https://www.plotly.express</a>',
"xref": "paper",
"yref": "paper"
}]))
py.iplot(fig, filename='Gapminder')
That also worked: https://plot.ly/~alexander.guentert/23
But, sadly the animation are not working online.
Is there a way to solve that?