Plotly
74 words
1 min read
Visual companion
Python
Type and operator map
Python Week 1: the first filter for runtime behavior
View
Revision summary
What this note is really saying
Short form
# Plotly [Join Discord](https://discord.gg/gE2m4Qrdqv) [Previous**Seaborn**](/notes/04-degree-electives-bscs4001-data-viz-week05-05-seaborn)[Next**Animation & Interaction**](/notes/04-degree-electives-bscs4001-data-viz-week06-06b-animation-interaction)

Plotly
pythonimport plotly.express as px import plotly.graph_objects as go import pandas as pd import numpy as np df = px.data.gapminder() # Scatter plot with animation fig = px.scatter(df, x='gdpPercap', y='lifeExp', size='pop', color='continent', log_x=True, size_max=60, animation_frame='year', title='Gapminder Data over Time') fig.show() # Line chart fig = go.Figure() for continent in df['continent'].unique(): subset = df[df['continent'] == continent] fig.add_trace(go.Scatter( x=subset['year'], y=subset['lifeExp'], mode='lines', name=continent )) fig.update_layout(title='Life Expectancy by Continent') fig.show()