How To Make Plotly Graph Animated Working
Hi I am trying to use Plotly v4.6. Everything is working fine. I can see all graphs except when I tried to replicate the animated graph from the website: import plotly.express as
Solution 1:
I tested this code on my jupyter and it works. You need to make plotly offline It opens another tab and show animation. Another thing is you need to use plot to render it in anaconda.
import plotly.express as px
from plotly.offline import plot
df = px.data.gapminder()
fig=px.scatter(df, x="gdpPercap", y="lifeExp", animation_frame="year", animation_group="country",
size="pop", color="continent", hover_name="country",
log_x=True, size_max=55, range_x=[100,100000], range_y=[25,90])
plot(fig)
Solution 2:
There are couple of additional installation steps: https://plot.ly/python/getting-started/#jupyterlab-support-python-35
or follow:
https://plotly.com/python/troubleshooting/
import plotly.express as px
df = px.data.gapminder()
px.scatter(df, 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”) )
Or please check: How to show graph in Visual Studio Code itself?
Install Python Extension Pack, it includes Jupyter extension, put your code in the editor, put #%% at the top of your code, you'll get Run cell clickable, click it, and you'll get result in the other window.
For Visual Studio use Neuron:
https://marketplace.visualstudio.com/items?itemName=neuron.neuron-IPE
Post a Comment for "How To Make Plotly Graph Animated Working"