Plotly Tutorial
Learn Plotly step by step: 42 lessons in 9 chapters with examples, quizzes, diagrams and projects.
Start learning →
of lessons completed
Getting Started
- What Is Plotly? Meet Plotly: the library that turns data into interactive charts. Learn how plotly.py, plotly.js, Express and Dash fit together, how to install it and how a figure works.
- Plotly Express Basics Learn Plotly Express: one function call turns a DataFrame into a chart. Map columns to x, y, color, size, symbol and facets, set labels and titles, and tweak the result.
- Graph Objects and Figure Anatomy Understand the anatomy of a Plotly figure: traces in data, layout, frames, magic underscores, add_trace and the update_traces and update_layout methods with selectors.
- Data for Plotly Charts Prepare data for Plotly: lists, NumPy arrays, DataFrames, tidy versus wide format, melt and pivot, dates, category order, missing values and the built-in sample datasets.
- Show, Save and Export Figures Display Plotly figures with fig.show and renderers, save them as standalone HTML or JSON, export PNG, SVG and PDF with Kaleido, and tune the toolbar with the config option.
Basic Charts
- Line Charts in Plotly Draw line charts in Plotly with px.line and go.Scatter: multiple lines, markers, dash styles, line shapes, gaps, hover labels and tips for time series and wide data.
- Scatter and Bubble Charts Make scatter plots and bubble charts in Plotly: map columns to color, size and symbol, add hover data, text labels, marginal plots, color scales, log axes and WebGL for big data.
- Bar Charts in Plotly Create bar charts in Plotly with px.bar and go.Bar: grouped, stacked, relative and percent bars, horizontal bars, text labels, sorting, bar colors, gaps and patterns.
- Histograms in Plotly Build histograms in Plotly with px.histogram and go.Histogram: choose bins, normalize to percent or density, aggregate with histfunc, overlay groups, add marginal plots and cumulative views.
- Pie and Donut Charts Make pie and donut charts in Plotly: px.pie and go.Pie, values and names, hole size, pull-out slices, text labels, colors, ordering, multiple pies and when not to use a pie chart.
- Area Charts and Time Series Plot time series in Plotly: area and stacked area charts, percent areas, filling between lines, resampling and moving averages with pandas, range sliders and range selector buttons.
- Sunburst, Treemap and Icicle Charts Show hierarchical data with Plotly sunburst, treemap and icicle charts: use path or ids, labels and parents, branchvalues, color by value, maxdepth and click-to-drill-down.
- Funnel, Waterfall and Candlestick Charts Draw business and finance charts in Plotly: funnel and funnel-area charts for conversion steps, waterfall charts for gains and losses, and candlestick and OHLC charts for prices.
Statistical and Scientific Charts
- Box, Violin and Strip Plots Compare distributions with Plotly box, violin and strip plots: quartiles, whiskers, outliers, notches, means, split violins, jittered points and how to read each plot.
- Distribution Plots and ECDFs Go beyond histograms in Plotly: draw empirical cumulative distribution (ECDF) plots, overlay a KDE curve on a histogram, add rug marks, and build a normal Q-Q plot with SciPy.
- Heatmaps and Contour Plots Draw heatmaps and contour plots in Plotly: px.imshow for matrices and correlation tables, go.Heatmap, 2D histograms with density_heatmap, contour levels, color scales and annotations.
- Trendlines and Error Bars Add statistics to Plotly charts: OLS, LOWESS, rolling and expanding trendlines in Express, read the fit results, draw error bars from data, percent or constants, and shade confidence bands.
- Scatter Matrix, Parallel Coordinates and Radar Charts Explore many variables at once in Plotly: scatter matrix (SPLOM), parallel coordinates and parallel categories with brushing, and radar charts with line_polar and Scatterpolar.
Layout, Styling and Themes
- Layout: Title, Size and Margins Control the look of a Plotly figure with the layout object: titles and subtitles, width and height, autosize, margins, paper and plot backgrounds, and update_layout shortcuts.
- Colors and Color Scales Choose and customize color in Plotly: color formats, discrete sequences, color_discrete_map, continuous and diverging scales, reversed and custom scales, colorbars and colorblind-safe choices.
- Templates and Themes Style every chart at once with Plotly templates: built-in themes like plotly_white and plotly_dark, combining templates, setting a default, and building and registering your own theme.
- Axes, Ticks and Scales Master Plotly axes: titles, ranges, log and date axes, tick values and formats, grid lines, rangebreaks for weekends, equal aspect ratio, reversed axes and a secondary y axis.
- Legends, Fonts and Hover Labels Customize the text of a Plotly chart: legend position, orientation and grouping, fonts and text sizes, hover modes, hovertemplate formatting, customdata, text labels and hover label styling.
Subplots and Annotations
- Subplots with make_subplots Put several charts in one Plotly figure with make_subplots: grids, shared axes, column widths, spans, secondary y-axes, mixed chart types and per-subplot axis updates.
- Annotations, Shapes and Reference Lines Mark up Plotly charts with text annotations, arrows, lines, rectangles, reference lines and shaded regions, using data coordinates or paper coordinates.
- Facets, Small Multiples and Insets Split one dataset into many panels with Plotly Express facet_row and facet_col, control wrapping and axes, then add inset charts and multiple y-axes with domains.
Maps and 3D
- 3D Scatter and Line Plots Build interactive 3D scatter and line plots with Plotly: scatter_3d, line_3d, Scatter3d, colors, sizes, scene axes, camera and when 3D is the wrong choice.
- 3D Surfaces, Meshes and Cameras Draw 3D surfaces, contour projections and triangle meshes in Plotly, fix the camera, lighting and aspect, and learn which surface data shapes are required.
- Geo Maps and Choropleths Draw country and state maps in Plotly: choropleth with ISO codes, scattergeo points and lines, map projections, scope, fitbounds and styling of the geo layer.
- Tile Maps and Density Maps Use Plotly street maps built from map tiles: scatter_map, choropleth_map, density heatmaps, map styles, zoom and center, plus the older mapbox names and tokens.
Interactivity and Animation
- Hover, Click and Events Control Plotly tooltips with hovertemplate, hovermode and customdata, then react to hover, click, selection and zoom events with Plotly.js and Dash.
- Dropdown Menus and Buttons Add dropdown menus and custom buttons to Plotly charts with updatemenus: restyle, relayout, update and animate methods, toggling traces, switching data and chart types.
- Sliders and Range Selectors Add parameter sliders, range sliders and time range selector buttons to Plotly charts: layout.sliders steps, rangeslider, rangeselector, and how they differ.
- Animations and Frames Animate Plotly charts with Plotly Express animation_frame and with go.Frame: play and pause buttons, a frame slider, transitions, fixed axes and bar chart races.
Dash and Deployment
- Your First Dash App Build your first Dash web app in pure Python: install Dash, write a layout with html and dcc components, show a Plotly figure in dcc.Graph, style it and run it locally.
- Dash Callbacks and Live Graphs Make Dash apps interactive with callbacks: Input, Output and State, multiple outputs, chained callbacks, click events, dcc.Store, and live updating graphs with dcc.Interval.
- Exporting and Embedding Figures Save Plotly figures as standalone HTML, JSON, PNG, SVG or PDF with write_html and write_image, embed them in web pages, control config options and share them safely.
- Deploying Plotly and Dash Apps Deploy a Dash app with gunicorn, Docker and a reverse proxy, and keep Plotly charts fast with scattergl, downsampling, caching, smaller figures and safe configuration.
Projects and Practice
- Project: A Sales Dashboard Build a complete sales dashboard in Plotly with pandas: simulated data, KPI indicators, a trend with moving average, category bars, a region heatmap and one combined figure.
- Project: Stock Prices and Time Series Analyze price time series with Plotly and pandas: line charts with range sliders, returns, rolling averages, Bollinger bands, candlestick and volume subplots with a shared axis.
- Project: A World Data Explorer Build an interactive world data explorer with Plotly: animated choropleth, metric dropdown, bubble scatter, top-10 bars and a Dash-ready structure using the gapminder data.
- Plotly Practice and Common Pitfalls Practice Plotly with graded exercises and worked solutions, then review the most common mistakes: wrong data shapes, lost ranges, slow figures, misleading axes and unreadable colors.