Reputation: 321
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 px
df = px.data.gapminder()
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])
I can see the graph but no animation when I click on the run button or try to change the date on the bar. I try to implement others examples. Same result.
I have no error message. Nothing seems to be wrong. I am working on VSCode 1.43.2
Thx for your help.
Upvotes: 3
Views: 2767
Reputation: 2139
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)
Upvotes: 3
Reputation: 2139
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
Upvotes: 0