Skip to main content

1. Introduction to Plotly

Plotly is a powerful Python library used for creating interactive, publication-quality, and web-based visualizations.

Features

  • Interactive graphs (zoom, pan, hover)
  • 2D and 3D plotting
  • Animation support
  • Statistical charts
  • Geographic maps
  • Dashboard integration with Dash
  • Export graphs as HTML, PNG, PDF, SVG

2. Installation

For Jupyter Notebook:
Import Plotly:

3. Plotly Modules


4. Plotly Express

Plotly Express is the easiest interface. Example:
Image

5. Basic Charts

A. Line Chart

Image

B. Scatter Plot

Image

C. Bar Chart

Plotly Barplot

D. Histogram

Plotly Histogram

E. Box Plot

Plotly Boxplot1

F. Violin Plot

Plotly Voilinplot

G. Pie Chart

Plotly Piechart

H. Area Chart

Plotly Areachart

6. Bubble Chart

Plotly Bubblechart

7. Sunburst Chart

Plotly Sunbrust

8. Treemap

Plotly Treemap

9. Funnel Chart

Plotly Funnelchart

10. Density Heatmap

Plotly Density1

11. Density Contour

Plotly Density2

12. Choropleth Map

Plotly Cmap

13. Scatter Geo

Plotly Scattergeo

14. Timeline Chart

Plotly Timeline

15. Polar Chart

Plotly Polar

16. Radar Chart

Plotly Radar

17. 3D Scatter Plot

Plotly 3dscatter

18. 3D Line Plot

Plotly 3dline

19. Surface Plot

Plotly Surface

20. Mesh3D

Plotly Mesh3d

21. Graph Objects

Graph Objects provide full control.
Plotly Go

22. Figure Layout

Plotly Go2

23. Templates


24. Multiple Traces

Plotly Multitrace

25. Subplots

Plotly Subplot

26. Update Traces


27. Update Axes


28. Hover Information


29. Annotations


30. Shapes

Rectangle:
Line:

31. Animation

Plotly Animation

32. Export Graph

HTML:
PNG:
(Requires the kaleido package.)

33. Display Figure


34. Common Plotly Express Parameters


35. Common Graph Objects

  • go.Scatter
  • go.Bar
  • go.Pie
  • go.Box
  • go.Violin
  • go.Histogram
  • go.Heatmap
  • go.Surface
  • go.Mesh3d
  • go.Scatter3d
  • go.Scatterpolar
  • go.Indicator
  • go.Table
  • go.Funnel

36. Advantages of Plotly

  • Interactive visualizations
  • Browser-based rendering
  • Publication-quality graphics
  • Supports 2D and 3D charts
  • Easy integration with Dash
  • Highly customizable
  • Animation support
  • Hover tooltips and zooming
  • Export to HTML and images

37. Limitations

  • Can be slower with very large datasets
  • More memory-intensive than static libraries
  • Some advanced exports require additional packages (such as kaleido)

38. Plotly vs Matplotlib


39. Summary

  • Plotly Express (px) is ideal for quickly creating interactive charts.
  • Graph Objects (go) provide fine-grained control and customization.
  • Key chart types: Line, Scatter, Bar, Pie, Histogram, Box, Violin, Heatmap, Treemap, Sunburst, Funnel, Timeline, Polar, 3D Scatter, Surface, Mesh3D, and Geographic Maps.
  • Core workflow: Create a Figure, add traces (if using go), customize with update_layout(), update_traces(), and update_xaxes()/update_yaxes(), then display with fig.show() or export with write_html()/write_image().