Plotly Express Basics
Create charts quickly.
Plotly Express Basics is a free Python Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Python Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
What Plotly Express Is
Plotly Express (imported as px) is a high-level interface for making interactive charts with very little code. One function call usually produces a complete, polished figure.
Where Matplotlib is static by default, Plotly figures are interactive: you can hover, zoom, and pan in the browser.
The Tidy Data Idea
Plotly Express works best with tidy data: each row is one observation and each column is one variable. You then name columns to map them onto chart features.
We can model a tidy dataset as a list of dictionaries.
rows = [
{'country': 'A', 'year': 2020, 'gdp': 100},
{'country': 'A', 'year': 2021, 'gdp': 110},
{'country': 'B', 'year': 2020, 'gdp': 80},
]
for r in rows:
print(r['country'], r['year'], r['gdp'])Your First Chart
A line chart is one call: px.line(df, x='year', y='gdp', color='country'). The color argument automatically splits the data into one line per country and builds a legend.
No manual looping over series is required.
Common Express Functions
Each chart type has its own function:
px.linetrendspx.barcategory comparisonpx.scatterrelationshipspx.histogramdistributionspx.pieparts of a whole
They all share the same column-mapping style.
Mapping Columns to Encodings
The power of Express is mapping columns to visual channels: x, y, color, size, symbol, and facet_col. Each argument takes a column name.
Choosing which column goes where is the main design decision.
encodings = {'x': 'year', 'y': 'gdp', 'color': 'country', 'size': 'population'}
for channel, column in encodings.items():
print(channel.ljust(6), '<-', column)Scatter with Color and Size
A single scatter call can show four variables: px.scatter(df, x='gdp', y='life', color='continent', size='population'). This is how the famous Gapminder bubble chart is built in one line.
Express picks sensible scales and a legend automatically.
Faceting
Faceting splits one chart into a grid of small multiples by a category, using facet_col='region' or facet_row. Each panel shares scales, making comparison easy.
The number of panels equals the number of unique category values.
regions = ['North', 'South', 'East', 'West']
print('facet_col=region produces', len(regions), 'panels')
for r in regions:
print(' panel:', r)Built-in Sample Data
Plotly ships datasets for practice via px.data, such as px.data.iris() and px.data.gapminder(). They return ready-to-plot tidy data, so you can experiment without finding files.
The Figure Object
Every Express call returns a Figure object. You can display it with fig.show(), tweak it with fig.update_layout(...), or save it. Express gives you a great starting figure that you can still refine.
Express vs Graph Objects
Under the hood Express builds graph objects (plotly.graph_objects). Use Express for speed; drop to graph objects when you need fine control Express does not expose. Both produce the same interactive output.
Titles and Labels in Express
Express accepts a title argument and a labels dictionary that renames columns for display, for example labels={'gdp': 'GDP per capita'}. You set readable names without touching the underlying data.
This keeps your data columns terse while the chart stays friendly.
Quick Check
Check your understanding of Plotly Express.
Recap
You learned Plotly Express fundamentals:
- One function call (
px.line,px.bar,px.scatter...) per chart - Data should be tidy, one row per observation
- Map columns to channels:
x,y,color,size,facet_col - Each call returns an interactive
Figureyou can further customize
Frequently asked questions
Is the “Plotly Express Basics” lesson free?
Yes — the full text of “Plotly Express Basics” is free to read here on the web, and the Python Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Python Academy course, upgrade to CoddyKit PRO.
What will I learn in “Plotly Express Basics”?
Create charts quickly. You practise Python Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Python Academy?
No prior experience is required. Python Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Plotly Express Basics” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Python Academy lesson?
Yes. Every Python Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Plotly Express Basics
- Interactive Features
- Dashboards Concepts
- Exporting and Embedding