100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace

Plotly Cheat Sheet

Plotly Cheat Sheet

Plotly reference for building interactive charts with the Express and Graph Objects APIs, subplots, and exporting to HTML or images.

2 PagesIntermediateMar 30, 2026

Plotly Express Basics

High-level API for quick interactive charts.

python
import plotly.express as pxfig = px.scatter(    df, x="gdp_per_cap", y="life_exp", color="continent",    size="population", hover_name="country", log_x=True,)fig.update_layout(title="Life Expectancy vs GDP")fig.show()fig2 = px.line(df, x="date", y="value", color="category")fig2.write_html("chart.html")            # export interactive HTML

Graph Objects API

Low-level API for fine-grained control.

python
import plotly.graph_objects as gofig = go.Figure()fig.add_trace(go.Scatter(x=x, y=y1, mode="lines+markers", name="series A"))fig.add_trace(go.Bar(x=x, y=y2, name="series B"))fig.update_layout(    xaxis_title="X", yaxis_title="Y",    template="plotly_dark",)

Subplots & Export

Combine multiple charts and export static images.

python
from plotly.subplots import make_subplotsfig = make_subplots(rows=1, cols=2, subplot_titles=("Left", "Right"))fig.add_trace(go.Scatter(x=x, y=y), row=1, col=1)fig.add_trace(go.Bar(x=x, y=y2), row=1, col=2)fig.write_image("out.png")               # requires the kaleido package

Common Chart Types

Frequently used Express and Graph Objects charts.

  • px.scatter- scatter plot
  • px.line- line chart
  • px.bar- bar chart
  • px.histogram- histogram
  • px.box / px.violin- distribution comparison across groups
  • px.choropleth- geographic map colored by value
  • px.sunburst / px.treemap- hierarchical part-to-whole charts
  • go.Heatmap- matrix heatmap
Pro Tip

Static image export (fig.write_image or fig.to_image) requires the separate kaleido package installed — without it, only fig.show() and fig.write_html() will work.

Was this cheat sheet helpful?

Explore Topics

#Plotly#PlotlyCheatSheet#DataScience#Intermediate#PlotlyExpressBasics#GraphObjectsAPI#SubplotsExport#CommonChartTypes#OOP#DataStructures#MachineLearning#WebDevelopment#APIs#CheatSheet#SkillVeris
Advertisement
Sri Hayavadhana Info-Tech

Professional Web Designing Services

  • Responsive Websites
  • E-commerce Solutions
  • SEO Friendly Design
  • Fast & Secure
  • Support & Maintenance
Get a Free Quote

Share this Cheat Sheet